Search Results

Search found 440 results on 18 pages for 'spike williams'.

Page 8/18 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Problem with jQuery.ajax with 'delete' method in ie

    - by Max Williams
    I have a page where the user can edit various content using buttons and selects that trigger ajax calls. In particular, one action causes a url to be called remotely, with some data and a 'put' request, which (as i'm using a restful rails backend) triggers my update action. I also have a delete button which calls the same url but with a 'delete' request. The 'update' ajax call works in all browsers but the 'delete' one doesn't work in IE. I've got a vague memory of encountering something like this before...can anyone shed any light? here's my ajax calls: //update action - works in all browsers jQuery.ajax({ async:true, data:data, dataType:'script', type:'put', url:"/quizzes/"+quizId+"/quiz_questions/"+quizQuestionId, success: function(msg){ initializeQuizQuestions(); setPublishButtonStatus(); } }); //delete action - fails in ie function deleteQuizQuestion(quizQuestionId, quizId){ //send ajax call to back end to change the difficulty of the quiz question //back end will then refresh the relevant parts of the page (progress bars, flashes, quiz status) jQuery.ajax({ async:true, dataType:'script', type:'delete', url:"/quizzes/"+quizId+"/quiz_questions/"+quizQuestionId, success: function(msg){ alert("success"); initializeQuizQuestions(); setSelectStatus(quizQuestionId, true); jQuery("tr[id*='quiz_question_"+quizQuestionId+"']").removeClass('selected'); }, error: function(msg){ alert("error:" + msg); } }); } I put the alerts in success and error in the delete ajax just to see what happens, and the 'error' part of the ajax call is triggered, but WITH NO CALL BEING MADE TO THE BACK END (i know this by watching my back end server logs). So, it fails before it even makes the call. I can't work out why - the 'msg' i get back from the error block is blank. Any ideas anyone? Is this a known problem? I've tested it in ie6 and ie8 and it doesn't work in either. thanks - max EDIT - the solution - thanks to Nick Craver for pointing me in the right direction. Rails (and maybe other frameworks?) has a subterfuge for the unsupported put and delete requests: a post request with the parameter "_method" (note the underscore) set to 'put' or 'delete' will be treated as if the actual request type was that string. So, in my case, i made this change - note the 'data' option': jQuery.ajax({ async:true, data: {"_method":"delete"}, dataType:'script', type:'post', url:"/quizzes/"+quizId+"/quiz_questions/"+quizQuestionId, success: function(msg){ alert("success"); initializeQuizQuestions(); setSelectStatus(quizQuestionId, true); jQuery("tr[id*='quiz_question_"+quizQuestionId+"']").removeClass('selected'); }, error: function(msg){ alert("error:" + msg); } }); } Rails will now treat this as if it were a delete request, preserving the REST system. The reason my PUT example worked was just because in this particular case IE was happy to send a PUT request, but it officially does not support them so it's best to do this for PUT requests as well as DELETE requests.

    Read the article

  • jQuery "Autocomplete" plugin is messing up the order of my data

    - by Max Williams
    I'm using Jorn Zaefferer's Autocomplete plugin on a couple of different pages. In both instances, the order of displayed strings is a little bit messed up. Example 1: array of strings: basically they are in alphabetical order except for General Knowledge which has been pushed to the top: General Knowledge,Art and Design,Business Studies,Citizenship,Design and Technology,English,Geography,History,ICT,Mathematics,MFL French,MFL German,MFL Spanish,Music,Physical Education,PSHE,Religious Education,Science,Something Else Displayed strings: General Knowledge,Geography,Art and Design,Business Studies,Citizenship,Design and Technology,English,History,ICT,Mathematics,MFL French,MFL German,MFL Spanish,Music,Physical Education,PSHE,Religious Education,Science,Something Else Note that Geography has been pushed to be the second item, after General Knowledge. The rest are all fine. Example 2: array of strings: as above but with Cross-curricular instead of General Knowledge. Cross-curricular,Art and Design,Business Studies,Citizenship,Design and Technology,English,Geography,History,ICT,Mathematics,MFL French,MFL German,MFL Spanish,Music,Physical Education,PSHE,Religious Education,Science,Something Else Displayed strings: Cross-curricular,Citizenship,Art and Design,Business Studies,Design and Technology,English,Geography,History,ICT,Mathematics,MFL French,MFL German,MFL Spanish,Music,Physical Education,PSHE,Religious Education,Science,Something Else Here, Citizenship has been pushed to the number 2 position. I've experimented a little, and it seems like there's a bug saying "put things that start with the same letter as the first item after the first item and leave the rest alone". Kind of mystifying. I've tried a bit of debugging by triggering alerts inside the autocomplete plugin code but everywhere i can see, it's using the correct order. it seems to be just when its rendered out that it goes wrong. Any ideas anyone? max EDIT - reply to Clint Thanks for pointing me at the relevant bit of code btw. To make diagnosis simpler i changed the array of values to ["carrot", "apple", "cherry"], which autocomplete re-orders to ["carrot", "cherry", "apple"]. Here's the array that it generates for stMatchSets: stMatchSets = ({'':[#1={value:"carrot", data:["carrot"], result:"carrot"}, #3={value:"apple", data:["apple"], result:"apple"}, #2={value:"cherry", data:["cherry"], result:"cherry"}], c:[#1#, #2#], a:[#3#]}) So, it's collecting the first letters together into a map, which makes sense as a first-pass matching strategy. What i'd like it to do though, is to use the given array of values, rather than the map, when it comes to populating the displayed list. I can't quite get my head around what's going on with the cache inside the guts of the code (i'm not very experienced with javascript).

    Read the article

  • C - equivalent of .NET Console.ReadLine

    - by John Williams
    I need to accomplish the same behavior as .NET Console.ReadLine function provides. The program execution should continue when the user pushes enter key. The following code is not sufficient, as it requires additional input: printf ("Press Enter to continue"); scanf ("%s",str); Any suggestions?

    Read the article

  • MacRuby - CLLocation Properties Not Accessible

    - by Craig Williams
    Anyone know why this works in Objective-C but not in MacRuby? Objective-C Version: CLLocation *loc = [[CLLocation alloc] initWithLatitude:38.0 longitude:-122.0]; NSLog(@"Lat: %.2f", loc.coordinate.latitude); NSLog(@"Long: %.2f", loc.coordinate.longitude); [loc release]; // Results: // 2010-04-30 16:48:55.568 OCCoreLocationTest[70030:a0f] Lat: 38.00 // 2010-04-30 16:48:55.570 OCCoreLocationTest[70030:a0f] Long: -122.00 Here is the MacRuby version with results: loc = CLLocation.alloc.initWithLatitude(38.0, longitude:-122.0) puts loc.class # => CLLocation puts loc.description # => <+38.00000000, -122.00000000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2010-04-30 16:37:47 -0600 puts loc.respond_to?(:coordinate) # => true puts loc.coordinate.latitude # => Error: unrecognized runtime type `{?=dd}' (TypeError)

    Read the article

  • mysql query execution time - can i get this in milliseconds?

    - by Max Williams
    I'm comparing a few different approaches to getting some data in mysql, directly at the console, using the SQL_NO_CACHE option to make sure mysql keeps running the full query every time. Mysql gives me the execution time back in seconds, to two decimal places. I'd really like to get the result back in milliseconds (ideally to one or two decimal places), to get a better idea of improvements (or lack of). Is there an option i can set in mysql to achieve this? thanks, max

    Read the article

  • JS sort works in Firefox but not IE - can't work out why

    - by Max Williams
    I have a line in a javascript function that sort an array of objects based on the order of another array of strings. This is working in firefox but not in IE and i don't know why. Here's what my data looks like going into the sort call. (I'm using an array of three items just to illustrate the point here). //cherry first then the rest in alphabetical order originalData = ['cherry','apple','banana','clementine','nectarine','plum'] //data before sorting - note how clementine is second item - we wan to to to be after apple and banana csub = [ {"value":"cherry","data":["cherry"],"result":"cherry"}, {"value":"clementine","data":["clementine"],"result":"clementine"}, {"value":"apple","data":["apple"],"result":"apple"}, {"value":"banana","data":["banana"],"result":"banana"}, {"value":"nectarine","data":["nectarine"],"result":"nectarine"}, {"value":"plum","data":["plum"],"result":"plum"} ] //after sorting, csub has been rearranged but still isn't right: clementine is before banana csubSorted = [ {"value":"cherry","data":["cherry"],"result":"cherry"}, {"value":"apple","data":["apple"],"result":"apple"}, {"value":"clementine","data":["clementine"],"result":"clementine"}, {"value":"banana","data":["banana"],"result":"banana"}, {"value":"nectarine","data":["nectarine"],"result":"nectarine"}, {"value":"plum","data":["plum"],"result":"plum"} ] Here's the actual sort code: csubSorted = csub.sort(function(a,b){ return (originalData.indexOf(a.value) > originalData.indexOf(b.value)); }); Can anyone see why this wouldn't work? Is the basic javascript sort function not cross-browser compatible? Can i do this a different way (eg with jquery) that would be cross-browser? grateful for any advice - max

    Read the article

  • What is the best way to merge mp3 files?

    - by Dan Williams
    I've got many, many mp3 files that I would like to merge into a single file. I've used the command line method copy /b 1.mp3+2.mp3 3.mp3 but it's a pain when there's a lot of them and their namings are inconsistent. The time never seems to come out right either.

    Read the article

  • Forcing a transaction to rollback on validation errors in Seam

    - by Chris Williams
    Quick version: We're looking for a way to force a transaction to rollback when specific situations occur during the execution of a method on a backing bean but we'd like the rollback to happen without having to show the user a generic 500 error page. Instead, we'd like the user to see the form she just submitted and a FacesMessage that indicates what the problem was. Long version: We've got a few backing beans that use components to perform a few related operations in the database (using JPA/Hibernate). During the process, an error can occur after some of the database operations have happened. This could be for a few different reasons but for this question, let's assume there's been a validation error that is detected after some DB writes have happened that weren't detectible before the writes occurred. When this happens, we'd like to make sure all of the db changes up to this point will be rolled back. Seam can deal with this because if you throw a RuntimeException out of the current FacesRequest, Seam will rollback the current transaction. The problem with this is that the user is shown a generic error page. In our case, we'd actually like the user to be shown the page she was on with a descriptive message about what went wrong, and have the opportunity to correct the bad input that caused the problem. The solution we've come up with is to throw an Exception from the component that discovers the validation problem with the annotation: @ApplicationException( rollback = true ) Then our backing bean can catch this exception, assume the component that threw it has published the appropriate FacesMessage, and simply return null to take the user back to the input page with the error displayed. The ApplicationException annotation tells Seam to rollback the transaction and we're not showing the user a generic error page. This worked well for the first place we used it that happened to only be doing inserts. The second place we tried to use it, we have to delete something during the process. In this second case, everything works if there's no validation error. If a validation error does happen, the rollback Exception is thrown and the transaction is marked for rollback. Even if no database modifications have happened to be rolled back, when the user fixes the bad data and re-submits the page, we're getting: java.lang.IllegalArgumentException: Removing a detached instance The detached instance is lazily loaded from another object (there's a many to one relationship). That parent object is loaded when the backing bean is instantiated. Because the transaction was rolled back after the validation error, the object is now detached. Our next step was to change this page from conversation scope to page scope. When we did this, Seam can't even render the page after the validation error because our page has to hit the DB to render and the transaction has been marked for rollback. So my question is: how are other people dealing with handling errors cleanly and properly managing transactions at the same time? Better yet, I'd love to be able to use everything we have now if someone can spot something I'm doing wrong that would be relatively easy to fix. I've read the Seam Framework article on Unified error page and exception handling but this is geared more towards more generic errors your application might encounter.

    Read the article

  • Clojure / HBase: How to Import HBaseTestingUtility in v0.94.6.1

    - by David Williams
    In Clojure, if I want to start a test cluster using the hbase testing utility, I have to annotate my dependencies with: [org.apache.hbase/hbase "0.92.2" :classifier "tests" :scope "test"] First of all, I have no idea what this means. According to leiningens sample project.clj ;; Dependencies are listed as [group-id/name version]; in addition ;; to keywords supported by Pomegranate, you can use :native-prefix ;; to specify a prefix. This prefix is used to extract natives in ;; jars that don't adhere to the default "<os>/<arch>/" layout that ;; Leiningen expects. Question 1: What does that mean? Question 2: If I upgrade the version: [org.apache.hbase/hbase "0.94.6.1" :classifier "tests" :scope "test"] Then I receive a ClassNotFoundException Exception in thread "main" java.lang.ClassNotFoundException: org.apache.hadoop.hbase.HBaseConfiguration Whats going on here and how do I fix it?

    Read the article

  • Can managed and unmanaged C++/MFC be mixed in one dll?

    - by Walter Williams
    Previously we had software in MFC (VC6), VB6 and C# applications that needed to call the same engine written in C++ (and MFC). The engine required C++ for speed. At the time we decided to use COM as the interface because all three could use it with the least issues in marshalling, etc. Our MFC application is now deprecated and we have recently decided to dump VB6, so what we've got left is C#. We can just leave the COM engine as-is, but it would be nice to get away from COM registration, etc., and have a managed interface to work with. COM registration occasionally causes support issues if there is something wrong with the person's machine. Is it possible to have a dll with the existing unmanaged C++/MFC, and a .NET front end interface?

    Read the article

  • Scrollbar still is painted after it should be removed

    - by Walter Williams
    I have the following custom control and can place on a form (with AutoScroll set to true and the control anchored left, top and right). If the form is too short for the control, the form correctly resizes the control (to make room for the scroll) and displays the scroll bar. When the control is closed using the close glyph, the control is resized and the scroll bar is removed, but occasionally the scroll bar appears to remain painted. If the form is minimized or moved off-screen, the leftover paint is removed. I've tried Parent.Invalidate and have toyed with it in many ways but to no avail. Any suggestions? (Using VS 2008 Standard) using System; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; namespace GroupPanelTest { public class GroupPanel : GroupBox { #region Members private const Int32 iHeaderHeight = 20; private Int32 iFullHeight = 200; private Boolean bClosed = false; private Rectangle rectCloseGlyphBounds = Rectangle.Empty; private Boolean bIsMoveOverCloseGlyph = false; #endregion #region Properties [DefaultValue(false)] public Boolean Closed { get { return (this.bClosed); } set { if (this.bClosed != value) { this.bClosed = value; if (this.bClosed) { this.iFullHeight = base.Height; base.Height = GroupPanel.iHeaderHeight; } else { base.Height = this.iFullHeight; } foreach (Control con in base.Controls) con.Visible = !this.bClosed; this.Invalidate(); } } } public new Int32 Height { get { return (base.Height); } set { if (value != base.Height) { if (this.Closed) { this.iFullHeight = value; } else { Int32 iOldHeight = base.Height; base.Height = value; } } } } [DefaultValue(typeof(Size), "350,200")] public new Size Size { get { return (base.Size); } set { if (base.Size != value) { base.Size = value; if (!this.Closed) this.iFullHeight = value.Height; } } } [DefaultValue(typeof(Padding), "0,7,0,0")] public new Padding Padding { get { return (base.Padding); } set { base.Padding = value; } } #endregion #region Construction public GroupPanel () { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.Selectable, true); this.Size = new Size(350, 200); this.Padding = new Padding(0, 7, 0, 0); // the groupbox will add to that this.rectCloseGlyphBounds = new Rectangle(base.ClientSize.Width - 24, 2, 16, 16); } #endregion #region Overrides protected override void OnSizeChanged (EventArgs e) { this.rectCloseGlyphBounds = new Rectangle(base.ClientSize.Width - 24, 2, 16, 16); base.OnSizeChanged(e); } protected override void OnPaint (PaintEventArgs e) { base.OnPaint(e); // we want all the delegates to receive the events, but we do this first so we can paint over it Graphics g = e.Graphics; g.FillRectangle(SystemBrushes.Window, this.ClientRectangle); Rectangle rectTitle = new Rectangle(0, 0, this.ClientRectangle.Width, GroupPanel.iHeaderHeight); g.FillRectangle(SystemBrushes.Control, rectTitle); g.DrawString(this.Text, this.Font, SystemBrushes.ControlText, new PointF(5.0f, 3.0f)); if (this.bIsMoveOverCloseGlyph) { g.FillRectangle(SystemBrushes.ButtonHighlight, this.rectCloseGlyphBounds); Rectangle rectBorder = this.rectCloseGlyphBounds; rectBorder.Inflate(-1, -1); g.DrawRectangle(SystemPens.Highlight, rectBorder); } using (Pen pen = new Pen(SystemColors.ControlText, 1.6f)) { if (this.Closed) { g.DrawLine(pen, this.rectCloseGlyphBounds.Left + 3, this.rectCloseGlyphBounds.Top + 3, this.rectCloseGlyphBounds.Left + 8, this.rectCloseGlyphBounds.Top + 8); g.DrawLine(pen, this.rectCloseGlyphBounds.Left + 13, this.rectCloseGlyphBounds.Top + 3, this.rectCloseGlyphBounds.Left + 8, this.rectCloseGlyphBounds.Top + 8); g.DrawLine(pen, this.rectCloseGlyphBounds.Left + 3, this.rectCloseGlyphBounds.Top + 7, this.rectCloseGlyphBounds.Left + 8, this.rectCloseGlyphBounds.Top + 12); g.DrawLine(pen, this.rectCloseGlyphBounds.Left + 13, this.rectCloseGlyphBounds.Top + 7, this.rectCloseGlyphBounds.Left + 8, this.rectCloseGlyphBounds.Top + 12); } else { g.DrawLine(pen, this.rectCloseGlyphBounds.Left + 3, this.rectCloseGlyphBounds.Top + 8, this.rectCloseGlyphBounds.Left + 8, this.rectCloseGlyphBounds.Top + 3); g.DrawLine(pen, this.rectCloseGlyphBounds.Left + 13, this.rectCloseGlyphBounds.Top + 8, this.rectCloseGlyphBounds.Left + 8, this.rectCloseGlyphBounds.Top + 3); g.DrawLine(pen, this.rectCloseGlyphBounds.Left + 3, this.rectCloseGlyphBounds.Top + 12, this.rectCloseGlyphBounds.Left + 8, this.rectCloseGlyphBounds.Top + 7); g.DrawLine(pen, this.rectCloseGlyphBounds.Left + 13, this.rectCloseGlyphBounds.Top + 12, this.rectCloseGlyphBounds.Left + 8, this.rectCloseGlyphBounds.Top + 7); } } } protected override void OnMouseDown (MouseEventArgs e) { if (e.Button == MouseButtons.Left && this.rectCloseGlyphBounds.Contains(e.Location)) this.Closed = !this.Closed; // close will call invalidate base.OnMouseDown(e); } protected override void OnMouseMove (MouseEventArgs e) { this.bIsMoveOverCloseGlyph = this.rectCloseGlyphBounds.Contains(e.Location); this.Invalidate(this.rectCloseGlyphBounds); base.OnMouseMove(e); } #endregion } }

    Read the article

  • Can anyone explain why my crypto++ decrypted file 16 bytes short?

    - by Tom Williams
    I suspect it might be too much to hope for, but can anyone with experience with crypto++ explain why the "decrypted.out" file created by main() is 16 characters short (which probably not coincidentally is the block size)? I think the issue must be in CryptStreamBuffer::GetNextChar(), but I've been staring at it and the crypto++ documentation for hours. Any other comments about how crummy or naive my std::streambuf implementation are also welcome ;-) And I've just noticed I'm missing some calls to delete so you don't have to tell me about those. Thanks, Tom // Runtime Includes #include <iostream> // Crypto++ Includes #include "aes.h" #include "modes.h" // xxx_Mode< > #include "filters.h" // StringSource and // StreamTransformation #include "files.h" using namespace std; class CryptStreamBuffer: public std::streambuf { public: CryptStreamBuffer(istream& encryptedInput, CryptoPP::StreamTransformation& c); CryptStreamBuffer(ostream& encryptedOutput, CryptoPP::StreamTransformation& c); protected: virtual int_type overflow(int_type ch = traits_type::eof()); virtual int_type uflow(); virtual int_type underflow(); virtual int_type pbackfail(int_type ch); virtual int sync(); private: int GetNextChar(); int m_NextChar; // Buffered character CryptoPP::StreamTransformationFilter* m_StreamTransformationFilter; CryptoPP::FileSource* m_Source; CryptoPP::FileSink* m_Sink; }; // class CryptStreamBuffer CryptStreamBuffer::CryptStreamBuffer(istream& encryptedInput, CryptoPP::StreamTransformation& c) : m_NextChar(traits_type::eof()), m_StreamTransformationFilter(0), m_Source(0), m_Sink(0) { m_StreamTransformationFilter = new CryptoPP::StreamTransformationFilter(c); m_Source = new CryptoPP::FileSource(encryptedInput, false, m_StreamTransformationFilter); } CryptStreamBuffer::CryptStreamBuffer(ostream& encryptedOutput, CryptoPP::StreamTransformation& c) : m_NextChar(traits_type::eof()), m_StreamTransformationFilter(0), m_Source(0), m_Sink(0) { m_Sink = new CryptoPP::FileSink(encryptedOutput); m_StreamTransformationFilter = new CryptoPP::StreamTransformationFilter(c, m_Sink); } CryptStreamBuffer::int_type CryptStreamBuffer::overflow(int_type ch) { return m_StreamTransformationFilter->Put((byte)ch); } CryptStreamBuffer::int_type CryptStreamBuffer::uflow() { int_type result = GetNextChar(); // Reset the buffered character m_NextChar = traits_type::eof(); return result; } CryptStreamBuffer::int_type CryptStreamBuffer::underflow() { return GetNextChar(); } CryptStreamBuffer::int_type CryptStreamBuffer::pbackfail(int_type ch) { return traits_type::eof(); } int CryptStreamBuffer::sync() { if (m_Sink) { m_StreamTransformationFilter->MessageEnd(); } } int CryptStreamBuffer::GetNextChar() { // If we have a buffered character do nothing if (m_NextChar != traits_type::eof()) { return m_NextChar; } // If there are no more bytes currently available then pump the source // *** I SUSPECT THE PROBLEM IS HERE *** if (m_StreamTransformationFilter->MaxRetrievable() == 0) { m_Source->Pump(1024); } // Retrieve the next byte byte nextByte; size_t noBytes = m_StreamTransformationFilter->Get(nextByte); if (0 == noBytes) { return traits_type::eof(); } // Buffer up the next character m_NextChar = nextByte; return m_NextChar; } void InitKey(byte key[]) { key[0] = -62; key[1] = 102; key[2] = 78; key[3] = 75; key[4] = -96; key[5] = 125; key[6] = 66; key[7] = 125; key[8] = -95; key[9] = -66; key[10] = 114; key[11] = 22; key[12] = 48; key[13] = 111; key[14] = -51; key[15] = 112; } void DecryptFile(const char* sourceFileName, const char* destFileName) { ifstream ifs(sourceFileName, ios::in | ios::binary); ofstream ofs(destFileName, ios::out | ios::binary); byte key[CryptoPP::AES::DEFAULT_KEYLENGTH]; InitKey(key); CryptoPP::ECB_Mode<CryptoPP::AES>::Decryption decryptor(key, sizeof(key)); if (ifs) { if (ofs) { CryptStreamBuffer cryptBuf(ifs, decryptor); std::istream decrypt(&cryptBuf); int c; while (EOF != (c = decrypt.get())) { ofs << (char)c; } ofs.flush(); } else { std::cerr << "Failed to open file '" << destFileName << "'." << endl; } } else { std::cerr << "Failed to open file '" << sourceFileName << "'." << endl; } } void EncryptFile(const char* sourceFileName, const char* destFileName) { ifstream ifs(sourceFileName, ios::in | ios::binary); ofstream ofs(destFileName, ios::out | ios::binary); byte key[CryptoPP::AES::DEFAULT_KEYLENGTH]; InitKey(key); CryptoPP::ECB_Mode<CryptoPP::AES>::Encryption encryptor(key, sizeof(key)); if (ifs) { if (ofs) { CryptStreamBuffer cryptBuf(ofs, encryptor); std::ostream encrypt(&cryptBuf); int c; while (EOF != (c = ifs.get())) { encrypt << (char)c; } encrypt.flush(); } else { std::cerr << "Failed to open file '" << destFileName << "'." << endl; } } else { std::cerr << "Failed to open file '" << sourceFileName << "'." << endl; } } int main(int argc, char* argv[]) { EncryptFile(argv[1], "encrypted.out"); DecryptFile("encrypted.out", "decrypted.out"); return 0; }

    Read the article

  • Bidirectional/Loopback UDP in .net

    - by Jason Williams
    I've got an app that needs to transmit and receive on the same port. This can happen in two cases: Where the PC is talking to a piece of remote hardware. It "replies to sender", so the datagrams come back in to my PC via the sending port. Where the PC is talking to itself (loopback mode) for testing and demoing (a test app feeds fake data into our main app via UDP). This only seems to fail when trying to achieve loopback. The only way I can get it working is to ensure that the receiver is set up first - something I cannot guarantee. Can anyone help narrow down my search by suggesting a "correct" way to implement the UdpClient(s) to handle the above situations reliably? (The only solution that I've found to work reliably with the remote hardware is to use a single UdpClient in a bidirectional manner, although I'm working with legacy code that may be influencing that finding. I've tried using two UdpClients, but they step on each others toes - In some cases, once one client is started up, the other client cannot connect. With ExclusiveAddressUse/ReuseAddress set up to allow port sharing, I can almost get it to work, apart from the receiver having to start first)

    Read the article

  • Is it possible to have an out-of-process COM server where a separate O/S process is used for each ob

    - by Tom Williams
    I have a legacy C++ "solution engine" that I have already wrapped as an in-process COM object for use by client applications that only require a single "solution engine". However I now have a client application that requires multiple "solution engines". Unfortunately the underlying legacy code has enough global data, singletons and threading horrors that given available resources it isn't possible to have multiple instances of it in-process simultaneously. What I am hoping is that some kind soul can tell me of some COM magic where with the flip of a couple of registry settings it is possible to have a separate out-of-process COM server (separate operating system process) for each instance of the COM object requested. Am I in luck?

    Read the article

  • Test if current page is inside a shadowbox? (so i can close the shadowbox and reopen that page in t

    - by Max Williams
    Hi all I have a couple of pages in my site which open in a shadowbox window rather than the main window. My problem is that if the user session expires, then the user clicks on one of the links that open in a shadowbox, they are redirected to the login page INSIDE THE SHADOWBOX, which i don't want. I've been trying to think of the best way to handle this - one way i thought of, which seems a bit clumsy tbh, was on the login page to test if we're in a shadowbox, and if we are then close it and redirect the parent window to the login page. a) does this seem like a sensible plan? I added the following to my login page, which works: $(document).ready(function(){ if(window.parent.location != window.location){ window.parent.location.href = window.location; } } but i have to wait for the shadowbox to finish loading the page and then redirect. So it's working but like i say a bit clumsy. Is there a nicer way? grateful for any advice - max

    Read the article

  • Migrating from Forms to WPF

    - by Jason Williams
    We're considering migrating a WinForms app to WPF, but are just starting on the WPF learning curve now that 4.0 is out. What I'd like to do is migrate our application commands (cut, copy, paste, etc) to a WPF-like command-binding system, while still running as a WinForms app - but in such a way as to make the migration easy when we go ahead with WPF. The ideal approach would be to implement our commands using the WPF command interfaces, classes and events directly, and simply hooking the WinForms events up to them with our own dispatcher. Has anyone tried something like this or know if it might be possible?

    Read the article

  • How to visually represent file size

    - by Keith Williams
    This will be a bit subjective, I'm afraid, but I'd value the advice of the Collective. Our web application lists documents that users can download; standard file navigator stuff: Type Name Created Size ----------------------------------- PDF Doc 1 01/04/2010 15 KB PDF Doc 2 01/04/2010 15 MB Currently we list the file size as text, but I'd like to improve this by having some way of showing visually whether the file is tiny, normal or huge. The reason for this is so that users can scan the list quickly and spot files that are likely to take a long time downloading. My options currently are: Bigger font sizes for bigger files (drawback: the layout can become untidy) Icons (like a wi-fi signal strength indicator; drawback: harder to scan) Keep all sizes in KB so the number of zeroes indicates size (drawback: users have to calculate the "friendly" size in their heads) I know this is quite a minor thing, but I'd appreciate anyone's thoughts on the matter!

    Read the article

  • Rails - eager load the number of associated records, but not the record themselves.

    - by Max Williams
    I have a page that's taking ages to render out. Half of the time (3 seconds) is spent on a .find call which has a bunch of eager-loaded associations. All i actually need is the number of associated records in each case, to display in a table: i don't need the actual records themselves. Is there a way to just eager load the count? Here's a simplified example: @subjects = Subject.find(:all, :include => [:questions]) In my table, for each row (ie each subject) i just show the values of the subject fields and the number of associated questions for each subject. Can i optimise the above find call to suit these requirements? I thought about using a group field but my full call has a few different associations included, with some second-order associations, so i don't think group by will work. @subjects = Subject.find(:all, :include => [{:questions => :tags}, {:quizzes => :tags}], :order => "subjects.name") :tags in this case is a second-order association, via taggings. Here's my associations in case it's not clear what's going on. Subject has_many :questions has_many :quizzes Question belongs_to :subject has_many :taggings has_many :tags, :through => :taggings Quiz belongs_to :subject has_many :taggings has_many :tags, :through => :taggings Grateful for any advice - max

    Read the article

  • Automatically copy new Jar file to Tomcat project WEB-INF/lib folder

    - by The D Williams
    I am developing a Tomcat app (actually it's a Red5 app, but this is effectively the same). This contains the usual /WebContent/WEB-INF/lib folder, which is where I locate the various jars it uses. Recently, I pulled a package out of my app project, and converted into a separate Jar project which was then released as open source (this resides in the same workspace). What I want, is that when I build my Tomcat app, that Eclipse automatically pulls the latest version of the Jar I have built into its /WebContent/WEB-INF/lib folder. This is the behaviour you get with .NET when you reference one project from another, and I guess this is why I was expecting to find some way of doing it. At the moment, I have to manually copy/paste the Jar across each time I build it. Of course, ideally when I build my Tomcat app it would automatically detect if the Jar project was up-to-date too, and build it if not. Any suggestions most gratefully received.

    Read the article

  • Show NSSegmentedControl menu when segment clicked, despite having set action

    - by Justin Williams
    I have an NSSegmentedControl on my UI with 4 buttons. The control is connected to a method that will call different methods depending on which segment is clicked: - (IBAction)performActionFromClick:(id)sender { NSInteger selectedSegment = [sender selectedSegment]; NSInteger clickedSegmentTag = [[sender cell] tagForSegment:selectedSegment]; switch (clickedSegmentTag) { case 0: [self showNewEventWindow:nil]; break; case 1: [self showNewTaskWindow:nil]; break; case 2: [self toggleTaskSplitView:nil]; break; case 3: [self showGearMenu]; break; } } Segment 4 has has a menu attached to it in the awakeFromNib method. I'd like this menu to drop down when the user clicks the segment. At this point, it only will drop if the user clicks & holds down on the menu. From my research online this is because of the connected action. I'm presently working around it by using some code to get the origin point of the segment control and popping up the context menu using NSMenu's popUpContextMenu:withEvent:forView but this is pretty hacktastic and looks bad compared to the standard behavior of having the menu drop down below the segmented control cell. Is there a way I can have the menu drop down as it should after a single click rather than doing the hacky context menu thing?

    Read the article

  • Bash PS1 settings - how to get the current folder back as the terminal title

    - by Max Williams
    Hi all. I recently added these lines to my ~/.bashrc file to show the current branch if i'm in a git working folder, and it works nicely for that. However, what i've lost is that the current folder name used to be shown in the tab for the terminal i have open, and now it isn't: it always just says 'Terminal'. Can i get that back and still keep the git stuff? Here's the lines in question - it's the second one that's the issue, as commenting out just the second line fixes the problem. source /etc/bash_completion.d/git PS1='\h:\w$(__git_ps1 "\[\e[32m\][%s]\[\e[0m\]")$ ' I've been looking at explanations of the options for PS1 but can't see anything about the terminal window's title in there. Can anyone advise? thanks, max

    Read the article

  • Selenium: Can i test if a page loaded a flash app (ie a swf) properly?

    - by Max Williams
    hi all. I'm writing some selenium tests (in rspec for a rails app). One of my pages loads a swf and while i don't want to test the functionality of this flash app i do want to test that it loaded up ok. Is this possible? In case it helps, the html to load the swf is: <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="600"> <PARAM NAME=movie VALUE="http://localhost:3000/assets/players/millionaire/millionaire.swf"> <PARAM NAME=quality VALUE="high"> <PARAM NAME=FlashVars VALUE="quizXML=http://localhost:3000/quizzes/371.xml?online=true&myURL=http://localhost:3000/assets/players/millionaire/&online=true"> <param name=width value="800"> <param name=height value="600"> <EMBED src="http://localhost:3000/assets/players/millionaire/millionaire.swf" FlashVars="quizXML=http://localhost:3000/quizzes/371.xml?online=true&myURL=http://localhost:3000/assets/players/millionaire/&online=true" width="800" height="600" quality=high TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> </EMBED> </OBJECT> thanks - max

    Read the article

  • Creating A Single Threaded Server with AnyEvent (Perl)

    - by David Williams
    I'm working on creating a local service to listen on localhost and provide a basic call and response type interface. What I'd like to start with is a baby server that you can connect to over telnet and echoes what it receives. I've heard AnyEvent is great for this, but the documentation for AnyEvent::Socket does not give a very good example how to do this. I'd like to build this with AnyEvent, AnyEvent::Socket and AnyEvent::Handle. Right now the little server code looks like this: #!/usr/bin/env perl use AnyEvent; use AnyEvent::Handle; use AnyEvent::Socket; my $cv = AnyEvent->condvar; my $host = '127.0.0.1'; my $port = 44244; tcp_server($host, $port, sub { my($fh) = @_; my $cv = AnyEvent->condvar; my $handle; $handle = AnyEvent::Handle->new( fh => $fh, poll => "r", on_read => sub { my($self) = @_; print "Received: " . $self->rbuf . "\n"; $cv->send; } ); $cv->recv; }); print "Listening on $host\n"; $cv->wait; This doesn't work and also if I telnet to localhost:44244 I get this: EV: error in callback (ignoring): AnyEvent::CondVar: recursive blocking wait attempted at server.pl line 29. I think if I understand how to make a mini, single threaded server that simply prints out whatever its given and then waits for more input, I could take it a lot further from there. Any ideas?

    Read the article

  • Obtaining reference to Class instance by string name - VB.NET

    - by Jeff Williams
    Is it possible using Reflection or some other method to obtain a reference to a specific class instance from the name of that class instance? For example the framework for the applications i develop heavily uses public class instances such as: Public bMyreference as MyReference = new MyReference Then throughout the application bMyReference is used by custom controls and code. One of the properties of the custom controls is the "FieldName" which references a Property in these class instances (bMyReference.MyField) as a string. What i would like to be able to do is analyze this string "bMyReference.MyField" and then refer back to the actual Instance/Property. In VB6 I would use an EVAL or something simular to convert the string to an actual object but this obviously doesn't work in VB.net What I'm picturing is something like this Dim FieldName as String = MyControl.FieldName ' sets FielName to bMyReference.MyField Dim FieldObject() as String = FieldName.Split(".") ' Split into the Object / Property Dim myInstance as Object = ......... ' Obtain a reference to the Instance and set as myInstance Dim myProperty = myInstance.GetType().GetProperty(FieldObject(1))

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >