Search Results

Search found 739 results on 30 pages for 'matthew bloch'.

Page 26/30 | < Previous Page | 22 23 24 25 26 27 28 29 30  | Next Page >

  • sortable list using jquery ui not passing updated list order

    - by Matthew Berman
    I am following the sortable lists railscast and got everything working except when I sort, the same (original) order gets passed to the update method each time, so it doesn't update the true order. Here's the code: In the view: %tbody#lineup{"data-update-url" => sort_lineups_url} - @lineup.pieces.each_with_index do |piece, index| = content_tag_for :tr, piece do = render 'piece', :piece => piece, :index => index and pieces.js.coffee: jQuery -> $('#lineup').sortable( axis: 'y' update: -> $.post($(this).data('update-url'), $(this).sortable('serialize')) ); sort and show methods of lineupscontroller: def show @lineup = Lineup.find_by_user_id(current_user.id) @pieces = @lineup.pieces.order("position") end def sort params[:piece].each_with_index do |id, index| current_user.lineup.pieces.update_all({position: index+1}, {id: id}) end render nothing: true end and the update request: Started POST "/lineups/sort" for 127.0.0.1 at 2012-06-24 20:06:14 -0700 Processing by LineupsController#sort as */* Parameters: {"piece"=>["8", "2", "1", "4", "3", "7"]} User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 LIMIT 1 Lineup Load (0.6ms) SELECT `lineups`.* FROM `lineups` WHERE `lineups`.`user_id` = 2 LIMIT 1 SQL (2.9ms) UPDATE `pieces` INNER JOIN `piece_lineups` ON `pieces`.`id` = `piece_lineups`.`piece_id` SET `position` = 1 WHERE `piece_lineups`.`lineup_id` = 3 AND `pieces`.`id` = 8 SQL (0.6ms) UPDATE `pieces` INNER JOIN `piece_lineups` ON `pieces`.`id` = `piece_lineups`.`piece_id` SET `position` = 2 WHERE `piece_lineups`.`lineup_id` = 3 AND `pieces`.`id` = 2 SQL (0.6ms) UPDATE `pieces` INNER JOIN `piece_lineups` ON `pieces`.`id` = `piece_lineups`.`piece_id` SET `position` = 3 WHERE `piece_lineups`.`lineup_id` = 3 AND `pieces`.`id` = 1 SQL (0.5ms) UPDATE `pieces` INNER JOIN `piece_lineups` ON `pieces`.`id` = `piece_lineups`.`piece_id` SET `position` = 4 WHERE `piece_lineups`.`lineup_id` = 3 AND `pieces`.`id` = 4 SQL (0.6ms) UPDATE `pieces` INNER JOIN `piece_lineups` ON `pieces`.`id` = `piece_lineups`.`piece_id` SET `position` = 5 WHERE `piece_lineups`.`lineup_id` = 3 AND `pieces`.`id` = 3 SQL (0.5ms) UPDATE `pieces` INNER JOIN `piece_lineups` ON `pieces`.`id` = `piece_lineups`.`piece_id` SET `position` = 6 WHERE `piece_lineups`.`lineup_id` = 3 AND `pieces`.`id` = 7 Rendered text template (0.0ms) so each time i drag+drop the list, it sends the same order again. what am I doing wrong that the params isn't passing the right, updated order? Completed 200 OK in 2757ms (Views: 1.0ms | ActiveRecord: 6.7ms)

    Read the article

  • In Java, is there a way to write a string literal without having to escape quotes?

    - by Matthew
    Say you have a String literal with a lot of quotation marks inside it. You could escape them all, but it's a pain, and difficult to read. In some languages, you can just do this: foo = '"Hello, World"'; In Java, however, '' is used for chars, so you can't use it for Strings this way. Some languages have syntax to work around this. For example, in python, you can do this: """A pretty "convenient" string""" Does Java have anything similar?

    Read the article

  • How can Java assignment be made to point to an object instead of making a copy?

    - by Matthew Piziak
    In a class, I have: private Foo bar; public Constructor(Foo bar) { this.bar = bar; } Instead of creating a copy of bar from the object provided in the parameter, is it possible to include a pointer to bar in the constructor such that changing the original bar changes the field in this object? Another way of putting it: int x = 7; int y = x; x = 9; System.out.print(y); //Prints 7. It is possible to set it up so that printing y prints 9 instead of 7?

    Read the article

  • How to take value from radio selection and pass that value into a hidden inputs value attribute?

    - by Matthew
    Hello guys, I need to know if this can be done and if so can someone push me in the right direction. Okay I have a series of radio buttons: <input type="radio" name="level_id" id="radio1" value="XXXX" class="radio1" /> <label for="radio1">choice 1</label> <input type="radio" name="level_id" id="radio2" value="XXXX" class="radio2" /> <label for="radio2">choice 2</label> <input type="radio" name="level_id" id="radio3" value="XXXX" class="radio3" /> <label for="radio3">choice 3</label> <label for="radio4">second choice1</label> <input type="radio" name="level_id" id="radio4" value="1" class="radio4" /> <label for="radio5">second choice2</label> <input type="radio" name="level_id" id="radio5" value="2" class="radio5" /> <label for="radio6">second choice3</label> <input type="radio" name="level_id" id="radio6" value="3" class="radio6" /> Now what I am looking to do is if someone selects CHOICE 1 and then selects SECOND CHOICE1 I would like to pass the value of SECOND CHOICE1 into the value of a hidden input. <input type="hidden" name="sub_source" id="sub_source" value="" /> So that when the form is ready to submit the value that gets passed would be: <input type="hidden" name="sub_source" id="sub_source" value="1" />

    Read the article

  • What would be the best approach to finding a date in a freeform text?

    - by Matthew DeVos
    What would be the best approach to finding a date in a freeform text? A post where a user may place a date in it in several different ways such as: July 14th & 15th 7/14 & 7/15 7-14 & 7-15 Saturday 14th and Sunday 15th Saturday July 14th and 15th and so on. Is regex my best choice for this type of thing with preg_match? I would also like to search if there are two dates, one for a start date and a second for an end date, but in the text I'm searching there may be one date or two. This is my PHP code so far: $dates1 = '01-01'; $dates2 = 'July 14th & 15th'; $dates3 = '7/14 & 7/15'; $dates4 = '7-14 & 7-15'; $dates5 = 'Saturday 14th and Sunday 15th'; $dates6 = 'Saturday July 14th and 15th'; $regexes = array( '/\s(1|2|3|4|5|6|7|8|9|10|11|12)\/\d{1,2}/', //finds a date '/\s(1|2|3|4|5|6|7|8|9|10|11|12)-\d{1,2}/', //finds another date '%\b(0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012])\b%', //finds date format dd-mm or dd.mm ); foreach($regexes as $regex){ preg_match($regex,$dates,$matches); } var_dump($matches);

    Read the article

  • [iPhone] Error reading plist file for fill a table

    - by Matthew
    Hi, I'm developing an app for iPhone but I've a problem... I've a view with some textField and the informations writed in them are saved in a plist file. With @class and #import declarations I import this view controller in another controller that manage a table view. The code I've just wrote appear to be right but my table is filled up with 3 same row... I don't know why the row are 3... Can anyone help me?

    Read the article

  • Add a fadein fade out in jQuery, on multiple conditional statements

    - by Matthew Harwood
    Task: On click of li navigation filter show and hide content with a transitional fadein fade out. Problem I'm just guessing and checking on where to place this fadein//fadeout transition. Furthermore, I feel like my code is too inefficiency because I'm using 4 conditional statements. Would stack lead me in creating a solution to improve the overall logic of this script so I can just make a pretty transition :c? LIVE CODE jQuery Script $(document).ready(function () { //attach a single click listener on li elements $('li.navCenter').on('click', function () { // get the id of the clicked li var id = $(this).attr('id'); // match current id with string check then apply filter if (id == 'printInteract') { //reset all the boxes for muliple clicks $(".box").find('.video, .print, .web').closest('.box').show(); $(".box").find('.web, .video').closest('.box').hide(); $(".box").find('.print').show(); } if (id == 'webInteract') { $(".box").find('.video, .print, .web').closest('.box').show(); $(".box").find('.print, .video').closest('.box').hide(); $(".box").find('.web').show(); } if (id == 'videoInteract') { $(".box").find('.video, .print, .web').closest('.box').show(); $(".box").find('.print, .web').closest('.box').hide() $(".box").find('.video').show(); } if (id == 'allInteract') { $(".box").find('.video, .print, .web').closest('.box').show(); } }); HTML Selected <nav> <ul class="navSpaces"> <li id="allInteract" class="navCenter"> <a id="activeAll" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/logo30px.png" /><h3>all</h3></div></a> </li> <li id="printInteract" class="navCenter"> <a id="activePrint" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/print.gif" /><h3>print</h3></div></a> </li> <li id="videoInteract" class="navCenter"> <a id="activeVideo" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/video.gif" /><h3>video</h3></div></a> </li> <li id="webInteract" class="navCenter"> <a id="activeWeb" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/web.gif" /><h3>web</h3></div></a> </li> </ul> ps. Sorry for the newbie question

    Read the article

  • PHP class extends not working why and is this how to correctly extend a class?

    - by Matthew
    Hi so I'm trying to understand how inherteince works in PHP using object oriented programming. The main class is Computer, the class that is inheriting is Mouse. I'm extedning the Computer class with the mouse class. I use __construct in each class, when I istinate the class I use the pc type first and if it has mouse after. For some reason computer returns null? why is this? class Computer { protected $type = 'null'; public function __construct($type) { $this->type = $type; } public function computertype() { $this->type = strtoupper($this->type); return $this->type; } } class Mouse extends Computer { protected $hasmouse = 'null'; public function __construct($hasmouse){ $this->hasmouse = $hasmouse; } public function computermouse() { if($this->hasmouse == 'Y') { return 'This Computer has a mouse'; } } } $pc = new Computer('PC', 'Y'); echo $pc->computertype; echo $pc->computermouse;

    Read the article

  • Java Socket Closes After Connection?

    - by Matthew
    Why does this port/socket close once a connection has been made by a client? package app; import java.io.*; import java.net.*; public class socketServer { public static void main(String[] args) { int port = 3333; boolean socketBindedToPort = false; try { ServerSocket ServerSocketPort = new ServerSocket(port); System.out.println("SocketServer Set Up on Port: " + port); socketBindedToPort = true; if(socketBindedToPort == true) { Socket clientSocket = null; try { clientSocket = ServerSocketPort.accept();//This method blocks until a socket connection has been made to this port. System.out.println("Waiting for client connection on port:" + port); /** THE CLIENT HAS MADE A CONNECTION **/ System.out.println("CLIENT IS CONENCTED"); } catch (IOException e) { System.out.println("Accept failed: " + port); System.exit(-1); } } else { System.out.println("Socket did not bind to the port:" + port); } } catch(IOException e) { System.out.println("Could not listen on port: " + port); System.exit(-1); } } }

    Read the article

  • c# .net MVC4 Model to represent table or form

    - by Matthew Chambers
    Hello I am a little confused with regards to models in mvc 4 and thought someone may be able to point me in the right direction. This would be most appreciated. For example if i have a table that has the following fields [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 5)] public string UserName { get; set; } [Required(ErrorMessage="Email Address is Required")] [StringLength(15, ErrorMessage = "Email Address must be between {0} and {1} in size",MinimumLength = 5 )] [DataType(DataType.EmailAddress)] [Display(Name="Email")] public string Email { get; set; } [MaxLength(25)] [Display(Name="Mobile Telephone Number")] public string Mobile {get;set;} [MaxLength(500)] [Display(Name="Headline")] public string Headline {get;set;} [Required] [StringLength(200)] [Display(Name = "First Name")] public string FirstName {get;set;} [Required] [StringLength(200)] [Display(Name="Surname")] public string Surname { get; set;} public virtual int? DayOfBirthId { get; set; } public virtual DayOfBirth DayOfBirth { get; set; } public virtual int? MonthOfBirthId { get; set; } public virtual MonthOfBirth MonthOfBirth { get; set; } public virtual int? YearOfBirthId { get; set; } public virtual YearOfBirth YearOfBirth{get;set;} This is my user profile table in the database. However I would like a form that the user registers to the site with. When they first register i do not need all the details such as telephone all i really need is there username, email address and password. Do i create another model for this. Or do i have one model and on the controller set the fields to null or empty string that are not required on registration. I have validation also so would this be set for data that has not been entered on the form. My question is ultimately should all forms represent models- should the database be redesigned to meet this required. Or should the controller set the values that are not required. Or should there be another model that represents the form be created which maps to this table. I am a little confused on this and clarification of anyone would be most appreciated.

    Read the article

  • Why should I install Python packages into `~/.local`?

    - by Matthew Rankin
    Background I don't develop using OS X's system provided Python versions (on OS X 10.6 that's Python 2.5.4 and 2.6.1). I don't install anything in the site-packages directory for the OS provided versions of Python. (The only exception is Mercurial installed from a binary package, which installs two packages in the Python 2.6.1 site-packages directory.) I installed three versions of Python, all using the Mac OS X installer disk image: Python 2.6.6 Python 2.7 Python 3.1.2 I don't like polluting the site-packages directory for my Python installations. So I only install the following five base packages in the site-packages directory. For the actual method/commands used to install these, see SO Question 4324558. setuptools/ez_setup distribute pip virtualenv virtualenvwrapper All other packages are installed in virtualenvs. I am the only user of this MacBook. Questions Given the above background, why should I install the five base packages in ~/.local? Since I'm installing these base packages into the site-packages directories of Python distributions that I've installed, I'm isolated from the OS X's Python distributions. Using this method, should I be concerned about Glyph's comment that other things could potentially break (see his comment below)? Again, I'm only interested in where to install those five base packages. Related Questions/Info I'm asking because of Glyph's comment to my answer to SO question 4314376, which stated: NO. NEVER EVER do sudo python setup.py install whatever. Write a ~/.pydistutils.cfg that puts your pip installation into ~/.local or something. Especially files named ez_setup.py tend to suck down newer versions of things like setuptools and easy_install, which can potentially break other things on your operating system. Previously, I asked What's the proper way to install pip, virtualenv, and distribute for Python?. However, no one answered the "why" of using ~/.local.

    Read the article

  • [JAVA] Activity Stream- Producing X amount of objects in a panel on app load

    - by Matthew De'Loughry
    Hi guys, Just wondering if you could help wanting to produce an activity stream in Java, the idea was to have a JLabel and text area followed by a divider be displayed on a screen and then repeated X amount of times according to what data was in a database. What I was wondering is how could I possibly repeat the placing the jlabel, text area, and diveder on the screen above the last rendered objects on the fly and all displayed correctly no matter the size of the text area of each set of object sort of like the image below. Hope I made it clear as I could thanks

    Read the article

  • Multi-key dictionaries (of another kind) in C#?

    - by Matthew Scharley
    Building on this question, is there a simple solution for having a multi-key dictionary where either key individually can be used to identify the value? ie. MultikeyDictionary<TKey1, TKey2, TValue> foo; foo.Add(key1, key2, value); myValue = foo[key1]; // value == myValue foo.Remove(key2); myValue = foo[key1]; // invalid, Exception or null returned

    Read the article

  • Iterators over a LInked List in a Game in Java

    - by Matthew
    I am using OpenGl in android and they have a callback method called draw that gets called with out my control. (As fast as the device can handle if I am not mistaken) I have a list of "GameObjects" that have a .draw method and a .update method. I have two different threads that handle each of those. So, the question is, can I declare two different iterators in two different methods in two different threads that iterate over the same Linked List? If so, do I simply declare ListIterator<GameObject> l = objets.listIterator() each time I want a new iterator and it won't interfere with other iterators?

    Read the article

  • Why is the page still caching even after the no-cache headers have been sent?

    - by Matthew Grasinger
    I've done a ton of research on this and have asked many people with help and still no success. Here are the details... I'm involved in developing a website that pulls data from various data files, combines them in a temp .csv file, and then is graphed using a popular graphing library: dygraphs. The bulk of the website is written in PHP. The parameters that determine the data that is graphed are stored in the users session, the .csv is named after the users session and available for download, and then the .csv file is written in a script that passes it to the dygraphs object. And we've found, even with the no-cache headers sent: header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); Many users experience in the middle of a session, (if enough different graphs are generated) the page displaying an older, static rendering of the page (data they had graphed earlier in the session) as if it were cached and loaded instead of getting a new request. It only gets weirder though: I've checked using developer tools in both Firefox and Chrome and both browsers are receiving the no-cache headers just fine; Even when the problem occurs if you view the page source, the source is the correct content (a table/legend is also dynamically created using php, the source shows the correct table, but what is rendered is older content); the page begins to render correctly until the graph is about to be display, and then shows the older content; the older content displays as if it were a completely static overlay--the cached graph does not have the same dynamic features (roll over data point display, zoom and pan, etc.) And it is as if the correct page were somewhere beneath it (the download button for the csv file moves depending on how large the table is. The older, static page does nothing if you click the download .csv button, but if you can manage to find the one in the page beneath it you can click and still download the .csv. The data in the .csv is correct) It is one of the strangest things I've seen in development thus far. Some other relevant facts are that all the problems I've personally experience occurred while I was using Chrome. Non of these symptoms have been reported by Firefox users. IE users have had the same problems (IE users are forced to use chrome frame). I'm at my wits end at this point. We've sent the php headers; we've tried setting the cache profile for php on IIS as "DisableCache" (or whatever); we've tried sending a random query string to the results page; we've tried all the appropriate meta tags--all with no success.

    Read the article

  • XmlHttpRequest in a bookmarklet returns empty responseText on GET?

    - by David Eyk
    I'm trying to build a javascript bookmarklet for a special URL shortening service we've built at http://esv.to for shortening scripture references (i.e. "Matthew 5" becomes "http://esv.to/Mt5". The bookmarklet is supposed to do a GET request to http://api.esv.to/Matthew+5, which returns a text/plain response of http://esv.to/Mt5. The code for the bookmarklet itself looks like this (expanded for readability): var body = document.getElementsByTagName('body')[0], script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'http://esv.to/media/js/bookmarklet.js'; body.appendChild(script); void(0); The code from http://esv.to/media/js/bookmarklet.js looks like this: (function() { function shorten(ref, callback) { var url = "http://esv.to/api/" + escape(ref); var req = new XMLHttpRequest(); req.onreadystatechange = function shortenIt() { if ( this.readyState == 4 && this.status == 200 ) { callback(req.responseText); }; }; req.open( "GET", url ); req.send(); }; function doBookmarklet() { var ref = prompt("Enter a scripture reference or keyword search to link to:", "") shorten(ref, function (short) { prompt("Here is your shortened ESV URL:", short); }); }; doBookmarklet(); })(); When called from http://esv.to itself, the bookmarklet works correctly. But when used on another page, it does not. The strange thing is, when I watch the request from Firebug, the response is 200 OK, the browser downloads 17 bytes (the length of the returned string), but the response body is empty! No error is thrown, just an empty responseText on the XmlHttpRequest object. Now, according to http://stackoverflow.com/questions/664689/ajax-call-from-bookmarklet, GET shouldn't violate the same origin policy. Is this a bug? Is there a workaround?

    Read the article

  • Unexpected $end in PHP file

    - by mattbd
    I'm working on a PHP contact form, but I can't get it to work. I get the following error in the Apache server log, running on an Ubuntu Server VM: PHP Parse error: syntax error, unexpected $end in /home/matthew/Sites/contactFormResponse.php on line 75, referer: http://192.168.1.4/contactForm.php From googling this error, it sounds like it's normally caused by either using the short PHP tag when the server's not set up to recognise them, or by having a block of code that isn't closed correctly. But as far as I can see that isn't the case here - as far as I can see it's all closed correctly. Here's the PHP code: <?php error_reporting(E_ALL); // Define variables to hold the name, email address and message, and import the information into the variables $name = $_POST['NameInput']; $email = $_POST['EmailAddress']; $telno = $_POST['ContactNumber']; $querytype = $_POST['QueryType']; $bookingstartdate = $_POST['BookingStartDay'] . $_POST['BookingStartMonth'] . $_POST['BookingStartYear']; $bookingenddate = $_POST['BookingEndDay'] . $_POST['BookingEndMonth'] . $_POST['BookingEndYear']; $message = $_POST['QueryText']; // Validate the inputs - send it if it's OK if(3 < strlen($name) && 3 < strlen($email)) { $email_message = <<< EMAIL Message from contact form at holidaychalet.co.uk Name: $name Email: $email Contact Number: $telno Query Type: $querytype Booking Start Date: $bookingstartdate Booking End Date: $bookingenddate The message: $message EMAIL; $headers = "cc:[email protected]\r\n"; if(mail('matthew@localhost','Contact form email', $email_message, $headers)) { echo "Thanks for completing the form! I'll be in touch shortly!"; } else { echo "Something went wrong - please use the back button and try again"; } } else { echo "You didn't complete the form fully enough! Please use go back using your web browser's back button"; } ?>

    Read the article

  • Is the Scala 2.8 collections library a case of "the longest suicide note in history" ?

    - by oxbow_lakes
    First note the inflammatory subject title is a quotation made about the manifesto of a UK political party in the early 1980s. This question is subjective but it is a genuine question, I've made it CW and I'd like some opinions on the matter. Despite whatever my wife and coworkers keep telling me, I don't think I'm an idiot: I have a good degree in mathematics from the University of Oxford and I've been programming commercially for almost 12 years and in Scala for about a year (also commercially). I have just started to look at the Scala collections library re-implementation which is coming in the imminent 2.8 release. Those familiar with the library from 2.7 will notice that the library, from a usage perspective, has changed little. For example... > List("Paris", "London").map(_.length) res0: List[Int] List(5, 6) ...would work in either versions. The library is eminently useable: in fact it's fantastic. However, those previously unfamiliar with Scala and poking around to get a feel for the language now have to make sense of method signatures like: def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That For such simple functionality, this is a daunting signature and one which I find myself struggling to understand. Not that I think Scala was ever likely to be the next Java (or /C/C++/C#) - I don't believe its creators were aiming it at that market - but I think it is/was certainly feasible for Scala to become the next Ruby or Python (i.e. to gain a significant commercial user-base) Is this going to put people off coming to Scala? Is this going to give Scala a bad name in the commercial world as an academic plaything that only dedicated PhD students can understand? Are CTOs and heads of software going to get scared off? Was the library re-design a sensible idea? If you're using Scala commercially, are you worried about this? Are you planning to adopt 2.8 immediately or wait to see what happens? Steve Yegge once attacked Scala (mistakenly in my opinion) for what he saw as its overcomplicated type-system. I worry that someone is going to have a field day spreading fud with this API (similarly to how Josh Bloch scared the JCP out of adding closures to Java). Note - I should be clear that, whilst I believe that Josh Bloch was influential in the rejection of the BGGA closures proposal, I don't ascribe this to anything other than his honestly-held beliefs that the proposal represented a mistake.

    Read the article

  • How thread-safe is enum in java?

    - by portoalet
    Hi, How thread-safe is enum in java? I am implementing a Singleton using enum (as per Bloch's Effective Java), should I worry at all about thread safety for my singleton enum? Is there a way to prove or disprove that it is thread safe? // Enum singleton - the preferred approach public enum Elvis { INSTANCE; public void leaveTheBuilding() { ... } } Thanks

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30  | Next Page >