Search Results

Search found 6715 results on 269 pages for 'preg match'.

Page 167/269 | < Previous Page | 163 164 165 166 167 168 169 170 171 172 173 174  | Next Page >

  • Cheapest way of binding local variable to closure

    - by mmotorny
    I believe following to be a cheapest way of binding local variable to closure: void ByRValueReference(A&& a) { } std::function<void ()> CreateClosureByRValueReference() { A a; std::function<void ()> f = std::bind(&ByRValueReference, std::move(a)); // !!! return f; } However, it does not compile under Clang 3.1: error: no viable conversion from '__bind<void (*)(A &&), A>' to 'std::function<void ()>' and gcc 4.6.1: /usr/include/c++/4.6/functional:1778:2: error: no match for call to ‘(std::_Bind<void (*(A))(A&&)>) ()’ Am I violating the standard or it's just broken standard libraries?

    Read the article

  • Why is it that I cannot insert this into Django correctly?

    - by alex
    new_thing = MyTable(last_updated=datetime.datetime.now()) new_thing.save() >>>>select * from MyTable\G; last_updated: 2010-04-01 05:26:21 However, in my Python console...this is what it says... >>> print datetime.datetime.now() 2010-04-01 10:26:21.643041 So obviously it's off by 5 hours. By the way, the database uses "SYSTEM" as its time, so they should match perfectly. mysql> SELECT current_time; +--------------+ | current_time | +--------------+ | 10:30:16 | +--------------+ >>> print datetime.datetime.now() 2010-04-01 10:30:17.793040

    Read the article

  • Is it possible, with simple F# pattern matching transformations, to ignore unmatched values without

    - by Phobis
    So, I previously asked this question: http://stackoverflow.com/questions/2820234/can-someone-help-me-compare-using-f-over-c-in-this-specific-example-ip-address I was looking at the posted code and I was wondering if this code could be written without it producing a warning: let [|a;b;c;d|] = s.Split [|'.'|] IP(parseOrParts a, parseOrParts b, parseOrParts c, parseOrParts d) Is it possible to do something for the match _ pattern ot ignore? Without adding in something like Active Patterns? i want to keep the code as simple as possible... can I do this without drastically changing this code? NOTE: Warning is as follows Warning Incomplete pattern matches on this expression. For example, the value '[|_; _; _; _; _|]' may indicate a case not covered by the pattern(s).

    Read the article

  • Multiplying complex with constant in C++

    - by Atilla Filiz
    The following code fails to compile #include <iostream> #include <cmath> #include <complex> using namespace std; int main(void) { const double b=3; complex <double> i(0, 1), comp; comp = b*i; comp=3*i; return 0; } with error: no match for ‘operator*’ in ‘3 * i’ What is wrong here, why cannot I multiply with immediate constants?

    Read the article

  • Can I configure AutoMapper to read from custom column names when mapping from IDataReader?

    - by rohancragg
    Psuedo code for mapping configuration (as below) is not possible since the lambda only lets us access Type IDataReader, wheras when actually mapping, AutoMapper will reach into each "cell" of each IDataRecord while IDataReader.Read() == true: var mappingConfig = Mapper.CreateMap<IDataReader, IEnumerable<MyDTO>>(); mappingConfig.ForMember( destination => destination.???, options => options.MapFrom(source => source.???)); Can anyone think of a way to do this using AutoMapper configuration at runtime or just some other dynamic approach that meets the requirement below. The requirement is to support any incoming IDataReader which may have column names that don't match the property names of MyDTO and there is no naming convention I can rely on. Instead we'll ask the user at runtime to cross-reference the expected column names with the actual column names found in the IDataReader via IDataReader.GetSchemaTable().

    Read the article

  • Singelton on iPhone Simulator vs Singelton on real Device

    - by Helge Becker
    I am using a Singelton for some shared stuff. In the simulator, the app crashes ocasionally. Tracking the crash down shows that the the properties of my Singelton became dealocated. Those crashes never happend on a real device. Does the iPHone simulator handle memory managemend different? GC maybe? Changed the singelton to match this pattern. The iPhone Simulator dont crash now, but I am not sure about the memory handling on the real device. I assume that this solution will cause problems. What do you think?

    Read the article

  • Check if row already exists, if so tell the referenced table the id

    - by flhe
    Let's assume I have a table magazine: CREATE TABLE magazine ( magazine_id integer NOT NULL DEFAULT nextval(('public.magazine_magazine_id_seq'::text)::regclass), longname character varying(1000), shortname character varying(200), issn character varying(9), CONSTRAINT pk_magazine PRIMARY KEY (magazine_id) ); And another table issue: CREATE TABLE issue ( issue_id integer NOT NULL DEFAULT nextval(('public.issue_issue_id_seq'::text)::regclass), number integer, year integer, volume integer, fk_magazine_id integer, CONSTRAINT pk_issue PRIMARY KEY (issue_id), CONSTRAINT fk_magazine_id FOREIGN KEY (fk_magazine_id) REFERENCES magazine (magazine_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ); Current INSERTS: INSERT INTO magazine (longname,shotname,issn) VALUES ('a long name','ee','1111-2222'); INSERT INTO issue (fk_magazine_id,number,year,volume) VALUES (currval('magazine_magazine_id_seq'),'8','1982','6'); Now a row should only be inserted into 'magazine', if it does not already exist. However if it exists, the table 'issue' needs to get the 'magazine_id' of the row that already exists in order to establish the reference. How can i do this? Thx in advance!

    Read the article

  • jQuery select number of tags

    - by ninumedia
    I have multiple comment ids I want to reset to a default value. Ex: <a id="comments_inner_toggle_45">example 1</a> <a id="comments_inner_toggle_608">example 2</a> <a id="comments_inner_toggle_28">example 3</a> ... How can I write the correct tag in jQuery to select every tag with an id of "comments_inner_toggle_" and perform some operation on it? I think it's something similar to: $('a[id|=comments_inner_toggle_]').whatever This is wrong however because the code above will only match the tag with "comments_inner_toggle_" and not with a number appended at the end. How can I fix this? thanks for the help! :)

    Read the article

  • How do you write an idiomatic Scala Quicksort function?

    - by Don Mackenzie
    I recently answered a question with an attempt at writing a quicksort function in scala, I'd seen something like the code below written somewhere. def qsort(l: List[Int]): List[Int] = { l match { case Nil => Nil case pivot::tail => qsort(tail.filter(_ < pivot)) ::: pivot :: qsort(tail.filter(_ >= pivot)) } } My answer received some constructive criticism pointing out that List was a poor choice of collection for quicksort and secondly that the above wasn't tail recursive. I tried to re-write the above in a tail recursive manner but didn't have much luck. Is it possible to write a tail recursive quicksort? or, if not, how can it be done in a functional style? Also what can be done to maximise the efficiency of the implementation? Thanks in advance.

    Read the article

  • Latest 100 mentions - Twitter api

    - by laurens
    I'm looking to achieve the following: For a specific person, for example BarackObama, I'd like to get the last 100 times/tweets he was mentioned. Not his own tweets but the tweets of others containing @BarackObama. In the end I'd like to have: the person who mentioned, location, datetime. This content should be written to a flat file. I've been experimenting with the Twitter API and Python, with success but haven't yet succeeded achieving the above problem. I know there is a dev sections on the twitter website but they don't provide any example of code!! https://dev.twitter.com/docs/api/1/get/statuses/mentions count=100 .... For me the scripting language or way of doing is not relevant it's the result. I just read on the internet that python and Twitter api are a good match. Thanks a lot in advance!!

    Read the article

  • Avoid Spring ApllicationContext instanciation

    - by Ceddoc
    I use Spring 3 to make a simple configuration. I have an XML file called PropertyBeans.xml like that : <bean id="propertyBean" class="com.myapp.PropertyBean"> <property name="rootDirLogPath" value="C:\Users\dede" /> </bean> I have the bean which match this XML and then I want to use this bean with the value injected. Actually I have : ApplicationContext context = new ClassPathXmlApplicationContext("AppPropertyBeans.xml"); PropertyBean obj = (PropertyBean) context.getBean("propertyBean"); String rootDirLogPath = obj.getRootDirLogPath(); This works great but I want to know if there's a way to avoid the instantiation of ApplicationContext at each time I want to use a bean. I've heard about BeanFactory is that a good idea? Which are the others solutions? In other words: Am I supposed to called this Application context instanciation in every Controller in spring MVC?

    Read the article

  • How to compare multiple columns in excel?

    - by musicking123
    Hi i have two sheets having data like this sheet1 : **A** **B** **C** 752 A 752 E 752 N 984 G1 984 G2 4471 U1 4471 U2 4471 U4 4471 U5 4471 U7 4471 U8 sheet2: **A** **B** **C** 132 G 69092 227 G 29400 227 G1 2378 292 G 2088 426 G 14419 752 A 180829 752 E 719404 752 N 602180 1173 G 7361 1173 G1 13083 1619 US 108 5804 N 701 5804 SG 8 5819 CA 24 6333 AE 218 What i want is, i need compare sheet1 and sheet2 , if sheet1 A and B columns match with sheet2 's A and B columns then i want the value C (column in sheet2) to be placed in sheet1 column C. Please help me, i know how to compare only one column with other column by using vlookup, but here i want to compare two columns at a time. Thanks in advance

    Read the article

  • Kohana v2 - problem with routes

    - by yoda
    Hi, I'm attempting to set some custom routes in Kohana v2. What I'm looking for is some method that allow the system to : follow a pre-defined name to it's related root; redirect the non-matched url's into another controller; To give you a more clear view over the problem, I want the first url parameter to be associated to certain pages (contacts, home, services, about us, etc), and those urls who doesn't match the previous pages would be routed into a controller called products, in order to determine if the first url parameter regards a product name. Here's a sample of what I have : $config['_default'] = 'home'; $config['([a-zA-Z]+)'] = 'products/showcat/$1'; What am I missing here? Thanks in advance!

    Read the article

  • What data should I use to create an autofill "destination" field like Facebook or the Trip Advisor s

    - by sbar
    In order to create a “destination” auto filter input field on our website, I need a data source that provides a hierarchical data set of Region, Country, County/State, City and Town (plus an area like the Peak District National Park if at all possible) I know sites like Trip Advisor and Facebook seem to have very robust datasets for this. When you type, it brings up a match list with the hierarchy displayed (e.g. if you type Boston you get 6 results as there are multiply places called Boston – the hierarchy allows you to pick the correct option) There are many data sources out there but they either lack hierarchy or do not seem to be easily updatable or complete. I had expected this to be an easy task given the amount of site that have a destination or location autofill field. However, i cannot find a datasource or method that works. any help would be much appreciated. Tks,

    Read the article

  • Could not load file or assembly error even when reference has been removed

    - by twal
    Could not load file or assembly 'Payflow_dotNET_2.0' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) I tried to reference the payflow SDK and got this error.But I am no longer trying to reference it. I have removed all references to this dll. and Now I am just trying to get the project to start in VS but I still get this error. I am not trying to add the dll anymore.If i have removed the reference to this, why am I still getting this error? How can I remove anything else that may still be causing my program to look for this file? Thanks!

    Read the article

  • Problem with pattern matching in ocaml

    - by Antony
    I wrote the function used to decompose a Boolean function, the problem is that the compilation I get this : "Warning 5: this function application is partial, maybe some arguments are missing." How can I solve this problem? I've set wrong the patter matching or I can not run this operation with pattern matching The code is the following: let rec decomposition state_init state prec formula = match formula with And form -> (fun () -> let f1 = List.hd form in let f2 = And(List.tl form )in let new_state = Forms (state_init,f1) in decomposition state_init new_state state f1; decomposition state_init new_state state f2; Hashtbl.add graph new_state (("",false,state :: []) , []) ; let x = Hashtbl.find graph state in let succ = state :: snd x in let (desc,last,ptrs) = fst x in Hashtbl.replace graph state ( ("And-node",last,ptrs) , succ))

    Read the article

  • Rewrite all URL requests to https://www.example.com/$1

    - by xylar
    I have two domains, example.com and example.co.uk, that use the same application on my server. I would like to rewrite the address of the URL depending on what the user types in. The only URLs I want are https://www.example.com and https://www.example.co.uk In my .htaccess file I have the following: # Turn on URL rewriting RewriteEngine On RewriteCond %{HTTP_HOST} ^example\.co.uk$ [NC] RewriteRule ^(.*)$ https://www.example.co.uk/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] If I goto http://www.example.com it doesn't add the https, if I goto http://example.com it does. What is the best way of making the ReWriteCond match the www url?

    Read the article

  • How can I possibly sort this in JavaScript?

    - by orokusaki
    I've been pounding my head on the wall trying to figure out how to sort this in JavaScript (I have to work with it in this format unfortunately). I need to sort it based on Small, Medium, Large, XL, XXL (Small ranking the highest) in each variationValues size field. The problem is that I need to sort the variationCosts and variationInventories at the same time to match the new order (since each value in order corresponds to the values in the other fields :( Input I have to work with var m = { variationNames: ["Length", "Size" ], variationValues: [ ["26.5\"", "XXL"], ["25\"", "Large"], ["25\"", "Medium"], ["25\"", "Small"], ["25\"", "XL"], ["25\"", "XXL"], ["26.5\"", "Large"], ["26.5\"", "Small"], ["26.5\"", "XL"] ], variationCosts: [ 20.00, 20.00, 20.00, 20.00, 20.00, 20.00, 20.00, 20.00, 20.00 ], variationInventories: [ 10, 60, 51, 10, 15, 10, 60, 10, 15 ], parentCost: 20.00 }; Desired output var m = { variationNames: ["Length", "Size" ], variationValues: [ ["25\"", "Small"], ["26.5\"", "Small"], ["25\"", "Medium"], ["25\"", "Large"], ["26.5\"", "Large"], ["25\"", "XL"], ["26.5\"", "XL"] ["25\"", "XXL"], ["26.5\"", "XXL"], ], variationCosts: [ 20.00, 20.00, 20.00, 20.00, 20.00, 20.00, 20.00, 20.00, 20.00 ], variationInventories: [ 10, 10, 51, 60, 15, 15, 15, 10, 10 ], parentCost: 20.00 };

    Read the article

  • JOIN two tables to show already purchased items

    - by Norbert
    I have a table where I keep all my templates: templates template_id template_name template_price These templates can be purchased by a registered user and then are inserted in the payments table: payments payment_id template_id user_id Is there a way to join these two tables and get not just a list of templates that have been purchased by a certain user, but all the templates? And then figure out from there which ones have already been purchased? I used this SELECT, but only the ones that the user bought showed up. I would like to have all the rows from templates, but empty in case the user_id doesn't match. SELECT * FROM templates LEFT JOIN payments ON templates.template_id = payments.template_id WHERE user_id = 2 GROUP BY templates.template_id

    Read the article

  • Updating only .dll of a reference in my ASP.NET Application

    - by Mike C.
    Hello, I have a deployed web application project that references my Utility.dll class library. I want to make a change to the Utlity.dll and roll only that .dll out. The problem is that when I do that, I get the following error when I try to launch my site: Could not load file or assembly 'Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3766481cef20a9d1' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Is there a setting I can change so I don't have to roll out the entire web application project - only the Utlity.dll? Thanks!

    Read the article

  • Ajax JQuery responses order problem....

    - by Parhs
    Hello !!! I am searching 3 hours and didnt find anything.... i have this code which is called at an onChange event of an function group_changed(obj) { $.ajaxSetup({async:false}); $.post("/medilab/personnel/groups/getGroupRightsAjax",{ 'group.id': obj.options[obj.selectedIndex].value }, function(data){ $("#div_rights").html(data); }); } This works fine but if i set async:true sometimes the result doesnt match the selection... I guess that this is happening because some requests are lost or that the responses dont come in order..... Any idea what to do to keep it asynchronous?

    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

  • Subversion version 'difference' a big deal?

    - by CmdrTallen
    Greetings, using VS2008 and VisualSVN and seems the VisualSVN folks are religious about updating the client (and their VisualSVN server) to the latest Subversion release. My question is my subversion server is a hosted server and seems to always lag several versions behind the client I use. Should I be concerned about this version "mis-match"? Is there a general rule of thumb about when it is a point to be concerned (like an entire major release behind)? Any sort of mechanism build into either the client, the server or the protocol that prevents something horrible from happening between badly 'paired' clients and servers?

    Read the article

  • SELECT with a Replace()

    - by andyjohnson
    I have a table of names and addresses, which includes a postcode column. I want to strip the spaces from the postcodes and select any that match a particular pattern. I'm trying this (simplified a bit) in T-SQL on SQL Server 2005: SELECT Replace(Postcode, ' ', '') AS P FROM Contacts WHERE P LIKE 'NW101%' But I get the following error; Msg 207, Level 16, State 1, Line 3 Invalid column name 'P'. If I remove the WHERE clause I get a list of postcodes without spaces, which is what I want to search. How should I approach this? What am I doing wrong?

    Read the article

  • Reducing a normalized table to one value

    - by Dio
    Hello, I'm sure this has been asked but I'm not quite sure how to properly search for this question, my apologies. I have two tables, Foo and Bar. For has one row per Food, bar has many rows per food matching descriptors. Foo name id Apple 1 Orange 2 Bar id description 1 Tasty 1 Ripe 2 Sweet etc (sorry for the somewhat contrived example). I'm trying to return a query where if, for each row in Foo, Bar contains a descriptor in ('Tasty', 'Juicy') return true ex: Output Apple True Orange False I had been solving this somewhat trivially with a case when I only had one item to match select Foo.name, case bar.description when 'Tasty' then True else 'False' end from Foo left join Bar on foo.id = bar.id where bar.description = 'Tasty' But with multiple items, I keep ending up with extra rows: Output Apple True Apple False etc etc Can someone point me in the right direction on how to think about this problem or what I should be doing? Thank you.

    Read the article

< Previous Page | 163 164 165 166 167 168 169 170 171 172 173 174  | Next Page >