Search Results

Search found 345 results on 14 pages for 'rock alternativo'.

Page 12/14 | < Previous Page | 8 9 10 11 12 13 14  | Next Page >

  • Django: Serving Media Behind Custom URL

    - by TheLizardKing
    So I of course know that serving static files through Django will send you straight to hell but I am confused on how to use a custom url to mask the true location of the file using Django. http://stackoverflow.com/questions/2681338/django-serving-a-download-in-a-generic-view but the answer I accepted seems to be the "wrong" way of doing things. urls.py: url(r'^song/(?P<song_id>\d+)/download/$', song_download, name='song_download'), views.py: def song_download(request, song_id): song = Song.objects.get(id=song_id) fsock = open(os.path.join(song.path, song.filename)) response = HttpResponse(fsock, mimetype='audio/mpeg') response['Content-Disposition'] = "attachment; filename=%s - %s.mp3" % (song.artist, song.title) return response This solution works perfectly but not perfectly enough it turns out. How can I avoid having a direct link to the mp3 while still serving through nginx/apache? EDIT 1 - ADDITIONAL INFO Currently I can get my files by using an address such as: http://www.example.com/music/song/1692/download/ But the above mentioned method is the devil's work. How can I accomplished what I get above while still making nginx/apache serve the media? Is this something that should be done at the webserver level? Some crazy mod_rewrite? http://static.example.com/music/Aphex%20Twin%20-%20Richard%20D.%20James%20(V0)/10%20Logon-Rock%20Witch.mp3

    Read the article

  • Capistrano fails for multiple host deployments

    - by morris082
    I be at a loss here, and after scouring the seas (read: internet) for solutions I am left with none other than to hit up the stack. any help appreciated. I have capistrano running locally for deployments onto several different environments. (I'm on windows 7, fwiw). All was well until I needed to deploy to multiple :app servers during a single deployment. Usually I'm prompted for my ssh passphrase once when I call 'cap deploy'. I have ssh-agent running (git never pesters for my pass) but despite this Capistrano has always bugged me once each deployment. Regardless, it always worked when deploying to ONE host. Now, when I attempt to deploy to multiple servers at once, it asks for my passphrase what appears to be multiple times: (ips removed by ME) servers: ["redacted", "redacted"]<br /> Enter passphrase for ~/.ssh/id_rsa: Enter passphrase for ~/.ssh/id_rsa: So with the above I enter my passphrase but this doesn't work. It waits as little while, then spits out this error: connection failed for: <one of the server ips> (NoMethodError: undefined method `overwrite' for nil:NilClass) And that's the end of that. I can "passwordless" ssh into the servers I'm deploying on just fine. I'm pretty certain the ssh-agent is running since I can hit Git w/out entering my passphrase every time Using 'forward_agent' setting in cap deploy did not work. This is my role: role :app, "ip 1 removed", "ip 2 removed" If i set default_run_options[:max_hosts] = 1, it works OK but it asks for my passphrase for every single connection to each host I'm deploying to.. which ends up being a lot. Essentially I'm looking for any of the below (but not limited to): - "You're never going to fix that on windows" - "This is how you get REAL passwordless deployment in capistrano" - "Have you overlooked this setting/feature?" - "I have a rock that can fix anything, you may borrow it" Thanks!

    Read the article

  • Can't return a List from a Compiled Query.

    - by Andrew
    I was speeding up my app by using compiled queries for queries which were getting hit over and over. I tried to implement it like this: Function Select(ByVal fk_id As Integer) As List(SomeEntity) Using db As New DataContext() db.ObjectTrackingEnabled = False Return CompiledSelect(db, fk_id) End Using End Function Shared CompiledSelect As Func(Of DataContext, Integer, List(Of SomeEntity)) = _ CompiledQuery.Compile(Function(db As DataContext, fk_id As Integer) _ (From u In db.SomeEntities _ Where u.SomeLinkedEntity.ID = fk_id _ Select u).ToList()) This did not work and I got this error message: Type : System.ArgumentNullException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Value cannot be null. Parameter name: value However, when I changed my compiled query to return IQueryable instead of List like so: Function Select(ByVal fk_id As Integer) As List(SomeEntity) Using db As New DataContext() db.ObjectTrackingEnabled = False Return CompiledSelect(db, fk_id).ToList() End Using End Function Shared CompiledSelect As Func(Of DataContext, Integer, IQueryable(Of SomeEntity)) = _ CompiledQuery.Compile(Function(db As DataContext, fk_id As Integer) _ From u In db.SomeEntities _ Where u.SomeLinkedEntity.ID = fk_id _ Select u) It worked fine. Can anyone shed any light as to why this is? BTW, compiled queries rock! They sped up my app by a factor of 2.

    Read the article

  • PHP - Best practice to retain form values across postback

    - by Adam
    Hello, Complete PHP novice here, almost all my previous work was in ASP.NET. I am now working on a PHP project, and the first rock I have stumbled upon is retaining values across postback. For the most simple yet still realistic example, i have 10 dropdowns. They are not even databound yet, as that is my next step. They are simple dropdowns. I have my entire page inclosed in a tag. the onclick() event for each dropdown, calls a javascript function that will populate the corrosponding dropdowns hidden element, with the dropdowns selected value. Then, upon page reload, if that hidden value is not empty, i set the selected option = that of my hidden. This works great for a single postback. However, when another dropdown is changed, the original 1'st dropdown loses its value, due to its corrosponding hidden value losing its value as well! This draws me to look into using querystring, or sessions, or... some other idea. Could someone point me in the right direction, as to which option is the best in my situation? I am a PHP novice, however I am being required to do some pretty intense stuff for my skill level, so I need something flexable and preferribly somewhat easy to use. Thanks! -----edit----- A little more clarification on my question :) When i say 'PostBack' I am referring to the page/form being submitted. The control is passed back to the server, and the HTML/PHP code is executed again. As for the dropdowns & hiddens, the reason I used hidden variables to retain the "selected value" or "selected index", is so that when the page is submitted, I am able to redraw the dropdown with the previous selection, instead of defaulting back to the first index. When I use the $_POST[] command, I am unable to retrieve the dropdown by name, but I am able to retrieve the hidden value by name. This is why upon dropdown-changed event, I call javascript which sets the selected value from the dropdown into its corrosponding hidden.

    Read the article

  • Why is Chrome miscalculating jQuery submenu dimensions?

    - by chunkymonkey
    I'm trying to implement this dropdown menu with flyouts: http://jsfiddle.net/chunkymonkey/fr6x4/ In Chrome certain categories can be expanded to show their subcategories while others show nothing when opened up. For example: Alternative Rock can be expanded to show its multiple subcategories . . . BUT . . . World Music, which has as many subcategories, shows no subcategories when expanded. (SCREENSHOT: http://i.imgur.com/0WorR.jpg) I thought I had tracked this problem down to a problem with they way the dimensions of the dropdown elements are calculated in the original code: First change: - var newLeftVal = - ($('.fg-menu-current').parents('ul').size() - 1) * 180; + var newLeftVal = - ($('.fg-menu-current').parents('ul').size() - 1) * container.width(); Second change: Remove: var checkMenuHeight = function(el) { if (el.height() > options.maxHeight) { el.addClass('fg-menu-scroll') }; el.css({ height: options.maxHeight }); }; Add: var checkMenuHeight = function(el) { var max_height = options.maxHeight - breadcrumb.getTotalHeight(); if (el.height() > max_height) { el.addClass('fg-menu-scroll'); el.height(max_height); topList.height(max_height); } else { if (topList.height() < el.height()) { topList.height(el.height()); } } }; But it's still not working only on Chrome (version 8, Windows & Mac) (not sure why Chrome is different).

    Read the article

  • Risking the exception anti-pattern.. with some modifications

    - by Sridhar Iyer
    Lets say that I have a library which runs 24x7 on certain machines. Even if the code is rock solid, a hardware fault can sooner or later trigger an exception. I would like to have some sort of failsafe in position for events like this. One approach would be to write wrapper functions that encapsulate each api a: returnCode=DEFAULT; try { returnCode=libraryAPI1(); } catch(...) { returnCode=BAD; } return returnCode; The caller of the library then restarts the whole thread, reinitializes the module if the returnCode is bad. Things CAN go horribly wrong. E.g. if the try block(or libraryAPI1()) had: func1(); char *x=malloc(1000); func2(); if func2() throws an exception, x will never be freed. On a similar vein, file corruption is a possible outcome. Could you please tell me what other things can possibly go wrong in this scenario?

    Read the article

  • What to do when ServerSocket throws IOException and keeping server running

    - by s5804
    Basically I want to create a rock solid server. while (keepRunning.get()) { try { Socket clientSocket = serverSocket.accept(); ... spawn a new thread to handle the client ... } catch (IOException e) { e.printStackTrace(); // NOW WHAT? } } In the IOException block, what to do? Is the Server socket at fault so it need to be recreated? For example wait a few seconds and then serverSocket = ServerSocketFactory.getDefault().createServerSocket(MY_PORT); However if the server socket is still OK, then it is a pity to close it and kill all previously accepted connections that are still communicating. EDIT: After some answers, here my attempt to deal with the IOException. Would the implementation be guaranteeing keeping the server up and only re-create server socket when only necessary? while (keepRunning.get()) { try { Socket clientSocket = serverSocket.accept(); ... spawn a new thread to handle the client ... bindExceptionCounter = 0; } catch (IOException e) { e.printStackTrace(); recreateServerSocket(); } } private void recreateServerSocket() { while (keepRunning) { try { logger.info("Try to re-create Server Socket"); ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(RateTableServer.RATE_EVENT_SERVER_PORT); // No exception thrown, then use the new socket. serverSocket = socket; break; } catch (BindException e) { logger.info("BindException indicates that the server socket is still good.", e); bindExceptionCounter++; if (bindExceptionCounter < 5) { break; } } catch (IOException e) { logger.warn("Problem to re-create Server Socket", e); e.printStackTrace(); try { Thread.sleep(30000); } catch (InterruptedException ie) { logger.warn(ie); } } } }

    Read the article

  • Android Hero denies XMLSocket or Socket connection? ....errors #2031, #2048

    - by claudi-ursica
    Hi, I am trying to adapt an existing flash web chat application for the Android mobile phone and I am having this really annoying issue. The server is a custom based solution and can send back both binary messages or XML. So I can use either XMLSocket class or the Socket class to get data from the server. Everything works fine when deployed and I connect from the desktop but when I try it from the android mobile I get the infamous errors #2031, followed by #2048. Now the crossdomain.xml file is rock solid and works well for desktop. When the connect socket method runs I see that the server replies with the crossdomain file but I get the error when running on the mobile. Has anyone bumped into this? Is there some limitation from the mobile phone part. I wasn't able to find anything relevant for this issue, in terms of the phone not allowing Socket or XMLSocket connections. The phone(s) Motorola and HTC run Android 2.1 and indicates the flash FL10,1,123,358 version of flash lite. The issue can be reproduced also on the HTC Desire. Any input on this would be highly appreciated... 10x, Claudiu

    Read the article

  • Update SQL Server 2000 to SQL Server 2008: Benefits please?

    - by Ciaran Archer
    Hi there I'm looking for the benefits of upgrading from SQL Server 2000 to 2008. I was wondering: What database features can we leverage with 2008 that we can't now? What new TSQL features can we look forward to using? What performance benefits can we expect to see? What else will make management go for it? And the converse: What problems can we expect to encounter? What other problems have people found when migrating? Why fix something that isn't (technically) broken? We work in a Java shop, so any .NET / CLR stuff won't rock our world. We also use Eclipse as our main development so any integration with Visual Studio won't be a plus. We do use SQL Server Management Studio however. Some background: Our main database machine is a 32bit Dell Intel Xeon MP CPU 2.0GHz, 40MB of RAM with Physical Address Extension running Windows Server 2003 Enterprise Edition. We will not be changing our hardware. Our databases in total are under a TB with some having more than 200 tables. But they are busy and during busy times we see 60-80% CPU utilisation. Apart form the fact that SQL Server 2000 is coming close to end of life, why should we upgrade? Any and all contributions are appreciated!

    Read the article

  • Why is Chrome miscalculating jQuery submenu dimensions?

    - by chunkymonkey
    I'm trying to implement this dropdown menu with flyouts: http://jsfiddle.net/chunkymonkey/fr6x4/ In Chrome certain categories can be expanded to show their subcategories while others show nothing when opened up. For example: Alternative Rock can be expanded to show its multiple subcategories . . . BUT . . . World Music, which has as many subcategories, shows no subcategories when expanded. (SCREENSHOT: http://i.imgur.com/0WorR.jpg) I thought I had tracked this problem down to a problem with they way the dimensions of the dropdown elements are calculated in the original code: First change: - var newLeftVal = - ($('.fg-menu-current').parents('ul').size() - 1) * 180; + var newLeftVal = - ($('.fg-menu-current').parents('ul').size() - 1) * container.width(); Second change: Remove: var checkMenuHeight = function(el) { if (el.height() > options.maxHeight) { el.addClass('fg-menu-scroll') }; el.css({ height: options.maxHeight }); }; Add: var checkMenuHeight = function(el) { var max_height = options.maxHeight - breadcrumb.getTotalHeight(); if (el.height() > max_height) { el.addClass('fg-menu-scroll'); el.height(max_height); topList.height(max_height); } else { if (topList.height() < el.height()) { topList.height(el.height()); } } }; But it's still not working only on Chrome (version 8, Windows & Mac) (not sure why Chrome is different).

    Read the article

  • Multiple use of a form before it is submitted

    - by OregonTrail
    I'm new to JavaScript, and trying to figure out the canonical way to do the following. I have a form with some checkboxes and a selector. Let's say the checkboxes are styles of music and the selector is for people's names. I'd like the user to be able to select the styles of music for each of the people's names and then submit the form with all of the data. For example, the user might first check off Classical, Jazz, Rock, and Pop and choose "Joe", then select Jazz, Pop, Country, and Electronica and choose "Jane". So there would have to be two different buttons for "submit person" and "submit form". I would like to: Have a list of the names and their chosen styles populate below the form, for feedback Allow the user to use the form as much as they want, and then submit all the data at the end I get the feeling that using jquery and JSON is perfect for this, but I'm not sure what search terminology to use to figure out how to do this. If it matters, the form will be processed by a Django view in Python.

    Read the article

  • Drupal 6 - I am using drupal_execute to insert a CCK node into my site. Everything is working excep

    - by rdurbin
    $form_state['values']['field_prx_mp3_labels'][0][value] = $mp3_labels; $form_state['values']['taxonomy'][0][value] = array('tags'=>array('1'=>'Music')); $errs = drupal_execute('prx_content_node_form', $form_state, (object) $nodeTmp); This is a Drupal 6 site. I am using drupal_execute to create a node programatically. The first line is working for field_prx_mp3_labels. The second (for taxonomy) is not. Here is what my select on the node add for my cck looks like: <select name="taxonomy[2][]" multiple="multiple" class="form-select" id="edit-taxonomy-2" size="9"><option value="">- None -</option><option value="5">Music</option><option value="6">-Rock/Pop</option><option value="7">-Jazz/Blues</option><option value="8">-Classical</option><option value="9">-Music Documentaries</option><option value="10">-Festivals/Concerts</option><option value="11">Arts</option><option value="19">-Literature</option><option value="12">Nature</option><option value="13">History</option><option value="15">-Music</option><option value="14">Culture</option><option value="17">-American Indian</option><option value="18">-Latino</option><option value="16">-Youth Perspective</option></select> I have tried many many variations for line 2 (relating to the taxonomy). This comment seemed close but it hasn't worked for me: http://drupal.org/node/178506#comment-1155576 Thanks!

    Read the article

  • Referencing not-yet-defined variables - Java

    - by user2537337
    Because I'm tired of solving math problems, I decided to try something more engaging with my very rusty (and even without the rust, very basic) Java skills. I landed on a super-simple people simulator, and thus far have been having a grand time working through the various steps of getting it to function. Currently, it generates an array of people-class objects and runs a for loop to cycle through a set of actions that alter the relationships between them, which I have stored in a 2d integer array. When it ends, I go look at how much they all hate each other. Fun stuff. Trouble has arisen, however, because I would like the program to clearly print what action is happening when it happens. I thought the best way to do this would be to add a string, description, to my "action" class (which stores variables for the actor, reactor, and the amount the relationship changes). This works to a degree, in that I can print a generic message ("A fight has occurred!") with no problem. However, ideally I would like it to be a little more specific ("Person A has thrown a rock at Person B's head!"). This latter goal is proving more difficult: attempting to construct an action with a description string that references actor and reactor gets me a big old error, "Cannot reference field before it is defined." Which makes perfect sense. I believe I'm not quite in programmer mode, because the only other way I can think to do this is an unwieldy switch statement that negates the need for each action to have its own nicely-packaged description. And there must be a neater way. I am not looking for examples of code, only a push in the direction of the right concept to handle this.

    Read the article

  • Why can't you return a List from a Compiled Query?

    - by Andrew
    I was speeding up my app by using compiled queries for queries which were getting hit over and over. I tried to implement it like this: Function Select(ByVal fk_id As Integer) As List(SomeEntity) Using db As New DataContext() db.ObjectTrackingEnabled = False Return CompiledSelect(db, fk_id) End Using End Function Shared CompiledSelect As Func(Of DataContext, Integer, List(Of SomeEntity)) = _ CompiledQuery.Compile(Function(db As DataContext, fk_id As Integer) _ (From u In db.SomeEntities _ Where u.SomeLinkedEntity.ID = fk_id _ Select u).ToList()) This did not work and I got this error message: Type : System.ArgumentNullException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Value cannot be null. Parameter name: value However, when I changed my compiled query to return IQueryable instead of List like so: Function Select(ByVal fk_id As Integer) As List(SomeEntity) Using db As New DataContext() db.ObjectTrackingEnabled = False Return CompiledSelect(db, fk_id).ToList() End Using End Function Shared CompiledSelect As Func(Of DataContext, Integer, IQueryable(Of SomeEntity)) = _ CompiledQuery.Compile(Function(db As DataContext, fk_id As Integer) _ From u In db.SomeEntities _ Where u.SomeLinkedEntity.ID = fk_id _ Select u) It worked fine. Can anyone shed any light as to why this is? BTW, compiled queries rock! They sped up my app by a factor of 2.

    Read the article

  • How do I create a *public* Facebook community page using the Open Graph protocol?

    - by jmbledsoe
    I am trying to integrate pages from a site I am building into the Facebook Open Graph. My goal is to create a Facebook "Community Page" for each cause in my application. I have added Open Graph tags to a page so that I can Like it in Facebook, and a community page corresponding to my cause has been added to Facebook. However, I am the only one who can see the community page, since I am its administrator. All other users are redirected to the URL of the cause itself. My community page is at: http://www.facebook.com/pages/Kings-Hospital-Garden-Short-Term-Aid/123353527700762 When fans go to this page, I would like them to see the Facebook community page rather than being redirected. In other words, I want my community page to behave like the following community page referenced in all of the Facebook documentation on the subject: http://www.facebook.com/pages/The-Rock/109550739071923 Any insight into this would be greatly appreciated. Also, I asked this same question on the Facebook Platform Developer Forum, but I suspect that the SO community may be more quick to respond.

    Read the article

  • Is there a better loop I could write to reduce database queries?

    - by dmanexe
    Below is some code I've written that is effective, but makes too many database queries. Is there a way I could optimize and reduce the number of queries but have conditional statements still be as effective as below? I pasted the code repeated a few times just for good measure. echo "<h3>Pool Packages</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Pool Packages") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Pool Packages") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Water Features</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Water Features") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Water Features") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Waterfall Rock Work</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE) { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Waterfall Rock Work") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Sheer Descents</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Sheer Descents") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Sheer Descents") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Booster Pump</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Booster Pump") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Booster Pump") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Pool Concrete Decking</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Pool Concrete Decking") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Pool Concrete Decking") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Solar Heating</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Solar Heating") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Solar Heating") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { } endforeach; echo "</ul>"; echo "<h3>Raised Bond Beam</h3>"; echo "<ul>"; foreach ($items as $item): $this->db->where('id', $item['id']); $query = $this->db->get('items')->row(); if ($item['quantity'] > 1 && $item['quantity'] == TRUE && $query->category == "Raised Bond Beam") { $newprice = $item['quantity'] * $query->price; $totals[] = $newprice; } else { $newprice = $query->price; $totals[] = $newprice; } if ($query->category == "Raised Bond Beam") { echo "<li>" . $query->name . " (QTY: " . $item['quantity'] . " x = " . str_ireplace(" ", "", money_format('%(#10n', $newprice)) . ")</li>"; } else { echo "<li>None</li>"; } endforeach; echo "</ul>"; It goes on beyond this to several more categories, but I don't know how to handle looping through this best. Thanks!

    Read the article

  • ASP.NET MVC4: How do I keep from having multiple identical results in my lookup tables

    - by sehummel
    I'm new to ASP.NET so this may be an easy question. I'm seeding my database with several rows of dummy data. Here is one of my rows: new Software { Title = "Microsoft Office", Version = "2012", SerialNumber = "12346231434543", Platform = "PC", Notes = "Macs really rock!", PurchaseDate = "2011-12-04", Suite = true, SubscriptionEndDate = null, SeatCount = 0, SoftwareTypes = new List<SoftwareType> { new SoftwareType { Type="Suite" }}, Locations = new List<Location> { new Location { LocationName = "Paradise" }}, Publishers = new List<SoftwarePublisher> { new SoftwarePublisher { Publisher = "Microsoft" }}} But when I do this, a new row is created for each location, with the LocationName being set in each row like this. We only have two locations. How do I get it to create a LocationID property for the Software class and in my Locations class. Here is my Location class: public class Location { public int Id { get; set; } [Required] [StringLength(20)] public string LocationName { get; set; } public virtual Software Software { get; set; } } I have this line in my Software class to reference this table: public virtual List<Location> Locations { get; set; } Again, what I want when I am done is a Locations table with two entries, and a LocationID field in my Software table. How do I do this?

    Read the article

  • What are the general strategies for the server of an FPS multiplayer game to update its clients?

    - by Hooray Im Helping
    A friend and I were having a discussion about how a FPS server updates the clients connected to it. We watched a video of a guy cheating in Battlefield: Bad Company 2 and saw how it highlighted the position of enemies on the screen and it got us thinking. His contention was that the server only updates the client with information that is immediately relevant to the client. I.e. the server won't send information about enemy players if they are too far away from the client or out of the client's line of sight for reasons of efficiency. He was unsure though - he brought up the example of someone hiding behind a rock, not able to see anyone. If the player were suddenly to pop up where he had three players in his line of sight, there would be a 50ms delay before they were rendered on his screen while the server transmitted the necessary information. My contention was the opposite: that the server sends the client all the information about every player and lets the client sort out what is allowed and what isn't. I figured it would actually be less expensive computationally for the server to just send everything to the client and let the client do the heavy lifting, so to speak. I also figured this is how cheat programs work - they intercept the server packets, get the location of enemies, then show them on the client's view. So the question: What are some general policies or strategies a modern first person shooter server employs to keep its clients updated?

    Read the article

  • Can't add/remove items from a collection while foreach is iterating over it

    - by flockofcode
    If I make my own implementation of IEnumerator interface, then I am able ( inside foreach statement )to add or remove items from a albumsList without generating an exception.But if foreach statement uses IEnumerator supplied by albumsList, then trying to add/delete ( inside the foreach )items from albumsList will result in exception: class Program { static void Main(string[] args) { string[] rockAlbums = { "rock", "roll", "rain dogs" }; ArrayList albumsList = new ArrayList(rockAlbums); AlbumsCollection ac = new AlbumsCollection(albumsList); foreach (string item in ac) { Console.WriteLine(item); albumsList.Remove(item); //works } foreach (string item in albumsList) { albumsList.Remove(item); //exception } } class MyEnumerator : IEnumerator { ArrayList table; int _current = -1; public Object Current { get { return table[_current]; } } public bool MoveNext() { if (_current + 1 < table.Count) { _current++; return true; } else return false; } public void Reset() { _current = -1; } public MyEnumerator(ArrayList albums) { this.table = albums; } } class AlbumsCollection : IEnumerable { public ArrayList albums; public IEnumerator GetEnumerator() { return new MyEnumerator(this.albums); } public AlbumsCollection(ArrayList albums) { this.albums = albums; } } } a) I assume code that throws exception ( when using IEnumerator implementation A supplied by albumsList ) is located inside A? b) If I want to be able to add/remove items from a collection ( while foreach is iterating over it), will I always need to provide my own implementation of IEnumerator interface, or can albumsList be set to allow adding/removing items? thank you

    Read the article

  • Best practice- How to team-split a django project while still allowing code reusal

    - by Infinity
    I know this sounds kind of vague, but please let me explain- I'm starting work on a brand new project, it will have two main components: "ACME PRODUCT" (think Gmail, Meebo, etc), and "THE SITE" (help, information, marketing stuff, promotional landing pages, etc lots of marketing-induced cruft). So basically the url /acme/* will load stuff in the uber cool ajaxy application, and every other URI will load stuff in the other site. Problem: "THE SITE" component is out of my hands, and will be handled by a consultants team that will work closely with marketing, And I and my team will work solely on the ACME PRODUCT. Question: How to set up the django project in such a way that we can have: Seperate releases. (They can push new marketing pages and functionality without having to worry about the state of our code. Maybe even separate Subversion "projects") Minimize impact (on our product) of whatever flying-unicorns-hocus-pocus the other team codes into the site. Still allow some code reusal. My main concern is that the ACME product needs to be rock solid, and therefore needs to be somewhat isolated of whatever mistakes/code bloopers the consultants make in their marketing side of the site. How have you handled this? Any ideas? Thanks!

    Read the article

  • Core Data combined Query

    - by Chris Summer
    Hey, i have question related to CoreData. My iphone project has 2 Entities, Organisation and Brand with a 1 to many "BrandsToOrg" relationship and inverse. So my project has a Mapview, where you can see all the Organisations and a little subview when you click on those Organisations.At the subview there is a "show Brands" Button, which should init a new TableView who only shows the brands belong to the seleceted organisation. Any ideas how i can code that? thx NSPredicate *predicate = [NSPredicate predicateWithFormat: @"(TitleMedium == %@)",@"Rock Antenne"];???? NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:self.entityName inManagedObjectContext:managedObjectContext]; [request setEntity:entity]; // If a predicate was passed, pass it to the query if(predicate != nil) { [request setPredicate:predicate]; } // If a sort key was passed, use it for sorting. NSString *sortKey=@"TitleMedium"; BOOL sortAscending=YES; if(sortKey != nil) { NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:sortKey ascending:sortAscending]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [sortDescriptors release]; [sortDescriptor release]; } NSError *error; NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy]; [request release]; [self setEntityArray:mutableFetchResults];

    Read the article

  • Reliable file copy (move) process - mostly Unix/Linux

    - by mfinni
    Short story : We have a need for a rock-solid reliable file mover process. We have source directories that are often being written to that we need to move files from. The files come in pairs - a big binary, and a small XML index. We get a CTL file that defines these file bundles. There is a process that operates on the files once they are in the destination directory; that gets rid of them when it's done. Would rsync do the best job, or do we need to get more complex? Long story as follows : We have multiple sources to pull from : one set of directories are on a Windows machine (that does have Cygwin and an SSH daemon), and a whole pile of directories are on a set of SFTP servers (Most of these are also Windows.) Our destinations are a list of directories on AIX servers. We used to use a very reliable Perl script on the Windows/Cygwin machine when it was our only source. However, we're working on getting rid of that machine, and there are other sources now, the SFTP servers, that we cannot presently run our own scripts on. For security reasons, we can't run the copy jobs on our AIX servers - they have no access to the source servers. We currently have a homegrown Java program on a Linux machine that uses SFTP to pull from the various new SFTP source directories, copies to a local tmp directory, verifies that everything is present, then copies that to the AIX machines, and then deletes the files from the source. However, we're finding any number of bugs or poorly-handled error checking. None of us are Java experts, so fixing/improving this may be difficult. Concerns for us are: With a remote source (SFTP), will rsync leave alone any file still being written? Some of these files are large. From reading the docs, it seems like rysnc will be very good about not removing the source until the destination is reliably written. Does anyone have experience confirming or disproving this? Additional info We will be concerned about the ingestion process that operates on the files once they are in the destination directory. We don't want it operating on files while we are in the process of copying them; it waits until the small XML index file is present. Our current copy job are supposed to copy the XML file last. Sometimes the network has problems, sometimes the SFTP source servers crap out on us. Sometimes we typo the config files and a destination directory doesn't exist. We never want to lose a file due to this sort of error. We need good logs If you were presented with this, would you just script up some rsync? Or would you build or buy a tool, and if so, what would it be (or what technologies would it use?) I (and others on my team) are decent with Perl.

    Read the article

  • Developer’s Life – Summary of Superhero Articles

    - by Pinal Dave
    Earlier this year, I wrote an article series where I talked about developer’s life and compared it with Superhero. I have got amazing response to this series and I have been receiving quite a lots of email suggesting that I should write more blog post about them. Currently I am not planning to write more blog post but I will soon continue another series. In this blog post, I have summarized the entire series. Let me know if you want me to write about any superhero. I will see what I can do about that hero. Developer’s Life – Every Developer is a Captain America Captain America was first created as a comic book character in the 1940’s as a way to boost morale during World War II.  Aimed at a children’s audience, his legacy faded away when the war ended.  However, he has recently has a major reboot to become a popular movie character that deals with modern issues. Developer’s Life – Every Developer is the Incredible Hulk The Incredible Hulk is possibly one of the scariest superheroes out there.  All superheroes are meant to be “out of this world” and awe-inspiring, but I think most people will agree with I say The Hulk takes this to the next level.  He is the result of an industrial accident, which is scary enough in it’s own right.  Plus, when mild-mannered Bruce Banner is angered, he goes completely out-of-control and transforms into a destructive monster that he cannot control and has no memories of. Developer’s Life – Every Developer is a Wonder Woman We have focused a lot lately on this “superhero series.”  I love fantasy books and movies, and I feel like there is a lot to be learned from them.  As I am writing this series, though, I have noticed that every super hero I write about is a man.  So today, I would like to talk about the major female super hero – Wonder Woman. Developer’s Life – Every Developer is a Harry Potter Harry Potter might not be a superhero in the traditional sense, but I believe he still has a lot to teach us and show us about life as a developer.  If you have been living under a rock for the last 17 years, you might not know that Harry Potter is the main character in an extremely popular series of books and movies documenting the education and tribulation of a young wizard (and his friends). Developer’s Life – Every Developer is Like Transformers Transformers may not be superheroes – they don’t wear capes, they don’t have amazing powers outside of their size and folding ability, they’re not even human (technically).  Part of their enduring popularity is that while we are enjoying over-the-top movies, we are learning about good leadership and strong personal skills. Developer’s Life – Every Developer is a Iron Man Iron Man is another superhero who is not naturally “super,” but relies on his brain (and money) to turn him into a fighting machine.  While traditional superheroes are still popular, a three-movie franchise and incorporation into the new Avengers series shows that Iron Man is popular enough on his own. Developer’s Life – Every Developer is a Sherlock Holmes I have been thinking a lot about how developers are like super heroes, and I have written two blog posts now comparing them to Spiderman and Superman.  I have a lot of love and respect for developers, and I hope that they are enjoying these articles, and others are learning a little bit about the profession.  There is another fictional character who, while not technically asuper hero, is very powerful, and I also think stands as a good example of a developer. That character is Sherlock Holmes.  Sherlock Holmes is a British detective, first made popular at the turn of the 19thcentury by author Sir Arthur Conan Doyle.  The original Sherlock Holmes was a brilliant detective who could solve the most mind-boggling crime through simple observations and deduction. Developer’s Life – Every Developer is a Chhota Bheem Chhota Bheem is a cartoon character that is extremely popular where I live.  He is my daughter’s favorite characters.  I like to say that children love Chhota Bheem more than their parents – it is lucky for us he is not real!  Children love Chhota Bheem because he is the absolute “good guy.”  He is smart, loyal, and strong.  He and his friends live in Dholakpur and fight off their many enemies – and always win – in every episode.  In each episode, they learn something about friendship, bravery, and being kind to others.  Chhota Bheem is a good role model for children, and I think that he is a good role model for developers are well. Developer’s Life – Every Developer is a Batman Batman is one of the darkest superheroes in the fantasy canon.  He does not come to his powers through any sort of magical coincidence or radioactive insect, but through a lot of psychological scarring caused by witnessing the death of his parents.  Despite his dark back story, he possesses a lot of admirable abilities that I feel bear comparison to developers. Developer’s Life – Every Developer is a Superman I enjoyed comparing developers to Spiderman so much, that I have decided to continue the trend and encourage some of my favorite people (developers) with another favorite superhero – Superman.  Superman is probably the most famous superhero – and one of the most inspiring. Developer’s Life – Every Developer is a Spiderman I have to admit, Spiderman is my favorite superhero.  The most recent movie recently was released in theaters, so it has been at the front of my mind for some time. Spiderman was my favorite superhero even before the latest movie came out, but of course I took my whole family to see the movie as soon as I could!  Every one of us loved it, including my daughter.  We all left the movie thinking how great it would be to be Spiderman.  So, with that in mind, I started thinking about how we are like Spiderman in our everyday lives, especially developers. I would like to know which Superhero is your favorite hero! Reference: Pinal Dave (http://blog.SQLAuthority.com)Filed under: PostADay, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, T SQL Tagged: Developer, Superhero

    Read the article

  • XNA Notes 006

    - by George Clingerman
    If you used to think the XNA community was small and inactive, hopefully these XNA Notes are opening your eyes. And I honestly feel like I’m still only catching the tail end of everything that’s going on. It’s a large and active community and you can be so mired down in one part of it you miss all sorts of cool stuff another part is doing. XNA is many things to a lot of people and that makes for a lot of really awesome things going on. So here’s what I saw going on this last week! Time Critical XNA New: XNA Team - Peer Review now closes for XNA 3.1 games http://blogs.msdn.com/b/xna/archive/2011/02/08/peer-review-pipeline-closed-for-new-xna-gs-3-1-games-or-updates-on-app-hub.aspx http://twitter.com/XNACommunity/statuses/34649816529256448 The XNA Team posts about a meet up with Microsoft for Creator’s going to be at GDC, March 3rd at the Lobby Bar http://on.fb.me/fZungJ XNA Team: @mklucher is busying playing the the bubblegum on WP7 made by a member of the XNA team (although reportedly made in Silverlight? Crazy! ;) ) http://twitter.com/mklucher/statuses/34645662737895426 http://bubblegum.me Shawn Hargreaves posts multiple posts (is this a sign that something new is coming from the XNA team? Usually when Shawn has time to post, something has just wrapped up…) Random Shuffle http://blogs.msdn.com/b/shawnhar/archive/2011/02/09/random-shuffle.aspx Doing the right thing: resume, rewind or skip ahead http://blogs.msdn.com/b/shawnhar/archive/2011/02/10/doing-the-right-thing-resume-rewind-or-skip-ahead.aspx XNA Developers: Andrew Russel was on .NET Rocks recently talking with Carl and Richard about developing games for Xbox, iPhone and Android http://www.dotnetrocks.com/default.aspx?ShowNum=635 Eric W. releases the Fishing Girl source code into the wild http://ericw.ca/blog/posts/fishing-girl-now-open-source/ http://forums.create.msdn.com/forums/p/74642/454512.aspx#454512 BinaryTweedDeej reminds that XNA community that Indie City wants you involved http://twitter.com/BinaryTweedDeej/statuses/34596114028044288 http://www.indiecity.com Mike McLaughlin (@mikebmcl) releases his first two XNA articles on the TechNet wiki http://social.technet.microsoft.com/wiki/contents/articles/xna-framework-overview.aspx http://social.technet.microsoft.com/wiki/contents/articles/content-pipeline-overview.aspx John Watte plays around with the Content Pipeline and Music Visualization exploring just what can be done. http://www.enchantedage.com/xna-content-pipeline-fft-song-analysis http://www.enchantedage.com/fft-in-xna-content-pipeline-for-beat-detection-for-the-win Simon Stevens writes up his talk on Vector Collision Physics http://www.simonpstevens.com/News/VectorCollisionPhysics @domipheus puts together an XNA Task Manager http://www.flickr.com/photos/domipheus/5405603197/ MadNinjaSkillz releases his fork of Nick's Easy Storage component on CodePlex http://twitter.com/MadNinjaSkillz/statuses/34739039068229634 http://ezstorage.codeplex.com @ActiveNick was interviewed by Rob Cameron and discusses Windows Phone 7, Bing Maps and XNA http://twitter.com/ActiveNick/statuses/35348548526546944 http://msdn.microsoft.com/en-us/cc537546 Radiangames (Luke Schneider) posts about converting his games from XNA to Unity http://radiangames.com/?p=592 UberMonkey (@ElementCy) posts about a new project in the works, CubeTest a Minecraft style terrain http://www.ubergamermonkey.com/personal-projects/new-project-in-the-works/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Ubergamermonkey+%28UberGamerMonkey%29 Xbox LIVE Indie Games (XBLIG): VideoGamer Rob review Bonded Realities http://videogamerrob.wordpress.com/2011/02/05/xblig-review-bonded-realities/ XBLIG Round Up on Gamergeddon http://www.gamergeddon.com/2011/02/06/xbox-indie-game-round-up-february-6th/ Are gamers still rating Indie Games after the Xbox Dashboard update? http://www.gamemarx.com/news/2011/02/06/are-gamers-still-rating-indie-games-after-the-xbox-dashboard-update.aspx Joystiq - Xbox Live Indie Gems: Corrupted http://www.joystiq.com/2011/02/04/xbox-live-indie-gems-corrupted/ Raymond Matthews of DarkStarMatryx reviews (Almost) Total Mayhem and Aban Hawkins & the 1000 Spikes http://www.darkstarmatryx.com/?p=225 http://www.darkstarmatryx.com/?p=229 8 Bit Horse reviews Aban Hawkins & the 1000 spikes http://8bithorse.blogspot.com/2011/01/aban-hawkins-1000-spikes-xbl-indie.html 2010 wrap-up for FunInfused Games http://www.krissteele.net/blogdetails.aspx?id=245 NeoGaf roundup of January's XBLIGs http://www.neogaf.com/forum/showthread.php?t=420528 Armless Ocotopus interviews Michael Ventnor creator of Bonded Realities http://www.armlessoctopus.com/2011/02/07/interview-michael-ventnor-of-red-crest-studios/ @recharge_media posts about the new city music for Woodvale in Sin Rising http://rechargemedia.com/2011/02/08/new-city-theme-woodvale/ @DrMisty posts some footage of YoYoYo in action http://www.mstargames.co.uk/mistryblogmain/54-yoyoyoblogs/184-video-update.html Xona Games - Decimation X3 on Reviews on the Run http://video.citytv.com/video/detail/782443063001.000000/reviews-on-the-run--february-8-2011/g4/ @benkane gives an early peek at his action RPG coming to XBLIG http://www.youtube.com/watch?v=bDF_PrvtwU8 Rock, Paper Shotgun talks to Zeboyd games about bringing Cthulhu Saves the World to PC http://www.rockpapershotgun.com/2011/02/11/summoning-cthulhu-natter-with-zeboyd/ Xbox LIVE Indieverse interviews the creator of Bonded Realities http://xbl-indieverse.blogspot.com/2011/02/xbl-indieverse-interview-red-crest.html XNA Game Development: Dream-In-Code posts about an upcoming XNA Challenge/Coding contest http://www.dreamincode.net/forums/blog/1385/entry-3192-xna-challengecontest/ Sgt.Conker covers Fishing Girl and IndieFreaks Game Framework release http://www.sgtconker.com/2011/02/fishing-girl-did-not-sell-a-single-copy/ http://www.sgtconker.com/2011/02/indiefreaks-game-framework-v0-2-0-0/ @slyprid releases Transmute v0.40a with lots of new features and fixes http://twitter.com/slyprid/statuses/34125423067533312 http://twitter.com/slyprid/statuses/35326876243337216 http://forgottenstarstudios.com/ Jeff Brown writes an XNA 4.0 tutorial on Saving/Loading on the Xbox 360 http://www.robotfootgames.com/xna-tutorials/92-xna-tutorial-savingloading-on-xbox-360-40 XNA for Silverlight Developers: Part 3- Animation http://www.silverlightshow.net/items/XNA-for-Silverlight-developers-Part-3-Animation-transforms.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+xna-connection-twitter-specific-stream+%28XNA+Connection%27s+Twitter+specific+stream%29 The news from Nokia is definitely something XNA developers will want to keep their eye on http://blogs.forum.nokia.com/blog/nokia-developer-news/2011/02/11/letter-to-developers?sf1066337=1

    Read the article

  • Using the “Settings.settings” functionalities in VB.NET can be tricky…

    - by Vincent Grondin
    Sometime you’re searching for something forever and when you find it, you realize it was right under your nose.  Maybe you were distracted by other things around… or maybe that thing right under your nose was so well hidden that it deserves a blog post…   That happened to me a few days ago while using the “Settings.settings” functionalities in my VB.NET application…  I thought it was a cool feature and I decided to use it…  So there I am adding new settings with “USER” scope and StringCollection as the data type, testing my application and everything works perfectly fine...  That was before I decided to modify the “Value” of one of my settings…  After changing the value of one of my settings, I start my application again and, to my surprise, my new values aren’t showing!  Hmmm… That’s odd…  My setting was a pretty long list of strings so I was rather angry at myself for not saving my work after I was done…  So I open up the Settings.setting in the designer and click the ellipsis symbol to enter my string collection again, but to my great pleasure (and disbelief) my strings are there!!!  Alright, you rock VB.NET!  You’ve just save me a bunch of typing time and I’m thinking it’s just a simple Visual Studio glitch…  I hit “Save” then “Save All” (just in case) and finally I rebuild everything and fire up my app once again.  Huh?  Where are my darn strings????????  Ok there’s a bug there…  I open up the app.config and my new strings are there!!!  Alright, let’s recap…  My new strings are in the app.config, they show correctly in the Settings.settings designer UI but they aren’t showing at runtime…  Hmmmm?  Let’s try something else…  Let’s start the application but outside Visual Studio this time… I fire up the exe and BAM!  My strings where there!  I “alt-tab” and hit “F5” and BOOM, no strings!  So it’s a bug in the Visual Studio environment… or could it be a FEATURE?  I must admit that I’m a little confused over what’s a bug and what’s a feature in Visual Studio… lol!   Finally I found out there’s a “cache” for your Visual Studio located here:  C:\Users\<your username>\AppData\Local\Microsoft\<your app name and a very weird temp ID>\<your app version>\user.config When using the “Settings.settings” with a setting of scope “user”, this file is out of sync with your app.config until you manually decide to update it… The button is right there… under your nose… at the top left corner of your screen in the settings designer…  See the big “Synchronize” button there?  Yep…  Now that’s user friendly isn’t it?  Oh, and wait until you see what it does when you click it…  It prompts you and basically says:  “Would you like your settings to start working inside Visual Studio now that you found out that I exist?” and of course the right answer is yes… or rather “OK”…  Unfortunately, you have to do this every time you edit a value… On the other hand, adding and removing settings seem to work flawlessly without having to click this magical button… go figure!  Oh and I almost forgot… this great “feature” is only available for VB.NET…  A project in C# using Settings.settings will work perfectly EVEN when editing values… Here’s a screenshot that shows this important button: Button Using other data types appears to work perfectly well…   Maybe it’s simply related to the StringCollection data type?  If you are a VB.NET programmer, you should pay attention to this when you plan on using the settings functionalities and your scope is “user” and your data type is StringCollection… Happy coding all!

    Read the article

< Previous Page | 8 9 10 11 12 13 14  | Next Page >