Search Results

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

Page 27/164 | < Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >

  • Ruby on Rails: reducing complexity of parameters in a RESTFul HTTP POST request (multi-model)

    - by randombits
    I'm using cURL to test a RESTFul HTTP web service. The problem is I'm normally submitting a bunch of values normally like this: curl -d "firstname=bob&lastname=smith&age=25&from=kansas&someothermodelattr=val" -H "Content-Type: application/x-www-form-urlencoded" http://mysite/people.xml -i The problem with this is my controller will then have code like this: unless params[:firstname].nil? end unless params[:lastname].nil? end // FINALLY @person = People.new(params[:firstname], params[:lastname], params[:age], params[:from]) etc.. What's the best way to simplify this? My Person model has all the validations it needs. Is there a way (assuming the request has multi-model parameters) that I can just do: @person = People.new(params[:person]) and then the initializer can take care of the rest?

    Read the article

  • How to change ldap password using zend

    - by NAVEED
    I am working with zend framework, PHP , Ldap on Ubuntu. I am authenticating users from ldap using zend library. Now I want to change user's ldap passwords using zend. Any Idea? This is the method that I am using to get zend authentication adapter. It is working perfectly and users are authenticated using this adapter. public function getAuthAdapter(array $params) { $front = Zend_Controller_Front::getInstance(); $options = $front->getParam('bootstrap')->getOption('ldap'); $params['username'] = split( "@" , $params['username'] ); $username = 'cn=' . $params['username'][0] . ',' . $options['server1']['baseDn']; $adapter = new Zend_Auth_Adapter_Ldap( $options, $username, $params['password']); $adapter->setIdentity( $params['username'] ); $adapter->setCredential( $params['password'] ); return $adapter; } Now how to change ldap passwords? Thanks

    Read the article

  • Why can't I reclaim my dynamically allocated memory using the "delete" keyword?

    - by synaptik
    I have the following class: class Patient { public: Patient(int x); ~Patient(); private: int* RP; }; Patient::Patient(int x) { RP = new int [x]; } Patient::~Patient() { delete [] RP; } I create an instance of this class on the stack as follows: void f() { Patient p(10); } Now, when f() returns, I get a "double free or corruption" error, which signals to me that something is attempted to be deleted more than once. But I don't understand why that would be so. The space for the array is created on the heap, and just because the function from inside which the space was allocated returns, I wouldn't expect the space to be reclaimed. I thought that if I allocate space on the heap (using the new keyword), then the only way to reclaim that space is to use the delete keyword. Help! :)

    Read the article

  • best practice for passing many arguments to method ?

    - by Tony
    Occasionally , we have to write methods that receive many many arguments , for example : public void doSomething(Object objA , Object objectB ,Date date1 ,Date date2 ,String str1 ,String str2 ) { } When I encounter this kind of problem , I often encapsulate arguments into a map. Map<Object,Object> params = new HashMap<Object,Object>(); params.put("objA",ObjA) ; ...... public void doSomething(Map<Object,Object> params) { // extracting params Object objA = (Object)params.get("objA"); ...... } This is not a good practice , encapsulate params into a map is totally a waste of efficiency. The good thing is , the clean signature , easy to add other params with fewest modification . what's the best practice for this kind of problem ?

    Read the article

  • how to get http get request params in jsf 2.0 bakcing bean?

    - by Marko
    Hi all, I having trouble with passing http get parameters to jsf 2.0 backing bean. User will invoke URl with some params containing id of some entity, which is later used to persist some other entity in db. whole process can be summarized by fallowing: 1. user open page http://www.somhost.com/JsfApp/step-one.xhtml?sid=1 2. user fills some data and goes to next page 3. user fills some more data and then entity is saved to db with sid param from step one. I have session scoped backing bean that hold data from all the pages (steps), but I cant pass param to bean property.. any ideas?

    Read the article

  • Apache Shiro, INI-Configuration, Perms per URL: How to get URL params?

    - by Marcus Schultö
    I want to use Apache Shiro[1] in my JSF-Application to perform URL-based authorization checks, configuration done in shiro.ini As I see in the Shiro-documentation[2] there is a way to use a "perms"-filter /remoting/rpc/** = authc, perms["remote:invoke"] In my scenario I want this functionality, but on entity-level[3], where the entity-Id is in the http-request # "Open settings for user with id=123": # /user/settings.xhtml?user_id=123 /user/settings.xhtml = perms["user:update:XXX"] So, how do I do this with Shiro? How to I tell the perms-filter to check for http-params? Or is this supposed to be done in my Realm-Implemenation, concrete by calling FacesContext? [1] https://shiro.apache.org [2] https://shiro.apache.org/web.html#Web-webini [3] This can be done at least programmatically: SecurityUtils.getSubject().isPermitted("printer:query:lp7200") https://shiro.apache.org/permissions.html

    Read the article

  • Searching a keyword in a long string in mysql?

    - by user187580
    Hello keyword = house SELECT * FROM products WHERE description LIKE '%house%' This query also returns records having keyword, for example, courthouse, but I want to look for house only. How do I search anywhere in the description for "house" only? Thanks. UPDATE just for more clarification .. actually house, can be at - the start of the description .. "House for sale..", - can be quoted -- "house", 'house' - can have exclamation .. house!!!, house! - others - house? etc .. this is why I used %house%

    Read the article

  • How can I mix optional keyword arguments with the & rest stuff?

    - by Rayne
    I have a macro that takes a body: (defmacro blah [& body] (dostuffwithbody)) But I'd like to add an optional keyword argument to it as well, so when called it could look like either of these: (blah :specialthingy 0 body morebody lotsofbody) (blah body morebody lotsofboy) How can I do that? Note that I'm using Clojure 1.2, so I'm also using the new optional keyword argument destructuring stuff. I naively tried to do this: (defmacro blah [& {specialthingy :specialthingy} & body]) But obviously that didn't work out well. How can I accomplish this or something similar?

    Read the article

  • How do I set ORDER BY params using prepared PDO statement?

    - by Marlorn
    I'm having problems using params in the ORDER BY section of my SQL. It doesn't issue any warnings, but prints out nothing. $order = 'columnName'; $direction = 'ASC'; $stmt = $db->prepare("SELECT field from table WHERE column = :my_param ORDER BY :order :direction"); $stmt->bindParam(':my_param', $is_live, PDO::PARAM_STR); $stmt->bindParam(':order', $order, PDO::PARAM_STR); $stmt->bindParam(':direction', $direction, PDO::PARAM_STR); $stmt->execute(); The :my_param works, but not :order or :direction. Is it not being internally escaped correctly? Am I stuck inserting it directly in the SQL? Like so: $order = 'columnName'; $direction = 'ASC'; $stmt = $db->prepare("SELECT * from table WHERE is_live = :is_live ORDER BY $order $direction"); Is there a PDO::PARAM_COLUMN_NAME constant or some equivalent? Thanks!

    Read the article

  • Facebook FB.api post how to specify a target

    - by Laurent Luce
    I am using FB.api OpenGraph to post a message on the user's wall. I would like the link target to be equal to '_blank' so it opens in a new tab. Is it possible ? The Facebook documentation doesn't give much details. var params = {}; params['message'] = 'message'; params['name'] = 'name'; params['link'] = 'http://link'; params['picture'] = 'http://picture'; params['description'] = 'description'; FB.api('/me/feed', 'post', params, function(response) { if (!response || response.error) { alert('Error occured'); } else { alert('Post ID: ' + response); } });

    Read the article

  • Search multiple search engines with a single keyword at the same time in Chrome?

    - by cptloop
    I want to search multiple websites at once by using a keyword trigger in Google Chrome. I am trying to achieve this with Javascript as described in this topic over at mozillazine. This is the code that supposedly works in Firefox: javascript:void(window.open('http://www.google.com/search?q=%s'));void(window.open('http://www.altavista.com/web/results?q=%s')) I have tried to insert this code into the "URL with %s in place of query" but nothing happens when I invoke it. Is it possible to get this to work this way or another in Chrome?

    Read the article

  • How to convert non key, value java arguments to applet params? (args like -Xmx64m)

    - by bwizzy
    I'm trying to use xvpviewer (based on TightVNC) to VNC into my VMs running on Citirx XenServer. There are a couple of caveats required with trusting the certificate from XenServer which I've got working. Essentially I'm trying to convert the java command below (which works on the command line to launch VncViewer) for use in an applet that can be accessed via HTML page. java -Djavax.net.ssl.trustStore=/tmp/kimo.jks -Xmx64m -jar VncViewer.jar HOST "/console?ref=OpaqueRef:141f4204-2240-4627-69c6-a0c7d9898e6a&session_id=OpaqueRef:91a483c4-bc40-3bb0-121c-93f2f89acc3c" PORT 443 PROXYHOST1 192.168.0.5 PROXYPORT1 443 SocketFactory "HTTPSConnectSocketFactory" I know I can put the HOST, PORT etc arguments into param tags for the applet but I'm not sure how to apply the two initial argments.

    Read the article

  • C/PHP: How do I convert the following PHP JSON API script into a C plugin for apache?

    - by TeddyB
    I have a JSON API that I need to provide super fast access to my data through. The JSON API makes a simply query against the database based on the GET parameters provided. I've already optimized my database, so please don't recommend that as an answer. I'm using PHP-APC, which helps PHP by saving the bytecode, BUT - for a JSON API that is being called literally dozens of times per second (as indicated by my logs), I need to reduce the massive RAM consumption PHP is consuming ... as well as rewrite my JSON API in a language that execute much faster than PHP. My code is below. As you can see, is fairly straight forward. <?php define(ALLOWED_HTTP_REFERER, 'example.com'); if ( stristr($_SERVER['HTTP_REFERER'], ALLOWED_HTTP_REFERER) ) { try { $conn_str = DB . ':host=' . DB_HOST . ';dbname=' . DB_NAME; $dbh = new PDO($conn_str, DB_USERNAME, DB_PASSWORD); $params = array(); $sql = 'SELECT homes.home_id, address, city, state, zip FROM homes WHERE homes.display_status = true AND homes.geolat BETWEEN :geolatLowBound AND :geolatHighBound AND homes.geolng BETWEEN :geolngLowBound AND :geolngHighBound'; $params[':geolatLowBound'] = $_GET['geolatLowBound']; $params[':geolatHighBound'] = $_GET['geolatHighBound']; $params[':geolngLowBound'] =$_GET['geolngLowBound']; $params[':geolngHighBound'] = $_GET['geolngHighBound']; if ( isset($_GET['min_price']) && isset($_GET['max_price']) ) { $sql = $sql . ' AND homes.price BETWEEN :min_price AND :max_price '; $params[':min_price'] = $_GET['min_price']; $params[':max_price'] = $_GET['max_price']; } if ( isset($_GET['min_beds']) && isset($_GET['max_beds']) ) { $sql = $sql . ' AND homes.num_of_beds BETWEEN :min_beds AND :max_beds '; $params['min_beds'] = $_GET['min_beds']; $params['max_beds'] = $_GET['max_beds']; } if ( isset($_GET['min_sqft']) && isset($_GET['max_sqft']) ) { $sql = $sql . ' AND homes.sqft BETWEEN :min_sqft AND :max_sqft '; $params['min_sqft'] = $_GET['min_sqft']; $params['max_sqft'] = $_GET['max_sqft']; } $stmt = $dbh->prepare($sql); $stmt->execute($params); $result_set = $stmt->fetchAll(PDO::FETCH_ASSOC); /* output a JSON representation of the home listing data retrieved */ ob_start("ob_gzhandler"); // compress the output header('Content-type: text/javascript'); print "{'homes' : "; array_walk_recursive($result_set, "cleanOutputFromXSS"); print json_encode( $result_set ); print '}'; $dbh = null; } catch (PDOException $e) { die('Unable to retreive home listing information'); } } function cleanOutputFromXSS(&$value) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); } ?> How would I begin converting this PHP code over to C, since C is both better on memory management (since you do it yourself) and much, much faster to execute?

    Read the article

  • Google Chrome freezes for seconds

    - by Levan
    I do not know if this is the right place to write about google chrome or not so sorry if it is not after the update ,,Google Chrome 20.0.1132.47" google chrome started to lag ,,It gets stuck for couple of seconds and then it resumes" i think it starts lagging when i enter any flash site when i started chrome from the terminal it showed this before the update non of this appeared ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params ALSA lib pcm_dsnoop.c:623:(snd_pcm_dsnoop_open) unable to initialize slave ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params ALSA lib pcm_dsnoop.c:623:(snd_pcm_dsnoop_open) unable to initialize slave ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params ALSA lib pcm_dsnoop.c:623:(snd_pcm_dsnoop_open) unable to initialize slave ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params ALSA lib pcm_dsnoop.c:623:(snd_pcm_dsnoop_open) unable to initialize slave ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params ALSA lib pcm_dsnoop.c:623:(snd_pcm_dsnoop_open) unable to initialize slave ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params ALSA lib pcm_dsnoop.c:623:(snd_pcm_dsnoop_open) unable to initialize slave Firefox does not have any problem is there a way to fix this and thank you for your time

    Read the article

  • How do search engines handle hyphenated words?

    - by NinjaKC
    I am not sure my title fully explains what I mean. I thought this might be an interesting question. If I had a set of keywords, broken with a dash or 2, will search engines consider the dashed split keyword as maybe a full keyword? Say I have a site that sort of breaks words down, like the dictionary sites do. So a keyword for that page, might end up in the page, and / or the URL, as broken by dashes. Key-word = keyword Co-op-er-at-ive = cooperative Pho-to-gra-phy = Photography www.example.com/key-word/ www.example.com/co-op-er-at-ive/ www.example.com/pho-to-gra-phy/ I know search engines will consider a dash (at least Google) as a space, and understand it as multiple words. But in the English language, a dash can also break a word down (at least I think it can, can't it?), so will search engines also take this into consideration? I did a 'little' research, I Googled some words and placed random dashes, and it returned the words I searched for, but this could be considered a typo from the user on Google's search end, so really I am wondering if I can purposely put a dash in a keyword, and have the search engine spiders still catch that keyword as the real word without dashes? I've done a little Googling and looking here on Stackoverflow, but everything comes down to dashes for multiple words, not really the specific thing I'm trying to figure out. Hopefully that makes sense, I am not an expert in SEO, yet, but get the basics and have been playing, and this is just really a random question to satisfy my knowledge of playing :P

    Read the article

  • ASP.NET MVC Ajax.BeginForm eats params of submit button clicked. Looks like bug.

    - by RonnBlack
    If you are using Ajax.BeginForm() with multiple submit buttons similar to this: // View.aspx <% using (Ajax.BeginForm("Action", "Controller", new AjaxOptions { UpdateTargetId = "MyControl", })) { %> <span id="MyControl"> <% Html.RenderPartial("MyControl"); %> </span> <% } %> //MyControl.ascx <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <input name="prev" type="submit" value="prev" /> <input name="next" type="submit" value="next" /> //... Everything is submitted to the controller fine but the params for the submit button that was clicked are absent from the Request. In otherwords Request["next"] and Request["prev"] are always null. I looked in to the JavaScript in Microsoft.MvcAjax.js and it looks like the function Sys_Mvc_MvcHelpers$_serializeForm completely skips over the inputs that are of type 'submit'. This doesn't seem logical at all. How else can you find out what button has been clicked? It looks like a bug to me. Is there any logical reason to skip these form parameters?

    Read the article

  • pass ...rest to a NetConnection call

    - by dome
    I want to pass a rest in a netconnection call, something like this: public function requestData(service : String, ...params) : void { nc.call(service, params); } this doesn't work since the call is expecting each parameter to be separated by commas, like: nc.call(service, params[0], params[1], params[2]); I've read some posts about apply, but I can't find a solution for this specific case.

    Read the article

  • nginx subdomain rewrite

    - by ivan73
    I need a nginx rewrite rule to rewrite from: http://some-keyword.example.com to www. example.com/keyword.php?keyword=$some-keyword while domain without www in front still rewrites to www.example.com and 'www' isn't taken as a keyword. Please could you help me to solve this problem, how to write these two rules?

    Read the article

  • Working with nested models in ROR

    - by user487429
    Hi there, I'm trying to create an application where users can freely create shops and associated shop item for a specific shop is displayed when a show action is called but I seem to be doing something wrong. Any help here will be appreciated. I have attached shots of my code below. class ShopItem < ActiveRecord::Base belongs_to :shop def self.find_shop_items_for_sale find(:all, :order => "title", :conditions => ["shop_id = ?", @shop.id]) end end class Shop < ActiveRecord::Base has_many :shop_items end #Controllers class ShopsController < ApplicationController def new @shop = Shop.new end def create @shop = Shop.new(params[:shop]) @shop.user_id = current_user.id respond_to do |format| if @shop.save flash[:notice] = "Successfully created shop." format.html {redirect_to(all_shops_shops_url)} format.xml {render :xml => @shop, :status => :created, :location => @shop } else format.html {render :action => 'new'} format.xml { render :xml => @shop.errors, :status => :unprocessable_entity } end end end def show @shop = Shop.find(params[:id]) @shop_items = ShopItem.find_shop_items_for_sale @shop_cart = find_shop_cart end class ShopItemsController < ApplicationController def user @per_page ||= 5 @user = User.find(params[:id]) @shop_items = ShopItem.find(:all, :conditions=>["user_id = ?", @user.id], :order=>"id desc") end def show @shop_item = ShopItem.find(params[:id]) @shop = @shop_item.shop respond_to do |format| format.html # show.html.erb format.xml { render :xml => @shop_item } end end # GET /shop_items/new # GET /shop_items/new.xml def new @shop_item = ShopItem.new @shop = Shop.find(params[:id]) #@shop_items = ShopItem.paginate(:all, :condition=>["shop_id] = ?", @shop.id], :order=> "id desc", :page => params[:page],:per_page => @per_page) @shop_items = ShopItem.find(:all, :conditions=>["shop_id = ?", @shop.id], :order=> "id desc") @shop_item.shop_id = params[:id] respond_to do |format| format.html # new.html.erb format.xml { render :xml => @shop_item } end end # GET /shop_items/1/edit def edit @shop_item = ShopItem.find(params[:id]) end # POST /shop_items # POST /shop_items.xml def create @shop_item = ShopItem.new(params[:shop_item]) @shop_item.user_id = current_user.id respond_to do |format| if @shop_item.save flash[:notice] = 'Shop item was successfully created.' format.html { redirect_to(@shop_item) } format.xml { render :xml => @shop_item, :status => :created, :location => @shop_item } else @shop = Shop.find(@shop_item.shop_id) #@shop_items = ShopItem.paginate(:all, :condition =>["shop_id = ?", @shop.id], :order=> "id desc" , :page => params[:page], :per_page => @per_page) @shop_items = ShopItem.find(:all, :conditions =>["shop_id = ?", @shop.id], :order=> "id desc") format.html { render :action => "new" } format.xml { render :xml => @shop_item.errors, :status => :unprocessable_entity } end end end

    Read the article

  • Creating a good search solution

    - by Daniel
    I have an app where users have a role,a username,faculty and so on.When I'm looking for a list of users by their role or faculty or anything they have in common I can call (among others possible) @users = User.find_by_role(params[:role]) #or @users = User.find_by_shift(params[:shift]) So it keeps the system Class.find_by_property So the question is: What if at different points users lists should be generated based on different properties.I mean: I'm passing from different links params[:role] or params[:faculty] or params[:department] to my list action in my users controller.As I see it all has to be in that action,but which parameter should the search be made by?

    Read the article

  • How do I keep the keyword.url setting in firefox to default when you restart the browser without del

    - by user34801
    I am on the latest version of Firefox (not beta or anything like that) and currently my keyword.url is stuck on search.google.com (which I don't remember setting even though the about:config says it's a user setting. Can someone tell me how to set it back to default and keep it at default when I reset my browser? I do not want to delete prefs.js as I do not want to go thru setting up all the extension settings I have just to have my location bar search google (if this is the only way then I'll stick with searching from the search bar instead). I've checked all my extensions that may effect the location bar but could not find anything that says it would change the default search engine for this. I've also tried to open the prefs.js in wordpad or notepad but it just ends up freezing when trying to edit it at all (yes the browser is closed at the time). I also deleted the prefs-1.js (along with 2 others) that were older (after trying to rename those to prefs.js and see if this corrects it. It might have but had such old extension settings I went back to my latest prefs.js with this one issue instead of the issue of setting back up a ton of extensions. I can give any other info if needed, someone please help me fix this issue if possible.

    Read the article

  • How can I make keyword order more relevant in my search?

    - by Atomiton
    In my database, I have a keywords field that stores a comma-delimited list of keywords. For example, a Shrek doll might have the following keywords: ogre, green, plush, hero, boys' toys A "Beanie Baby" doll ( that happens to be an ogre ) might have: beanie baby, kids toys, beanbag toys, soft, infant, ogre (That's a completely contrived example.) What I'd like to do is if the consumer searches for "ogre" I'd like the "Shrek" doll to come up higher in the search results. My content administrator feels that if the keyword is earlier in the list, it should get a higher ranking. ( This makes sense to me and it makes it easy for me to let them control the search result relevance ). Here's a simplified query: SELECT p.ProductID AS ContentID , p.ProductName AS Title , p.ProductCode AS Subtitle , 100 AS Rank , p.ProductKeywords AS Keywords FROM Products AS p WHERE FREETEXT( p.ProductKeywords, @SearchPredicate ) I'm thinking something along the lines of replacing the RANK with: , 200 - INDEXOF(@SearchTerm) AS Rank This "should" rank the keyword results by their relevance I know INDEXOF isn't a SQL command... but it's something LIKE that I would like to accomplish. Am I approaching this the right way? Is it possible to do something like this? Does this make sense?

    Read the article

  • How am i overriding this C++ inherited member function without the virtual keyword being used?

    - by Gary Willoughby
    I have a small program to demonstrate simple inheritance. I am defining a Dog class which is derived from Mammal. Both classes share a simple member function called ToString(). How is Dog overriding the implementation in the Mammal class, when i'm not using the virtual keyword? (Do i even need to use the virtual keyword to override member functions?) mammal.h #ifndef MAMMAL_H_INCLUDED #define MAMMAL_H_INCLUDED #include <string> class Mammal { public: std::string ToString(); }; #endif // MAMMAL_H_INCLUDED mammal.cpp #include <string> #include "mammal.h" std::string Mammal::ToString() { return "I am a Mammal!"; } dog.h #ifndef DOG_H_INCLUDED #define DOG_H_INCLUDED #include <string> #include "mammal.h" class Dog : public Mammal { public: std::string ToString(); }; #endif // DOG_H_INCLUDED dog.cpp #include <string> #include "dog.h" std::string Dog::ToString() { return "I am a Dog!"; } main.cpp #include <iostream> #include "dog.h" using namespace std; int main() { Dog d; std::cout << d.ToString() << std::endl; return 0; } output I am a Dog! I'm using MingW on Windows via Code::Blocks.

    Read the article

< Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >