Search Results

Search found 9872 results on 395 pages for 'preg replace callback'.

Page 4/395 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Facebook RESTful API require_login() callback

    - by skidding
    Hi, I'm trying to authenticate a user through the RESTful API (not Connect) but I can't since the callback system does not work for me. I have a local app that creates the Facebook API object with my key and secret, then calls the Facebook API require_login() method; I am sent to Facebook login, I login, and then I am sent to http://www.facebook.com/login.php?auth_token=<...>, where there's another login with just a field for password (not username), I write it again, and after that I am redirected to normal Facebook home. What am I doing wrong? I have set the callback URL in the Facebook app proprieties. Does it have anything to do with the fact that it's localhost? Thanks!

    Read the article

  • jQuery.ajax success callback function not executed

    - by Frank Michael Kraft
    I have a JavaScript Ajax call (jQuery.ajax), that does not execute the success callback function. $.ajax({ url: target, contentType: 'application/json; charset=utf-8', type: 'POST', // type: 'GET', dataType: 'jsonp', error: function (xhr, status) { alert(status); }, success: function (result) { alert("Callback done!"); // grid.dataBind(result.results); // grid.dataBind(result); } }); I see in firebug, that the request is posted and the correct result in terms of the json is returned as expected. What is wrong?

    Read the article

  • Javascript callback for multiple ajax calls

    - by Jisaak
    My lack of javascript knowledge is getting me in trouble again. I think this should be a fairly easy problem to fix but I cant figure it out. Situation: I want to make three ajax calls in a click event. Each ajax call does a distinct operation and returns back data that is needed for a final callback. The calls themselves are not dependent on one another, they can all go at the same time, however I would like to have a final callback when all three are complete. $('#button').click(function() { fun1(); fun2(); fun3(); //now do something else when the requests have done their 'sucess' callbacks. }); var fun1= (function() { $.ajax({/*code*/}); }); var fun2 = (function() { $.ajax({/*code*/}); }); var fun3 = (function() { $.ajax({/*code*/}); });

    Read the article

  • WCF Callback Contract Fiddler Debugging

    - by DavyMac23
    I'm trying to debug a WCF self-hosted service utilizing callbacks. Every 1/2 I make a callback to a SL3 app to display the latest changes (yes, there are tons of changes every 1/2 second). There are 3 services, one has new data every 1/2 second, one has new data every second, and another has new data every hour. I've set all of my timeouts, Send, Receive, Open and Close to 2 days 23 hours and 23 minutes, but I still get time out errors on the service side when I go to issue the callback. I'm using Fiddler and I notice that my service that has new data every hour is still showing up every 10 seconds. Fiddlier shows a Body length of -1, then 10 seconds later it changes to 0 and the response is HTTP 200, but the overall elapsed time is 10 seconds. What's going on here?

    Read the article

  • Rails Cache Sweeper and Model Callback Firing

    - by Topher Fangio
    Hey guys, I have the following classes: class Vigil < ActiveRecord::Base after_update :do_something_cool private def do_something_cool # Sweet code here end end class NewsFeedObserver < ActionController::Caching::Sweeper observe Vigil def after_update # Create a news feed entry end end Everything works as expected. The after_update in the sweeper requires that the do_something_cool method in the model has finished before it can run properly. The problem is that the after_update in the sweeper is being called before (or perhaps at the same time as) the do_something_cool callback and it's causing problems. Does anyone know how to force the after_update in the sweeper to fire after the model callback? Is there better way to achieve this?

    Read the article

  • Mongoose 3.1.0: Why the callback in the connection.db.dropDatabase(callback) is never called?

    - by Totty
    Code: var connection = mongoose.createConnection('mongodb://localhost:9000/' + databaseName); connection.db.dropDatabase(function(err){ // never reach this point! debugger; console.log(err); console.log('-------------->Dropped database: ' + databaseName); }); If I do connection.open it says that it's already opening and no multiple calls to "open" are supported for the same connection. Even this doesn't work var conn = mongoose.createConnection('mongodb://localhost',databaseName, 9000, {}, function(){ console.log('created'); // is reached conn.db.dropDatabase(callback); // but the callback is not called anyway }); What is the problem? ("mongoose": "3.1.0") thanks

    Read the article

  • When is a Cocoa callback given controll?

    - by Kaspa
    Hi, I've been searching around the web for an answer to this one, but was unable to find an answer, on the other side I think it's something quite common thus there is a possibility I'm missing some keywords here. Anyhow, the problem is as follows: When is control given to a callback function in ObjC (iPhone)? Does it happen after control is given to a high up in the hierarchy class responsible for the runloop? Can it occur in the middle of another function call being executed? As an example, let's take the NSURLConnection, we don't know or can't predict when it's going to call didReceiveResponse or the other callback methods, can it be the case that didReceiveResponse get's called when I'm in the middle of another function? (highly doubt that but was unable to find information on callbacks wating for the end of the run loop) Cheers, Kaspa

    Read the article

  • jQuery: Scroll the window then addClass() - how to callback

    - by carillonator
    Inside a jQuery event handler, I would like to scroll the window and then add a class to something. This is my code: $('#foo').click(function() { window.scrollTo(y); $('#bar').addClass('active'); }); $(window).scroll(function() { $('#bar').removeClass('active'); }); Notice I have another handler to remove that same class whenever the window is scrolled. The scrolling part works fine, but seems to run asynchronously, so removeClass() happens after addClass() but before the scrolling is finished. I don't know how to do this in plain javascript. I know there is a jQuery scrollTop() function that does the same thing (but seems to have cross-browser issues), but it doesn't accept a callback. What I really need is a callback to add the class after the scrolling is finished. thanks!

    Read the article

  • Find/Replace Paragraph End (^13) in Microsoft Word 2007 Merges Paragraphs

    - by Mike Blyth
    I need to replace a target at the beginning of lines with something else. Without wildcards, I can say to replace "^pTarget" with "^pReplacement". With wildcards enabled, I use replace "^13Target" with "^13Replacement". The replacement is successful except that the paragraph is now merged with the previous one in a strange way: The end-paragraph mark is still in place and the paragraph begins on a new line, but Triple clicking to select paragraph selects both the changed paragraph and the one above In a macro, starting in the paragraph above and extending the selection to the end of paragraph causes both paragraphs to be selected. Inter-paragraph spacing disappears between the changed paragraph and the one above. In essence, the paragraph boundary has been removed although the end-paragraph mark is still shown. To duplicate this problem, make a new document Line 1 Line 2 Line 3 (separate paragraphs). Find and replace (with wildcards on) "^13" with "^13". If your result is the same as mine, you will see the problems listed above. I can work around this in the usual way of replacing ^p with something else first, e.g. "^p" = "$", then "$target" = "$replacement", but I'm curious about what's going on. (This is using Word 2007 on Windows 7) I don't know Word XML, but the XML output seems to correspond with the above. Replacing ^13 with ^13 moves the paragraphs together in almost the same way as replacing end-paragraph with end-line (^p = ^l). Here is the relevant XML of the original "Line 1, Line 2, Line 3" in separate paragraphs: <w:p w:rsidR="00BB3032" w:rsidRDefault="00027252"> <w:r><w:t>Line 1</w:t></w:r> </w:p> <w:p w:rsidR="00027252" w:rsidRDefault="00027252"> <w:r><w:t>Line 2</w:t></w:r> </w:p> <w:p w:rsidR="00027252" w:rsidRDefault="00027252"> <w:r><w:t>Line 3</w:t></w:r> </w:p> Now after replacing ^13 with ^13: <w:p w:rsidR="00027252" w:rsidRDefault="00027252"> <w:r><w:t>Line 1</w:t></w:r> <w:r w:rsidR="00C57863"><w:cr/></w:r> <w:r><w:t>Line 2</w:t></w:r> <w:r w:rsidR="00C57863"><w:cr/></w:r> <w:r><w:t>Line 3</w:t></w:r> <w:r w:rsidR="00C57863"><w:cr/></w:r> </w:p> Now original after replacement of ^p with ^l (convert end-paragraph to end-line) <w:p w:rsidR="00027252" w:rsidRDefault="00027252"> <w:r><w:t>Line 1</w:t></w:r> <w:r w:rsidR="00AC7B51"><w:br/></w:r> <w:r><w:t>Line 2</w:t></w:r> <w:r w:rsidR="00AC7B51"><w:br/></w:r> <w:r><w:t>Line 3</w:t></w:r> <w:r w:rsidR="00AC7B51"><w:br/></w:r> </w:p>

    Read the article

  • Java replace slow?

    - by cpf
    Hi StackOverflow, I have a Java application that makes heavy use of a large file, to read, process and give through to SolrEmbeddedServer (http://lucene.apache.org/solr/). One of the functions does basic HTML escaping: private String htmlEscape(String input) { return input.replace("&", "&amp;").replace(">", "&gt;").replace("<", "&lt;") .replace("'", "&apos;").replaceAll("\"", "&quot;"); } While profiling the application, the program spends roughly 58% of the time in this function, a total of 47% in replace, and 11% in replaceAll. Now, is the Java replace that slow, or am I on the right path and should I consider the program efficient enough to have its bottleneck in Java and not in my code? (Or am I replacing wrong?) Thanks in advance!

    Read the article

  • Is str.replace(..).replace(..) ad nauseam a standard idiom in Python?

    - by meeselet
    For instance, say I wanted a function to escape a string for use in HTML (as in Django's escape filter): def escape(string): """ Returns the given string with ampersands, quotes and angle brackets encoded. """ return string.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace("'", '&#39;').replace('"', '&quot;') This works, but it gets ugly quickly and appears to have poor algorithmic performance (in this example, the string is repeatedly traversed 5 times). What would be better is something like this: def escape(string): """ Returns the given string with ampersands, quotes and angle brackets encoded. """ # Note that ampersands must be escaped first; the rest can be escaped in # any order. return replace_multi(string.replace('&', '&amp;'), {'<': '&lt;', '>': '&gt;', "'": '&#39;', '"': '&quot;'}) Does such a function exist, or is the standard Python idiom to use what I wrote before?

    Read the article

  • Find & Replace in blogger

    - by Benjol
    (I just learnt that Yahoo are shutting down Geocities, this is a bummer as I used my account there to host two icons, in the days when Blogger didn't upload gifs. Now those two icons are referenced in every one of my 600+ posts). Blogger doesn't have a "Find & Replace in all posts" function. I'm wondering about using the API to hack something together, and wondered if anyone has already tried playing with the API, if there are any tips or things to avoid. Also if there isn't a sneaky shortcut (like switching to ftp, doing the replace locally then switching back?). Not 100% programming related, please be lenient, or at least answer my question before closing it!

    Read the article

  • Complex (?) Unix Text Replace Command

    - by Matrym
    What's the command line equivalent of: For every file that contains "AAA" within its contents, find "BBB" and replace it with "CCC" Thus, the command would match and replace BBB in a file: <html> <head></head> <body> AAA Hello world! BBB </body> </html> But Not in a file: <html> <head></head> <body> Don't match me! BBB </body> </html> Thanks in advance!

    Read the article

  • WinForms Control.BeginInvoke asynchronous callback

    - by Darran
    I have a number of Janus grid controls that need to be populated on an application startup. I'd like to load these grids on different threads to speed startup time and the time it takes to refresh these grids. Each grid is on a seperate tab. Ideally I'd like to use Control.BeginInvoke on each grid and on the grid load completing the tabs will become enabled. I know with Delegates you can do a Asynchronous callback when using BeginInvoke, so I could enable the tabs in the asynchronous callback, however when using Control.BeginInvoke this is not possible. Is there a way to do asynchronous callbacks using Control.BeginInvoke or possibly a better solution? So far I have: public delegate void BindDelegate(IMyGrid grid); private IAsyncResult InvokeBind(IMyGrid grid) { return ((Control)grid).BeginInvoke( new BindDelegate(DoBind), new object[] { grid } ); } private void DoBind(IMyGrid grid) { grid.Bind(); // Expensive operation } private void RefreshComplete() { IAsyncResult grid1Asynch = InvokeBind(grid1); IAsyncResult grid2Asynch = InvokeBind(grid2); IAsyncResult grid3Asynch = InvokeBind(grid2); IAsyncResult grid4Asynch = InvokeBind(grid3); IAsyncResult grid5Asynch = InvokeBind(grid4); IAsyncResult grid6Asynch = InvokeBind(grid5); } Now I could spin off a separate thread and keep checking to see if the IAsynchResults have completed and depending on which one completes I could re-enable the Tab control that the grid is contained in. Is there a better way of doing this?

    Read the article

  • WCF Callback Faulted - what happens to the session?

    - by RemotecUk
    Just trying to get my head around what can happen when things go wrong with WCF. I have an implementation of my service contract declared with an InstanceContextMode of PerSession... [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)] The calls happen as follows: My client calls the server and calls GetServerUTC() to return the current UTC time of the server. This is a one way call and the server will call the client back when its ready (trivial in this instance to simply return the current time!) The server calls back to the client and for test purposes in the callback implementation on the client I throw an exception. This goes unhandled in the client (for test purposes) and the client crashes and closes down. On the server I handle the faulted event handler on the ICommunicationObject... obj.Faulted += new EventHandler(EventService_Faulted); Questions... Will this kill off the session for the current connection on the server. I presume I am free to do what I want in this method e.g. logging or something, but should I do anything specific here to terminate the session or will WCF handle this? From a best practise view point what should I do when the callback is faulted? Does it mean "something has happened in your client" and thats the end of that or is there something I a missing here? Additionally, are there any other faulted handlers I should be handling. Ive done a lot of reading on WCF and it seems sort of vague on what to do when something goes wrong. At present I am implementing a State Machine on my client which will manage the connection and determine if a user action can happen dependant on if a connection exists to the server - or is this overkill. Any tips would be really appreciated ;)

    Read the article

  • Design problem with callback functions in android

    - by Franz Xaver
    Hi folks! I'm currently developing an app in android that is accessing wifi values, that is, the application needs to scan for all access point and their specific signal strengths. I know that I have to extend the class BroadcastReceiver overwriting the method BroadcastReceiver.onReceive(Context context, Intent intent) which is called when the values are ready. Perhaps there exist solutions provided by the android system itself but I'm relatively new to android so I could need some help. The problem I encountered is that I got one class (an activity, thus controlled by the user) that needs this scan results for two different things (first to save the values in a database or second, to use them for further calculations but not both at one moment!) So how to design the callback system in order to "transport" the scan results from onReceive(Context context, Intent intent) to the operation intended by the user? My first solution was to define enums for each use case (save or use for calculations) which wlan-interested classes have to submit when querying for the values. But that would force the BroadcastReceiverextending class to save the current enum and use it as a parameter in the callback function of the querying class (this querying class needs to know what it asked for when getting backcalled) But that seems to me kind of dirty ;) So anyone a good idea for this?

    Read the article

  • CURL C API: callback was not called

    - by Pierre
    Hi all, The code below is a test for the CURL C API . The problem is that the callback function write_callback is never called. Why ? /** compilation: g++ source.cpp -lcurl */ #include <assert.h> #include <iostream> #include <cstdlib> #include <cstring> #include <cassert> #include <curl/curl.h> using namespace std; static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *userp) { std::cerr << "CALLBACK WAS CALLED" << endl; exit(-1); return size*nmemb; } static void test_curl() { int any_data=1; CURLM* multi_handle=NULL; CURL* handle_curl = ::curl_easy_init(); assert(handle_curl!=NULL); ::curl_easy_setopt(handle_curl, CURLOPT_URL, "http://en.wikipedia.org/wiki/Main_Page"); ::curl_easy_setopt(handle_curl, CURLOPT_WRITEDATA, &any_data); ::curl_easy_setopt(handle_curl, CURLOPT_VERBOSE, 1); ::curl_easy_setopt(handle_curl, CURLOPT_WRITEFUNCTION, write_callback); ::curl_easy_setopt(handle_curl, CURLOPT_USERAGENT, "libcurl-agent/1.0"); multi_handle = ::curl_multi_init(); assert(multi_handle!=NULL); ::curl_multi_add_handle(multi_handle, handle_curl); int still_running=0; /* lets start the fetch */ while(::curl_multi_perform(multi_handle, &still_running) == CURLM_CALL_MULTI_PERFORM ); std::cerr << "End of curl_multi_perform."<< endl; //cleanup should go here ::exit(EXIT_SUCCESS); } int main(int argc,char** argv) { test_curl(); return 0; } Many thanks Pierre

    Read the article

  • Scoping problem with Javascript callback

    - by nazbot
    I am having some trouble getting a callback function to work. Here is my code: SomeObject.prototype.refreshData = function() { var read_obj = new SomeAjaxCall("read_some_data", { }, this.readSuccess, this.readFail); } SomeObject.prototype.readSuccess = function(response) { this.data = response; this.someList = []; for (var i = 0; i < this.data.length; i++) { var systemData = this.data[i]; var system = new SomeSystem(systemData); this.someList.push(system); } this.refreshList(); } Basically SomeAjaxCall is making an ajax request for data. If it works we use the callback 'this.readSuccess' and if it fails 'this.readFail'. I have figured out that 'this' in the SomeObject.readSuccess is the global this (aka the window object) because my callbacks are being called as functions and not member methods. My understanding is that I need to use closures to keep the 'this' around, however, I have not been able to get this to work. If someone is able show me what I should be doing I would appreciate it greatly. I am still wrapping my head around how closures work and specifically how they would work in this situation. Thanks!

    Read the article

  • replace a random word of a string with a random replacement

    - by tpickett
    I am developing a script that takes an article, searches the article for a "keyword" and then randomly replaces that keyword with an anchor link. I have the script working as it should, however I need to be able to have an array of "replacements" for the function to loop through and insert at the random location. So the first random position would get anchor link #1. The second random position would get anchor link #2. The third random position would get anchor link #3. etc... I found half of the answer to my question here: PHP replace a random word of a string public function replace_random ($str, $search, $replace, $n) { // Get all occurences of $search and their offsets within the string $count = preg_match_all('/\b'.preg_quote($search, '/').'\b/', $str, $matches, PREG_OFFSET_CAPTURE); // Get string length information so we can account for replacement strings that are of a different length to the search string $searchLen = strlen($search); $diff = strlen($replace) - $searchLen; $offset = 0; // Loop $n random matches and replace them, if $n < 1 || $n > $count, replace all matches $toReplace = ($n < 1 || $n > $count) ? array_keys($matches[0]) : (array) array_rand($matches[0], $n); foreach ($toReplace as $match) { $str = substr($str, 0, $matches[0][$match][1] + $offset).$replace.substr($str, $matches[0][$match][1] + $searchLen + $offset); $offset += $diff; } return $str; } So my question is, How can i alter this function to accept an array for the $replace variable?

    Read the article

  • Word Automation : Replace do not work after TypeText

    - by wishper
    I need to generate doc (real doc, not docx) files, the "best" way i have found is to use word automation (Word 2010). I have files that I open, and then replace values inside before saving it on a new name. (Ex : I replace "" with "155023"). To do this, I use the Application.Selection.Find. I just had a problem when the new value had more than 255 characters (Thanks Microsofts limitations ...). To avoid this problem, i use TypeText in this case. My problem now is once I use TypeText, the Replace do not work anymore .. And I can't find why. Any idea will be greatly appreciated. My code is in a function, called in a foreach with each values to replace : private void Replace(Application app, string name, string newValue) { Selection selection = app.Selection; Find find = selection.Find; Replacement replacement = find.Replacement; find.ClearFormatting(); find.Text = "<" + name + ">"; // Word limitation : can't replace with more than 255 characters, // use another way to do it if that's the case if (tempNewValue.Length < 255) { replacement.ClearFormatting(); replacement.Text = tempNewValue; find.Execute(Replace: replaceAll); } else { while (find.Execute()) { selection.TypeText(tempNewValue); } } Marshal.ReleaseComObject(replacement); Marshal.ReleaseComObject(find); Marshal.ReleaseComObject(selection); }

    Read the article

  • Can a WCF contract use multiple callback interfaces?

    - by mafutrct
    I'm trying something like this: [ServiceContract ( CallbackContract = typeof (CallbackContract_1), CallbackContract = typeof (CallbackContract_2), CallbackContract = typeof (CallbackContract_3)) ] public interface SomeWcfContract { I know it does not work like this. Is there still a way to get a single contract use multiple callback interfaces?

    Read the article

  • Javascript callback and google maps api question

    - by es11
    I am using google maps api v3 and have an array of arrays object: MVCArray.<MVCArray.<LatLng>> I want to iterate over this. I see that MVCArray has a method forEach which uses a call back, but I have no idea how to use this (I haven't done much js). The api defines this method as follows: forEach(callback:function(*, number))) Could somebody please show me an example of how to use this given an MVCArray of MVCArrays?

    Read the article

  • Programming a callback function within a jQuery plugin

    - by ILMV
    I'm writing a jQuery plug-in so I can reuse this code in many places as it is a very well used piece of code, the code itself adds a new line to a table which has been cloned from a hidden row, it continues to perform a load of manipulations on the new row. I'm currently referencing it like this: $(".abc .grid").grid(); But I want to include a callback so each area the plug-in is called from can do something a bit more unique when the row has been added. I've used the jQuery AJAX plug-in before, so have used the success callback function, but cannot understand how the code works in the background. Here's what I want to achieve: $(".abc .grid").grid({ row_added: function() { // do something a bit more specific here } }); Here's my plug-in code (function($){ $.fn.extend({ //pass the options variable to the function grid: function() { return this.each(function() { grid_table=$(this).find('.grid-table > tbody'); grid_hidden_row=$(this).find('.grid-hidden-row'); //console.debug(grid_hidden_row); $(this).find('.grid-add-row').click(function(event) { /* * clone row takes a hidden dummy row, clones it and appends a unique row * identifier to the id. Clone maintains our jQuery binds */ // get the last id last_row=$(grid_table).find('tr:last').attr('id'); if(last_row===undefined) { new_row=1; } else { new_row=parseInt(last_row.replace('row',''),10)+1; } // append element to target, changes it's id and shows it $(grid_table).append($(grid_hidden_row).clone(true).attr('id','row'+new_row).removeClass('grid-hidden-row').show()); // append unique row identifier on id and name attribute of seledct, input and a $('#row'+new_row).find('select, input, a').each(function(id) { $(this).appendAttr('id','_row'+new_row); $(this).replaceAttr('name','_REPLACE_',new_row); }); // disable all the readonly_if_lines options if this is the first row if(new_row==1) { $('.readonly_if_lines :not(:selected)').attr('disabled','disabled'); } }); $(this).find('.grid-remove-row').click(function(event) { /* * Remove row does what it says on the tin, as well as a few other house * keeping bits and pieces */ // remove the parent tr $(this).parents('tr').remove(); // recalculate the order value5 //calcTotal('.net_value ','#gridform','#gridform_total'); // if we've removed the last row remove readonly locks row_count=grid_table.find('tr').size(); console.info(row_count); if(row_count===0) { $('.readonly_if_lines :disabled').removeAttr('disabled'); } }); }); } }); })(jQuery); I've done the usually searching on elgooG... but I seem to be getting a lot of noise with little result, any help would be greatly appreciated. Thanks!

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >