Search Results

Search found 5942 results on 238 pages for 'total starnger'.

Page 200/238 | < Previous Page | 196 197 198 199 200 201 202 203 204 205 206 207  | Next Page >

  • How do I vertcally align thumbnails of unknown height using jQuery?

    - by playahabana
    Ok, I am a complete beginner to this, in fact I am still building my first website. I am attempting to do this all by hand-coding without a CMS in order to try and learn as much possible as quickly as possible. If this post is in the wrong place I apologise, and a pointer to right place would be appreciated. Here goes, I am trying to peice together a bit of jQuery that will automatically vertically align my thumbnails in my image gallery (they are all different sizes). They are within fixed size div's and the function I am attempting looks something like this: <script type="text/javascript"> $('#ul.photo).bind(function() { var smartVert=$(this); var phty=ob.("ul.photo img").height(); //get height of photos var phtdif=Math.floor(208 - phty); //subtract height of photo from div height var phttop=Math.floor(phtdif / 2); //gets padding reqd. $ob.("ul.photo").css({'padding-top' : phttop}) //sets padding to center thumbnail }); smartVert(); unsurprisingly this doesn't work, if some kindly soul could take pity on a total noob, and point out where I am going wrong (probably in writing complete gibberish would be my first guess) it would be greatly appreciated- even if you could just point me in the direcion of a tutorial regarding these things, I have looked and found one reference that said such a function was easy to create, but it did not elaborate. thankyou in advance

    Read the article

  • How to format JSON Date?

    - by Mark Struzinski
    I'm taking my first crack at AJAX with jQuery. I'm getting my data onto my page, but I'm having some trouble with the JSON that is returned for Date data types. Basically, I'm getting a string back that looks like this: /Date(1224043200000)/ From a total newbie at JSON - How do I format this to a short date format? Should this be handled somewhere in the jQuery code? I've tried the jQuery.UI.datepicker plugin using $.datepicker.formatDate() wiuth no success. FYI: Here's the solution I came up with using a combination of the answers here: function getMismatch(id) { $.getJSON("Main.aspx?Callback=GetMismatch", { MismatchId: id }, function(result) { $("#AuthMerchId").text(result.AuthorizationMerchantId); $("#SttlMerchId").text(result.SettlementMerchantId); $("#CreateDate").text(formatJSONDate(Date(result.AppendDts))); $("#ExpireDate").text(formatJSONDate(Date(result.ExpiresDts))); $("#LastUpdate").text(formatJSONDate(Date(result.LastUpdateDts))); $("#LastUpdatedBy").text(result.LastUpdateNt); $("#ProcessIn").text(result.ProcessIn); } ); return false; } function formatJSONDate(jsonDate){ var newDate = dateFormat(jsonDate, "mm/dd/yyyy"); return newDate; } This solution got my object from the callback method and displayed the dates on the page properly using the date format library.

    Read the article

  • Save a tab in a jQuery Modal Window for future Display

    - by Shauni
    Hello, long time reader, first time poster. I’m coming with an issue that many of you will find trivial but I’m bashing my head against it for too long time and I can’t seems to find any clue on the internet. As a total scrubs with JavaScript, I’m trying to use JQuery.ui smartmodal windows (v 1.8.rc1) for displaying two football teams in two separate tabs. Like France in Tab(0) and England in Tab(1). When I open this modal window, the first tab (France) is always opened by default. Everything’s fine until here : I’m trying to improve this modal window by remembering what was the last Tab the user was looking when he closed the modal, for reopening it (in spite of the first tab, by default) when the user will reopen this modal latter on. I’ve already tried to use the “selecting & loading a jquery tab programatically » method but without any kind of success, and I’m slowly running out of options (and time). Thanks for reading me, if you have any idea on how can I use a parameter in the smartmodal call, that would greatly help me.

    Read the article

  • Large Product catalog with statistics - alternatives to Sql Server?

    - by Eric P
    I am building UI for a large product catalog (millions of products). I am using Sql Server, FreeText search and ASP.NET MVC. Tables are normalized and indexed. Most queries take less then a second to return. The issue is this. Let's say user does the search by keyword. On search results page I need to display/query for: First 20 matching products (paged, sorted) Total count of matching products for paging List of stores only of matching products List of brands only of matching products List of colors only of matching products Each query takes about .5 to 1 seconds. Altogether it is like 5 seconds. I would like to get the whole page to load under 1 second. There are several approaches: Optimize queries even more. I already spent a lot of time on this one, so not sure it can be pushed further. Load products first, then load the rest of the information using AJAX. More like a workaround. Will need to revise UI. Re-organize data to be more Report friendly. Already aggregated a lot of fields. I checked out several similar sites. For ex. zappos.com. Not only they display the same information as I would like in under 1 second, but they also include statistics (number of results in each category). The following is the search for keyword "white" http://www.zappos.com/white How do sites like zappos, amazon make their results, filters and stats appear almost instantly?

    Read the article

  • Find class in table row

    - by meep
    Hello. Take a look at this table: <table cellpadding="0" cellspacing="0" class="order_form"> <tr> <th>Amount</th> <th>Desc</th> <th>Price</th> <th>Total</th> </tr> <tr> <td><input type="text" class="order_count" /></td> <td> <span class="order_desc">Middagstallerken</span> </td> <td> <span class="order_price">1,15</span> </td> <td> <span class="order_each_total"></span> </td> </tr> [...] </table> Upon entering amount I need to select the class "order_price" and multiply it with the value of the input "order_count" and place it in "order_each_count". I have millions of these rows so I need to find the next class in the row. I have tried using some function like this but without result: <script type="text/javascript"> $(document).ready(function(){ $('.order_count').keyup(function() { var each_price = $(this).prevUntil("tr").find("span.order_price").text(); }); }); </script> I hope someone have a good solution :-)

    Read the article

  • How to remove words based on a word count

    - by Chris
    Here is what I'm trying to accomplish. I have an object coming back from the database with a string description. This description can be up to 1000 characters long, but we only want to display a short view of this. So I coded up the following, but I'm having trouble in actually removing the number of words after the regular expression finds the total count of words. Does anyone have good way of dispalying the words which are less than the Regex.Matches? Thanks! if (!string.IsNullOrEmpty(myObject.Description)) { string original = myObject.Description; MatchCollection wordColl = Regex.Matches(original, @"[\S]+"); if (wordColl.Count < 70) // 70 words? { uxDescriptionDisplay.Text = string.Format("<p>{0}</p>", myObject.Description); } else { string shortendText = original.Remove(200); // 200 characters? uxDescriptionDisplay.Text = string.Format("<p>{0}</p>", shortendText); } }

    Read the article

  • MS 70-536 .NET Framework Foundation - info on Exam? Especially regex?

    - by Sebastian P.R. Gingter
    Hi, I know there are already some questions about this, but not that specific. I have the self-paced training kit and worked through the test exam tool that is on the CD coming with the book. I constantly fail on the test tool, mostly on the regex questions. I'm not a regex guru. In fact my regex-fu is more than weak. I know what regex'es are, how I can use them and where my 'Regular expressions - kurz und gut' book is in my drawer in case I really need them. And to be honest I feel like learning regex is a total waste of time, because if I need them I have either a colleague that is fit and can do them in just a few seconds or I need my book and get them right in a still fair amount of time. And from my experience I can tell that I need regex like once in two or three years. So just putting in a lot of time into learning just the expressions to pass the exam is.. something I like not to have to do. Can you tell me something about the real exam vs. the test exam tool on the book and about the need to know regex for passing it? Thank you for your time. Marked as Community Wiki. Hope that fits?

    Read the article

  • Run script after Jquery finish

    - by Felipe Fernández
    First let's explain the hack that I was trying to implement. When using Total Validator Tool through my web page and I get following error: [WCAG v1 6.3 (A), US-508-l] Consider providing a alternative after each tag As my page relies heavily on javascript I can't provide a real alternative, so I decided to add an empty noscript tag after every script appearence. Let's say I need to provide a clean report about accesibility about my web page even the hack is senseless. (I know the hack is unethical and silly, let's use it as example material, but the point of my post are the final questions) I tried the following approach: $(document).ready(function(){ $("script").each(function() { $(this).after("<noscript></noscript>"); }); }); The problem raises because I have a jQueryUI DatePicker component on my page. jQuery adds a script section after the DOM is ready so my hack fails as miss this section. So the questions are: How handles jQuery library to be executed after document is ready? How can I run my code after jQuery finish its labours?

    Read the article

  • HTML5: Rendering absolute images using canvas

    - by Mark
    I am experimenting with canvas as part of my HTML5 introduction. This constitutes as assignment work, but I am not asking for any help on the actual coursework at all. I am trying to write a rendering engine, but having no luck because once the image is drawn on canvas it looks very distorted, and not at the right dimensions of the image itself. I have made a animation engine that loads images into an array, and then iterates through them at a certain speed. This is not the problem, and I assume is not causing the issue as this was happening when I drawn an image to the canvas. I think this is natural behaviour for images to be scaled/skewed when the window is resized, so I conquered that by simply redrawing the whole thing once the window is resized. The images I am using are isometric, and drawn at a pixel level. Would this cause the distortion? It seems setting the dimensions on the drawImage() function are not working are all. I am using JavaScript for the manipulation and rendering of the canvas. I would normally try and work it out myself, but I do not have any time to ponder why because I have no idea why it is even scaling/skewing the image once it is drawn on the canvas. I cannot share the code for obvious reasons. I should also mention, the canvas's dimension is the total width of the viewport, as I am developing a game. My question is: Has anyone encountered this and how would I correct it? Thanks for your help.

    Read the article

  • ecommerce - use server side code for hidden values in an html form

    - by bsarmi
    I'm trying to learn how to implement a donation form on a website using virtual merchant. The html code from their developer manual goes like this: <form action="https://www.myvirtualmerchant.com/VirtualMerchant/process.do" method="POST"> Your Total: $5.00 <br/> <input type="hidden" name="ssl_amount" value="5.00"> <br/> <input type="hidden" name="ssl_merchant_id" value="my_virtualmerchant_ID"> <input type="hidden" name="ssl_pin" value="my_PIN"> <input type="hidden" name="ssl_transaction_type" value="ccsale"> <input type="hidden" name="ssl_show_form" value="false"> Credit Card Number: <input type="text" name="ssl_card_number"> <br/> Expiration Date (MMYY): <input type="text" name="ssl_exp_date" size="4"> <br/> <br/> <input type="submit" value="Continue"> </form> I have that in an html file and it works fine, but they suggest that the merchant data (the input type="hidden" values) should be in a Server Side Code. I was looking at cURL but it'a all very new to me and I spent a couple of hours trying to find some guide or some sample code on how to accomplish that. Any suggestions or help is greatly appreciated. Thanks!

    Read the article

  • next previous button in div jquery mobile

    - by satine kianne
    i have a total of 11 div in my app. what i want to do is to display 3 divs in between 2 permanent div it should look like this |first permanent div| |div 1| |div 2| |div 3| |second permanent div| |previous| |next| when i click on next is should look like this |first permanent div| |div 2| |div 3| |div 4| |second permanent div| |previous| |next| and so on. and when im not div 1,2,3 the previous should be disabled and when im no 7,8,9 the next should be disabled. but i cant make it i'm using this fiddle as a sample http://jsfiddle.net/WGkPV/1/ its working but only one div is shown in the center of my two permanent div which is not in my plan.im getting like this |first permanent div| |div 1| |second permanent div| |previous| |next| any suggestion will be taken seriously. here is the code of the fiddle im working on as tutorial $(document).ready(function () { var divs = $('.mydivs>div'); var now = 0; // currently shown div divs.hide().first().show(); $("button[name=next]").click(function (e) { divs.eq(now).hide(); now = (now + 1 < divs.length) ? now + 1 : 0; divs.eq(now).show(); // show next }); $("button[name=prev]").click(function (e) { divs.eq(now).hide(); now = (now > 0) ? now - 1 : divs.length - 1; divs.eq(now).show(); // or .css('display','block'); //console.log(divs.length, now); }); }); <div class="mydivs"> <div>div 1</div> <div>div 2</div> <div>div 3</div> <div>div 4</div> </div>

    Read the article

  • how do I remove rows/columns from this matrix using python

    - by banditKing
    My matrix looks like this. ['Hotel', ' "excellent"', ' "very good"', ' "average"', ' "poor"', ' "terrible"', ' "cheapest"', ' "rank"', ' "total reviews"'] ['westin', ' 390', ' 291', ' 70', ' 43', ' 19', ' 215', ' 27', ' 813'] ['ramada', ' 136', ' 67', ' 53', ' 30', ' 24', ' 149', ' 49', ' 310 '] ['sutton place', '489', ' 293', ' 106', ' 39', ' 20', ' 299', ' 24', ' 947'] ['loden', ' 681', ' 134', ' 17', ' 5', ' 0', ' 199', ' 4', ' 837'] ['hampton inn downtown', ' 241', ' 166', ' 26', ' 5', ' 1', ' 159', ' 21', ' 439'] ['shangri la', ' 332', ' 45', ' 20', ' 8', ' 2', ' 325', ' 8', ' 407'] ['residence inn marriott', ' 22', ' 15', ' 5', ' 0', ' 0', ' 179', ' 35', ' 42'] ['pan pacific', ' 475', ' 262', ' 86', ' 29', ' 16', ' 249', ' 15', ' 868'] ['sheraton wall center', ' 277', ' 346', ' 150', ' 80', ' 26', ' 249', ' 45', ' 879'] ['westin bayshore', ' 390', ' 291', ' 70', ' 43', ' 19', ' 199', ' 813'] I want to remove the top row and the 0th column from this and create a new matrix. How do I do this? Normally in java or so Id use the following code: for (int y; y< matrix[x].length; y++) for(int x; x < matrix[Y].length; x++) { if(x == 0 || y == 0) { continue } else { new_matrix[x][y] = matrix[x][y]; } } Is there a way such as this in python to iterate and selectively copy elements? Thanks EDIT Im also trying to convert each matrix element from a string to a float as I iterate over the matrix. This my updated modified code based on the answer below. A = [] f = open("csv_test.csv",'rt') try: reader = csv.reader(f) for row in reader: A.append(row) finally: f.close() new_list = [row[1:] for row in A[1:]] l = np.array(new_list) l.astype(np.float32) print l However Im getting an error --> l.astype(np.float32) print l ValueError: setting an array element with a sequence.

    Read the article

  • Is it okay to rely on javascript for menu layout?

    - by Ryan
    I have a website template where I do not know the number of menu items or the size of the menu items that will be required. The js below works exactly the way I want it to, however this is the most js I've every written. Are there any disadvantages or potential problems with this method that I'm not aware of because I'm a js beginner? I'm currently manually setting the padding for each site. Thank you! var width_of_text = 0; var number_of_li = 0; // measure the width of each <li> and add it to the total with, increment li counter $('li').each(function() { width_of_text += $(this).width(); number_of_li++; }); // calculate the space between <li>'s so the space is equal var padding = Math.floor((900 - width_of_text)/(number_of_li - 1)); // add the padding the all but the first <li> $('li').each(function(index) { if (index !== 0) { $(this).css("padding-left", padding); } });

    Read the article

  • INSERT INTO ...SELECT syntax error in join operator

    - by user1477356
    I'm trying to write a shopping basket into a order + orderline in a sql database from C# asp.net. the orderline will contain a ordernumber, total price, productid, quantity etc. for every item in the basket. The order itself will contain the ordernumber as primary key and will be linked to the different lines through it. Everything worked fine yesterday, but now as i tried to use a SELECT command in the insert into statement to get things more dynamic i'm getting the above described syntax error. Does anybody know what's wrong with this statement: INSERT INTO [order] (klant_id,totaalprijs,btw,subtotaal,verzendkosten) SELECT klant.id , SUM(orderregel.totaalprijs) , SUM(orderregel.btw) , SUM(orderregel.totaalprijs) - SUM(orderregel.btw) , 7.50 FROM orderregel INNER JOIN klant ON [order].klant_id = klant.id WHERE klant.username = 'jerry' GROUP BY id; the ordernumber in the "order" table is on autonumber, in the asp codebehind there is a for each which handles the lines being written for every product, there's an index set on 0 outside of this loop and is heightened with 1 every end of it. The executenonquery of the order is only executed once at the beginning of the first loop and the lines are added after with MAX(ordernumber) as ordernumber. I hope i have provided enough information and somebody is capable of helping me. Thanks in advance!

    Read the article

  • Code producing System.NullReferenceException error for Membership.GetUser(). This is VB.Net (ASP.Net 4)

    - by Derrek
    I have a Default.aspx page that is not static. I have added functionality with datalist and sqldatasources. When a user logins he/she will see items like saved workouts, saved equipment, total replys, etc... This is based on getting the currently logged in user UserID. Quite simply this works great when the user is logged in. However, I do not want to force a user to login to view the Default page because it does have functionality on it that does not require login. When a user is not logged in of course I receive the [System.NullReferenceException] error. I understand the error well but I do not know how to code to fix it. That is where I need help. I will admit I am more designer than developer. However, I do know the exception error I am receivving is caused by me not setting a value in my code when a user is not logged in. I do not know how to do that and have for a week made unsuccessful attempts at writing the code. Both sets of code below compile for VB.Net/ASP.Net 4/Visual Studio 2010 without errors. However, I still get the System.NullReferenceException error if not logged in. I know it can be done but I do not know the right syntax. If you can help please insert you code in mine or write it out. JUST TELLING ME WHERE TO GO TO FIND AN ANSWER WON'T HELP. I HAVE DONE THAT FOR 7 STRAIGHT DAYS. I APPRECIATE OUR HELP. Partial Class _Default Inherits System.Web.UI.Page Protected Sub SqlDataSource4_Selecting(ByVal sender As Object, ByVal e As SqlDataSourceCommandEventArgs) Handles SqlDataSource4.Selecting Dim MemUser As MembershipUser MemUser = Membership.GetUser() If Not MemUser Is DBNull.Value Then UserID.Text = MemUser.ProviderUserKey.ToString() e.Command.Parameters("@UserId").Value = MemUser.ProviderUserKey.ToString() End If End Sub -------------------------------------ORIGINAL CODE------------------------------- Partial Class _Default Inherits System.Web.UI.Page Protected Sub SqlDataSource4_Selecting(ByVal sender As Object, ByVal e As SqlDataSourceCommandEventArgs) Handles SqlDataSource4.Selecting Dim MemUser As MembershipUser MemUser = Membership.GetUser() UserID.Text = MemUser.ProviderUserKey.ToString() e.Command.Parameters("@UserId").Value = MemUser.ProviderUserKey.ToString() End Sub

    Read the article

  • Porting VB6 app to VB.Net: Can anyone ballpark how much effort this is?

    - by Robusto
    In 2002 I did a pretty large VB6 app for a client. It used a lot of UserControls and a 3rd party menu control (for putting icons next to menu names). It had dynamically "splittable" panels, TreeViews with multi-state checkboxes, etc. A very rich UI. My total time on the project was about 500 hours, which the client graciously let me spread over a whole month. (Yeah, it was that kind of job.) They were very happy, though, and they paid the bill on time with no argument. So after having no contact with them for years, they suddenly call and wonder if I can update the app to .Net for them. My initial reaction is just to decline, since I don't use VB.Net. And having read a bunch of posts on SO about the difficulties of porting, etc., etc., I'm even more inclined to decline, so to speak. Still, before I tell them no I am interested in roughly quantifying the effort it would take. I would love to hear from anyone who has done this kind of thing and has a feel for how much work it is. Was it: Significantly less than the effort you used on the original? Somewhat less than the effort you used on the original? The same as the effort you used on the original? More? A lot more? Please only respond if you have actually done this kind of port. And the answer doesn't have to be exact, since I really am only trying to ballpark this. My feeling is that the effort will be at least as much as it took for the original, if not more. But I could be wrong. Thanks for any help.

    Read the article

  • Determining Best Table Structure for MySQL Performance

    - by Joe Majewski
    I'm working on a browser-based RPG for one of my websites, and right now I'm trying to determine the best way to organize my SQL tables for performance and maintenance. Here's my question: Does the number of columns in an SQL table affect the speed in which it can be queried? I am not a newbie when it comes to PHP or MySQL. I used to develop things with the common goal of getting them to work, but I've recently advanced to the stage where a functional program is not good enough unless it's fast and reliable. Anyways, right now I have a members table that has around 15 columns. It contains information such as the player's username, password, email, logins, page views, etcetera. It doesn't contain any information on the player's progress in the game, however. If I added columns for things such as army size, gold, turns, and whatnot, then it could easily rise to around 40 or 50 total columns. Oh, and my database structure IS normalized. Will a table with 50 columns that gets constantly queried be a bad idea? Should I split it into two tables; one for the user's general information and one for the user's game statistics? I know I could check the query time myself, but I haven't actually created the tables yet and I think I'd be better off with some professional advice on this important decision for my game. Thank you for your time! :)

    Read the article

  • zipping file problem on the server PHP

    - by Ahmet vardar
    Hi, here is my code; error_reporting(-1); require("zip_min.php"); $f = $_SERVER['DOCUMENT_ROOT'] ."/mp3/allmp3s.zip"; if (!file_exists($f)) { $zipfile = new zipfile(); $folder = $_SERVER['DOCUMENT_ROOT'] ."/mp3; if (is_dir($folder)) { if($dir = opendir ($folder)) { while (false !== ($file = readdir($dir))) { if($file != ".") { if($file != "..") { $zipfile -> addFile(file_get_contents($folder."/".$file), $file); } } } closedir($dir); $contents = $zipfile -> file(); if (file_put_contents($f, $contents)) { print "ok"; } else { print "error creating file"; } } } else { print "error"; } } else { print "file already exists"; } there are 10 mp3 files total size of 100 mb, when i execute this script, i got just a blank page, nothing happens. but with 30-40 mb of size it works great. what should i do ? thanks so much

    Read the article

  • how to get the values dynamically in js

    - by jeessy
    hi having problem with my id iam making my website for health product. already we have a 10 products with corresponding amounts in this section customer choose the product through drop down box. in next we are getting service charges from customer by clicking radio buttons. we have a three radio buttons with name=add and three amount value like 5$ 7$ 9$. It is working fine. for example: customer selected 3 produts in the sense that total amount around 20$ after customer clicks this radio button(any) and submit button that amount will add with totally in next page ie 25$ what i want is that radio button amount should add with get payment then display the page dynamically. function checkRadio (frmName, rbGroupName) { var radios = document[frmName].elements[rbGroupName]; for (var i=0; i < radios.length; i++) { if(radios[i].checked) { return true; } } return false; } $(document).ready(function(){ $("input[name='rmr']").click(function() { updatePayment($(this).val()); if (!!$(this).attr("checked") == true) { $("#finalamount").html( parseInt($("#totalamount").val(), 10) * parseInt($(this).val(), 10)); } }); } this code is right or wrong. thanks in adv

    Read the article

  • How do I form a Rails link_to with custom field value as parameter

    - by rwheadon
    I have an invoice form where I'm giving the user opportunity to apply coupons to the invoice total. These coupons are held in another Model and I am going to do a lookup on the Coupon code (something like "20OFFONFRIDAY") which I will use to find what the restrictions and benefits of the coupon. (and to see if it even exists at all) The invoice does not have "coupon_code" on it so I hand forged the field onto my form with html: <% if (@invoice.status == 'new') %> <input id="coupon_code" name="coupon_code" type="text"/> <% end %> and I am calling a controller method with link_to and would like something like the following jquery enhanced link_to to work: <%= link_to "Apply Coupon", { :controller=>"invoices", :id=>@invoice.id, :coupon_code=>$('.coupon_code').val(), :action=>"apply_coupon_code" }, :method=>"post" %> ^formatted for easier reading Then inside my "apply_coupon_code" method I will go off to a couple other models and perform business logic before returning the updated invoice page. ...but maybe it's a pipe dream. I guess if push came to shove I could add the "coupon_code" field to my invoice model (even though it's persisted elsewhere.) so it's part of the entity and thus easily available on my form to send back into a controller, but I just hate adding a column to make a coupon validation easier. I figured I'd ping stackoverflow before taking that path.

    Read the article

  • How do I simplify my code?

    - by Mitchell Skurnik
    I just finished creating my first major application in C#/Silverlight. In the end the total line count came out to over 12,000 lines of code. Considering this was a rewrite of a php/javascript application I created 2 years that was over 28,000 lines I am actually quite proud of my accomplishment. After reading many questions and answers here on stackoverflow and other sites online, I followed many posters advice: I created classes, procedures, and such for things that I would have a year ago copied and pasted; I created logic charts to figure out complex functions; making sure there are no crazy hidden characters (used tabs instead of spaces); and a few others things; place comments where necessary (I have lots of comments). My application consists of 4 tiles laid out horizontally that have user controls loaded into each slice. You can have between one and four slices loaded at anytime. If you have once slice loaded, the slice takes up the entire artboard...if you have 2 loaded, each take up half, 3 a third, 4 a quarter. Each one of these slices represent (for the sake of this example) a light control. Each slice has 3 slider controls in it. Now when I coded the functionality of the sliders, I used a switch/case statement inside of a public function that would run the command on the specified slice/slider. The made for some duplicate code but I saw no way around it as each slice was named differently. So I would do slice1.my.commands(); slice2.my.commands(); etc. My question to you is how do I clean up my code even futher? (Sadly I cannot post any of my code). Is there any way to take this repetion out of my code?

    Read the article

  • Why doesn't Win Forms application update label immediately?

    - by rosscj2533
    I am doing some experimenting with threads, and made a 'control' method to compare against where all the processing happens in the UI thread. It should run a method, which will update a label at the end. This method runs four times, but the labels are not updated until all 4 have completed. I expected one label to get updated about every 2 seconds. Here's the code: private void button1_Click(object sender, EventArgs e) { Stopwatch watch = new Stopwatch(); watch.Start(); UIThreadMethod(lblOne); UIThreadMethod(lblTwo); UIThreadMethod(lblThree); UIThreadMethod(lblFour); watch.Stop(); lblTotal.Text = "Total Time (ms): " + watch.ElapsedMilliseconds.ToString(); } private void UIThreadMethod(Label label) { Stopwatch watch = new Stopwatch(); watch.Start(); for (int i = 0; i < 10; i++) { Thread.Sleep(200); } watch.Stop(); // this doesn't set text right away label.Text = "Done, Time taken (ms): " + watch.ElapsedMilliseconds; } Maybe I'm just missing something basic, but I'm stuck. Any ideas? Thanks.

    Read the article

  • Displaying count for current_user 'likes' on a 'question' in questions/show.html.erb view

    - by bgadoci
    I have an application that allows for users to create questions, create answers to questions, and 'like' answers of others. When a current_user lands on the /views/questions/show.html.erb page I am trying to display the total 'likes' for all answers on that question, for the current_user. In my Likes table I am collecting the question_id, site_id and the user_id and I have the appropriate associations set up between user, question, answers and likes. I think I just need to call this information the right way, which I can't seem to figure out. All of the below is taking place in the /views/questions/show.html.erb page. I have tried the following: <% div_for current_user do %> You have liked this question <%= @question.likes.count %> times <% end %> Which returns all the 'likes' for the question but not filtered by current_user You have liked this question <%= current_user.question.likes.count %> times Which gives an error of 'undefined method `question' You have liked this question <%= @question.current_user.likes.count %> times Which gives an error of 'undefined method `current_user' I have tried a couple of other things but they don't make as much sense as the above to me. What am I missing?

    Read the article

  • rc.local on ubuntu on ec2 will not work

    - by Tampa
    Below are the contents of my rc.local file. When I run sudo /etc/rc.local it works fine. When I boot up and instance. I expect monit to be installed but it is not. I am at a total loss. I usually use rc.local but this is rather confunsing. #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. apt-get -y install monit /etc/init.d/monit stop cd /home/ubuntu/workspace/rtbopsConfig/ git fetch git checkout origin/master rtb_ec2_boot/ec2_boot.py git checkout origin/master config/ cp /home/ubuntu/workspace/rtbopsConfig/config/monit/redis/monitrc /etc/monit/ /usr/bin/python /home/ubuntu/workspace/rtbopsConfig/rtb_ec2_boot/ec2_boot.py >> /home/ubuntu/workspace/ec2_boot.txt 2>&1 /etc/init.d/monit start chkconfig monit on exit 0

    Read the article

  • WINDOWS: Your computer hangs. You can windows + R (run dialog) but performance is so halted taskMGR

    - by John Sullivan
    The question is, what process are available to try to recover from total system instability before pulling the plug when we can do nothing but programs or batches in the path from the run dialog (windows + r key), and performance is so dead that taskMGR / procEXP / other programs with visual guis are not usable? I am not a windows expert, but ideally someone out there has written a program that does more or less stuff like this: Immediately set (or perhaps I can set from the run prompt) its priority to extremely high, evaluate performance bottlenecks. E.g. is CPU 100%? If so identify offending program(s) or problems. Attempt / log fixes, then provide crude feedback asking the user if his performance has stabilized enough to abort, wait a few seconds, if no feedback continue, etc. etc. Eventually try to do any "system cleanup" if the program decides it cannot recover and perhaps finally provide a series of beeps to the user, or what have you, to say "OK, I give up, time to pull the plug". Ideally create a log, when able. These kinds of horrible hangs are a situation where surely trying something, anything, is better than nothing -- as long as that something is intelligent -- when the alternative is ripping out the power coord. Again, I am not a windows expert, so perhaps there is a much more elegant "hands on" approach I am not aware of.

    Read the article

< Previous Page | 196 197 198 199 200 201 202 203 204 205 206 207  | Next Page >