Search Results

Search found 4088 results on 164 pages for 'params keyword'.

Page 59/164 | < Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >

  • Python and urllib2: how to make a GET request with parameters

    - by Infinity
    I'm building an "API API", it basically a wrapper for a in house REST web service that the web app will be making a lot of requests to. Some of the web service calls need to be GET rather than post, but passing parameters. Is there a "best practice" way to encode a dictionary into a query string? e.g.: ?foo=bar&bla=blah I'm looking at the urllib2 docs, and it looks like it decides by itself wether to use POST or GET based on if you pass params or not, but maybe someone knows how to make it transform the params dictionary into a GET request. Maybe there's a package for something like this out there? It would be great if it supported keep-alive, as the web server will be constantly requesting things from the REST service. Thanks!

    Read the article

  • importing CELERY* environment variables in django settings.py causes celeryd not to start

    - by Taras
    I just spent 2 hours trying to figure out why django celery stopped working. Celery would being to start, but would stop short of printing out the configuration items, implying that it wasn't starting correct. The log would only contain The celery.decorators module along with the magic keyword arguments, are deprecated, and will be removed in version 3.0. Please use the celery.task module instead of celery.decorators, and the task.request should be used instead of the magic keyword arguments: from celery.task import task See http://bit.ly/celery22major for more information. """)) It turns out that some celery env variables that I was importing to try and fix a different problem were causing celery not to start correctly: from celery.tests.config import CELERY_QUEUES, CELERY_DEFAULT_QUEUE, CELERY_DEFAULT_ROUTING_KEY Even though I wasn't using them anywhere. Does anyone know what was happening?

    Read the article

  • Internationalization of static pages with Rails

    - by Gavin
    I feel like I'm missing something really simple and I keep spinning my wheels on this problem. I currently have internationalization working throughout my app. The translations work and the routes work perfectly. At least, most of the site works with the exception of the routes to my two static pages, my "About" and "FAQ" pages. Every other link throughout the app points to the proper localized route. For example if I select "french" as my language, links point to the appropriate "(/:locale)/controller(.:format)." However, despite the changes I make throughout the app my links for the "About" and "FAQ" refuse to point to "../fr/static/about" and always point to "/static/about." To make matters stranger, when I run rake routes I see: "GET (/:locale)/static/:permalink(.:format) pages#show {:locale=/en|fr/}" and when I manually type in "../fr/static/about" the page translates perfectly. My Routes file: devise_for :users scope "(:locale)", :locale => /en|fr/ do get 'static/:permalink', :controller => 'pages', :action => 'show' resources :places, only: [:index, :show, :destroy] resources :homes, only: [:index, :show] match '/:locale' => 'places#index' get '/'=>'places#index',:as=>"root" end My ApplicationController: before_filter :set_locale def set_locale I18n.locale=params[:locale]||I18n.default_locale end def default_url_options(options={}) logger.debug "default_url_options is passed options: #{options.inspect}\n" { :locale => I18n.locale } end and My Pages Controller: class PagesController < ApplicationController before_filter :validate_page PAGES = ['about_us', 'faq'] def show render params[:permalink] end def validate_page redirect_to :status => 404 unless PAGES.include?(params[:permalink]) end end I'd be very grateful for any help ... it's just been one of those days. Edit: Thanks to Terry for jogging me to include views. <div class="container-fluid nav-collapse"> <ul class="nav"> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t(:'navbar.about') %><b class="caret"></b></a> <ul class="dropdown-menu"> <li><%=link_to t(:'navbar.about_us'), "/static/about_us"%></li> <li><%=link_to t(:'navbar.faq'), "/static/faq"%></li> <li><%=link_to t(:'navbar.blog'), '#' %></li> </ul> </li>

    Read the article

  • Is there a Java method that encodes a collection of parameters as a URL query component?

    - by Steven Huwig
    Is there a widely-used Java library that does something like what dojo.objectToQuery() does? E.g. (assuming the use of HttpCore's HttpParams object, but any key-value mapping will do): HttpParams params = new BasicHttpParams() .setParameter("foo", "bar") .setParameter("thud", "grunt"); UnknownLibrary.toQueryString(params); should yield "foo=bar&thud=grunt". I know it's not hard to write but it seems like it should have already been written. I just can't find it.

    Read the article

  • How would you implement the "tell don't ask" principle in HAML?

    - by Enrique Ramírez Vélez
    Here's the thing. I have a button that, depending on the scenario, will behave, look and have different text. Here's how it, roughly, looks like at the moment: - if params[:param_A] && @statement_A %span.button.cancel_button{attribute: "value_B"} - if @statement_B = t('locale_A') - else = t('locale_B') - elsif params[:param_A] %span.button.cancel_button{attribute: "value_A"} - if @statement_B = t('locale_A') - else = t('locale_B') There's also a CSS class both buttons should have IF statement_B is true. So it is a mess. And I recently read about the "Tell, don't ask" principle which I liked very much, so I'd love to apply it here... but I'm not sure how. I know I could make a helper, but I'd like to stay away from them because reasons (I really have some valid reasons to do so, but those are beyond the scope of this question). I can resort to that as a last resource, but would rather find another solution.

    Read the article

  • Using jQuery to find keywords in string

    - by Nic Hubbard
    In php, I have used preg_match_all() to find keywords (using the format %keyword%) in a string, which works wonderfully and returns an array of all found keywords. What I would like to do, is do the same thing using jQuery or javascript. I have tried using the filter() function, and it kind of works. But I think I am missing something. How can I find ALL instances of the keyword in a string, using a regex? Here is what I have worked out so far: $("[id^='editableContent-']").filter(function() { alert($(this).html().match(/\%(.*?)\%/)); }); Any suggestions are welcome!

    Read the article

  • Calling cdecl Functions That Have Different Number of Arguments

    - by KlaxSmashing
    I have functions that I wish to call based on some input. Each function has different number of arguments. In other words, if (strcmp(str, "funcA") == 0) funcA(a, b, c); else if (strcmp(str, "funcB") == 0) funcB(d); else if (strcmp(str, "funcC") == 0) funcC(f, g); This is a bit bulky and hard to maintain. Ideally, these are variadic functions (e.g., printf-style) and can use varargs. But they are not. So exploiting the cdecl calling convention, I am stuffing the stack via a struct full of parameters. I'm wondering if there's a better way to do it. Note that this is strictly for in-house (e.g., simple tools, unit tests, etc.) and will not be used for any production code that might be subjected to malicious attacks. Example: #include <stdio.h> typedef struct __params { unsigned char* a; unsigned char* b; unsigned char* c; } params; int funcA(int a, int b) { printf("a = %d, b = %d\n", a, b); return a; } int funcB(int a, int b, const char* c) { printf("a = %d, b = %d, c = %s\n", a, b, c); return b; } int funcC(int* a) { printf("a = %d\n", *a); *a *= 2; return 0; } typedef int (*f)(params); int main(int argc, char**argv) { int val; int tmp; params myParams; f myFuncA = (f)funcA; f myFuncB = (f)funcB; f myFuncC = (f)funcC; myParams.a = (unsigned char*)100; myParams.b = (unsigned char*)200; val = myFuncA(myParams); printf("val = %d\n", val); myParams.c = (unsigned char*)"This is a test"; val = myFuncB(myParams); printf("val = %d\n", val); tmp = 300; myParams.a = (unsigned char*)&tmp; val = myFuncC(myParams); printf("a = %d, val = %d\n", tmp, val); return 0; } Output: gcc -o func func.c ./func a = 100, b = 200 val = 100 a = 100, b = 200, c = This is a test val = 200 a = 300 a = 600, val = 0

    Read the article

  • Calling an svn update from a php script via a browser is not working

    - by hbt
    Hey guys, I have two scripts. running an update and calling shell_exec('svn update') and shell_exec('svn st') running a mysqldump shell_exec('mysqldump params') The svn script is not running the update command, the svn st is printing results but not the svn update I tried to declare parameters when calling svn update eg 'svn update ' . dir . ' --username myuser --password mypasswd --non-interactive'; -- still nothing Played with most of the params If this is something related to binaries/permissions/groups, I don't see it. The mysqldump command works fine and is producing a file, so why isn't the svn updating the filesystem? Please do not advise using core SVN classes in PHP. This is not an option, I don't have complete control over the server and the module is not available. Thanks for your help, -hbt PS: important thing to mention here. The scripts works when called via the command line. It only fails when called via a web browser.

    Read the article

  • AngularJS service returning promise unit test gives error No more request expected

    - by softweave
    I want to test a service (Bar) that invokes another service (Foo) and returns a promise. The test is currently failing with this error: Error: Unexpected request: GET foo.json No more request expected Here are the service definitions: // Foo service returns new objects having get function returning a promise angular.module('foo', []). factory('Foo', ['$http', function ($http) { function FooFactory(config) { var Foo = function (config) { angular.extend(this, config); }; Foo.prototype = { get: function (url, params, successFn, errorFn) { successFn = successFn || function (response) {}; errorFn = errorFn || function (response) {}; return $http.get(url, {}).then(successFn, errorFn); } }; return new Foo(config); }; return FooFactory; }]); // Bar service uses Foo service angular.module('bar', ['foo']). factory('Bar', ['Foo', function (Foo) { var foo = Foo(); return { getCurrentTime: function () { return foo.get('foo.json', {}, function (response) { return Date.parse(response.data.now); }); } }; }]); Here is my current test: 'use strict'; describe('bar tests', function () { var currentTime, currentTimeInMs, $q, $rootScope, mockFoo, mockFooFactory, Foo, Bar, now; currentTime = "March 26, 2014 13:10 UTC"; currentTimeInMs = Date.parse(currentTime); beforeEach(function () { // stub out enough of Foo to satisfy Bar service: // create mock object with function get: function(url, params, successFn, errorFn) // that promises to return a response with this property // { data: { now: "March 26, 2014 13:10 UTC" }}) mockFoo = { get: function (url, params, successFn, errorFn) { successFn = successFn || function (response) {}; errorFn = errorFn || function (response) {}; // setup deferred promise var deferred = $q.defer(); deferred.resolve({data: { now: currentTime }}); return (deferred.promise).then(successFn, errorFn); } }; // create mock Foo service mockFooFactory = function(config) { return mockFoo; }; module(function ($provide) { $provide.value('Foo', mockFooFactory); }); module('bar'); inject(function (_$q_, _$rootScope_, _Foo_, _Bar_) { $q = _$q_; $rootScope = _$rootScope_; Foo = _Foo_; Bar = _Bar_; }); }); it('getCurrentTime should return currentTimeInMs', function () { Bar.getCurrentTime().then(function (serverCurrentTime) { now = serverCurrentTime; }); $rootScope.$apply(); // resolve Bar promise expect(now).toEqual(currentTimeInMs); }); }); The error is being thrown at $rootScope.$apply(). I also tried using $rootScope.$digest(), but it gives the same error. Thanks in advance for any insight you can give me.

    Read the article

  • Rails and jQuery - how do you get server-side validation errors to your view after an ajax request

    - by adam
    Ive searched this site but questions are usually regarding doing client-side validations or for different frameworks. I have a tasks list whose items can be edited inline. Upon submitting the inline edit form the item is updated all thanks to jQuery, ajax and rails. But I want to handle bad input from the user. HTML requests redisplay the view and errors are displayed thanks to rails helpers. But how do I insert that information after an ajax call? Heres my update method in my controller def update @task = Task.find(params[:id]) respond_to do |format| if @task.update_attributes(params[:task]) flash[:notice] = 'Task was successfully updated.' format.html { redirect_to(@task) } format.xml { head :ok } format.js else format.html { render :action => "edit" } format.xml { render :xml => @task.errors, :status => :unprocessable_entity } #format.js ...hmmm... either go to js.erb file or do stuff inline end end end

    Read the article

  • Google Maps custom marker - can the iframe accept one like the static maps?

    - by alex
    I was reading the static maps API, and it says you can include a custom marker in the GET params. You simply link to an image file. I now have a second Google Map within an iframe, and was wondering if you can attach custom markers via the GET params to it? Here is the src attribute of the iframe currently. http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=111+Fake+Street+Noosaville+Queensland+Australia&ie=UTF8&output=embed I can't seem to find the documentation on how to do this, if possible. Is this possible?

    Read the article

  • highlight multiple keywords in search

    - by fusion
    i'm using this code to highlight search keywords: function highlightWords($string, $word) { $string = str_replace($word, "<span class='highlight'>".$word."</span>", $string); /*** return the highlighted string ***/ return $string; } .... $cQuote = highlightWords(htmlspecialchars($row['cQuotes']), $search_result); however, this highlights only one keyword. if the user enters more than one keyword, it will narrow down the search but no word is highlighted. how can i highlight more than one word?

    Read the article

  • How to search in this activerecord example?

    - by Horace Ho
    Two models: Invoice :invoice_num string :date datetime . . :disclaimer_num integer (foreign key) Disclaimer :disclaimer_num integer :version integer :body text For each disclaimer there are multiple versions and will be kept in database. This is how I write the search (simplified): scope = Invoice.scoped({ :joins => [:disclaimer] }) scope = scope.scoped :conditions => ["Invoice.invoice_num = ?", "#{params[:num]}"] scope = scope.scoped :conditions => ["Disclaimer.body LIKE ?", "%#{params[:text]}%"] However, the above search will search again all versions of the disclaimer. How can I limit the search to only the last disclaimer (i.e. the version integer is the maximum). Please note: Invoice does not keep the version number. New disclaimers will be added to disclaimer table and keep old versions.

    Read the article

  • CakePHP save without form

    - by SDwebs
    I have a photo gallery I'm trying to set a picture as the cover for the album. I have a field cover_id in the albums table that has already been linked to the photos through the model. I'm passing the album_id and photo_id to the controller. I want to update the album.cover_id passed thru the params with the photo_id passed thru the params. Is there a way to do this or a way to make the link a form without having it look like or form or changing much of the CSS?

    Read the article

  • Set Facebook status using iphone app

    - by gmcalab
    I have just started with the new graph api for facebook. I have gotten a few items to work like logging in and getting the user name and displaying this to the screen. I am having trouble figuring out how to set my status with the graph api... I have tried a couple things but I always receive and error response back. Any ideas? NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"test2", @"test", nil]; [_facebook requestWithMethodName:@"status.set" andParams:params andHttpMethod:@"POST" andDelegate:self];

    Read the article

  • PHP - Filter some words

    - by bob
    I want to filter some reserved word on my title form. $adtitle = sanitize($_POST['title']); $ignore = array('sale','buy','rent'); if(in_array($adtitle, $ignore)) { $_SESSION['ignore_error'] = '<strong>'.$adtitle.'</strong> cannot be use as your title'; header('Location:/submit/'); exit; How to make something like this. If user type Car for sale the sale will detected as reserved keyword. Now my current code only detect single keyword only.

    Read the article

  • Ruby on Rails: building a model with an attribute not in the database?

    - by randombits
    I have a model that sets one of its attributes based off of a form parameter that a user submits. The model is a child resource to a parent resource Home. A hypothetical example is the following: A class Person has an age attribute. The user submits a birthdate as an HTTP POST parameter and from that, I need to derive the age of the user. So I'd do something like this: @home.people.build(:name => params[:name], :birthdate => params[:birthdate]) Rails would barf on that for obvious reasons, complaining it doesn't know what the attribute birthdate is. What's the proper way of going about this? Is it possible to use the build constructor with the supplied solution so that my foreign key relations are also setup properly? If not, what's a better way to work around this problem?

    Read the article

  • MODX parse error function implode (is it me or modx?)

    - by Ian
    Hi, I cannot for the life of me figure this out, maybe someone can help. Using MODX a form takes user criteria to create a filter and return a list of documents. The form is one text field and a few checkboxes. If both text field and checkbox data is posted, the function works fine; if just the checkbox data is posted the function works fine; but if just the text field data is posted, modx gives me the following error: Error: implode() [function.implode]: Invalid arguments passed. I've tested this outside of modx with flat files and it all works fine leading me to assume a bug exists within modx. But I'm not convinced. Here's my code: <?php $order = array('price ASC'); //default sort order if(!empty($_POST['tour_finder_duration'])){ //duration submitted $days = htmlentities($_POST['tour_finder_duration']); //clean up post array_unshift($order,"duration DESC"); //add duration sort before default $filter[] = 'duration,'.$days.',4'; //add duration to filter[] (field,criterion,mode) $criteria[] = 'Number of days: <strong>'.$days.'</strong>'; //displayed on results page } if(!empty($_POST['tour_finder_dests'])){ //destination/s submitted $dests = $_POST['tour_finder_dests']; foreach($dests as $value){ //iterate through dests array $filter[] = 'searchDests,'.htmlentities($value).',7'; //add dests to filter[] $params['docid'] = $value; $params['field'] = 'pagetitle'; $pagetitle = $modx->runSnippet('GetField',$params); $dests_array[] = '<a href="[~'.$value.'~]" title="Read more about '.$pagetitle.'" class="tourdestlink">'.$pagetitle.'</a>'; } $dests_array = implode(', ',$dests_array); $criteria[] = 'Destinations: '.$dests_array; //displayed on results page } if(is_array($filter)){ $filter = implode('|',$filter);//pipe-separated string } if(is_array($order)){ $order = implode(',',$order);//comma-separated string } if(is_array($criteria)){ $criteria = implode('<br />',$criteria); } echo '<br />Order: '.$order.'<br /> Filter: '.$filter.'<br /> Criteria: '.$criteria; //next: extract docs using $filter and $order, display user's criteria using $criteria... ?> The echo statement is displayed above the MODX error message and the $filter array is correctly imploded. Any help will save my computer from flying out the window. Thanks

    Read the article

  • Ajax / GroovyGrails Post data coming over with unexpected leading character. Who is encoding/decod

    - by ?????
    I'm having an encoding issue, and I'm not sure where to look for the problem. I have this Ajax.Request function (prototype library) sending data to a Groovy/Grails encoder var myAjax = new Ajax.Request(url, {method:'post', encoding:'UTF-8', contentType:'application/x-www-form-urlencoded', parameters:{'content':new_content}, onSuccess:success, onFailure:failure}); The data is coming in with an unexpected %A0 at the beginning: I have this simple controller that just echos the content back: def titlechange = { def content = URLDecoder.decode(params['content']) printf("Content: %s; DecodedContent = %s\n", params['content'], content) response.characterEncoding='UTF-8' render content } the debug print statement shows: Content: %A0Hello%2C%20world%21; DecodedContent = †Hello, world! Where is that %A0 coming from? My grails configuration has this: // The default codec used to encode data with ${} grails.views.default.codec="none" // none, html, base64 grails.views.gsp.encoding="UTF-8" grails.converters.encoding="UTF-8 Is the issue on the grails side or on the JavaScript side?

    Read the article

  • How can I make the Rails 3 router localize URLs using localization files?

    - by edgerunner
    What I'd like to be able to do is: in config/routes.rb resources :posts in config/locale/en.yml en: resources: posts: "posts" new: "new" edit: "edit" in config/locale/tr.yml tr: resources: posts: "yazilar" new: "yeni" edit: "duzenle" and get I18n.locale = :en edit_post_path(3) #=> /posts/3/edit I18n.locale = :tr edit_post_path(3) #=> /yazilar/3/duzenle I'd also like Rails to match any of these routes anytime and pass the associated locale in the params hash such that when I navigate to /yazilar , the request should be routed to the posts#index action with the :tr locale in the params hash. Any simple or complex way of doing that?

    Read the article

  • Fastest PHP Routine To Match Words

    - by Volomike
    What is the fastest way in PHP to take a keyword list and match it to a search result (like an array of titles) for all words? For instance, if my keyword phrase is "great leather shoes", then the following titles would be a match... Get Some Really Great Leather Shoes Leather Shoes Are Great Great Day! Those Are Some Cool Leather Shoes! Shoes, Made of Leather, Can Be Great ...while these would not be a match: Leather Shoes on Sale Today! You'll Love These Leather Shoes Greatly Great Shoes Don't Come Cheap I imagine there's some trick with array functions or a RegEx (Regular Expression) to achieve this rapidly.

    Read the article

  • Filter some words

    - by bob
    I want to filter some reserved word on my title form. $adtitle = sanitize($_POST['title']); $ignore = array('sale','buy','rent'); if(in_array($adtitle, $ignore)) { $_SESSION['ignore_error'] = '<strong>'.$adtitle.'</strong> cannot be use as your title'; header('Location:/submit/'); exit; How to make something like this. If user type Car for sale the sale will detected as reserved keyword. Now my current code only detect single keyword only.

    Read the article

  • How does the " is " operator work internally

    - by JDMX
    I want to compare the type of an object to a type to see if they are the same. I do not have the object, just the type of the object. I can do type1 == type2 and get general equality I can have a recursive loop where I repeat the above step for type1.BaseType until the BaseType is null. I can do type1.GetInterface( type2.FullName ) != null to check if type2 is an interface of type1 If I put it all together, I get if ( type2.IsInterface ) return type1.GetInterface( type2.FullName ) != null; while ( type1 != null ) { if ( type1 == type2 ) return true; type1 = type1.BaseType; } return false; Is that all the is keyword is. I cannot find the right keyword to plug into the Reflector search to find the function and a google search on "is" was not really helpful

    Read the article

< Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >