Search Results

Search found 1746 results on 70 pages for 'bom signature'.

Page 46/70 | < Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >

  • Haskell: writing the result of a computation to file

    - by peterwkc
    I have a function which creates a tuple after computation, but I would like to write it to file. I know how to write to a file using writeFile, but do not know how to combine the computation and monads IO together in the type signature. This is my code. invest :: ([Char]->Int->Int->([Char], Int) ) -> [Char]->Int->Int->([Char], Int) invest myinvest x y = myinvest x y myinvest :: [Char]->Int->Int->([Char], Int) myinvest w x y | y > 0 = (w, x + y) | otherwise = error "Invest amount must greater than zero" where I have a function which computes the maximum value from a list, but I want this function to receive input from a file, and then perform the computation of maximum value. maximuminvest :: (Ord a) => [a] -> a maximuminvest [] = error "Empty Invest Amount List" maximuminvest [x] = x maximuminvest (x:xs) | x > maxTail = x | otherwise = maxTail where maxTail = maximuminvest xs Please help. Thanks.

    Read the article

  • Why does a delegate with no parameters compile?

    - by Ryan
    I'm confused why this compiles: private delegate int MyDelegate(int p1, int p2); private void testDelegate() { MyDelegate imp = delegate { return 1; }; } MyDelegate should be a pointer to a method that takes two int parameters and returns another int, right? Why am I allowed to assign a method that takes no parameters? Interestingly, these doesn't compile (it complains about the signature mismatches, as I'd expect) private void testDelegate() { // Missing param MyDelegate imp = delegate(int p1) { return 1; }; // Wrong return type MyDelegate imp2 = delegate(int p1, int p2) { return "String"; }; } Thanks for any help! Ryan

    Read the article

  • pointer to const member function typedef

    - by oldcig
    I know it's possible to separate to create a pointer to member function like this struct K { void func() {} }; typedef void FuncType(); typedef FuncType K::* MemFuncType; MemFuncType pF = &K::func; Is there similar way to construct a pointer to a const function? I've tried adding const in various places with no success. I've played around with gcc some and if you do template deduction on something like template <typename Sig, typename Klass> void deduce(Sig Klass::*); It will show Sig with as a function signature with const just tacked on the end. If to do this in code it will complain that you can't have qualifiers on a function type. Seems like it should be possible somehow because the deduction works.

    Read the article

  • How and why is ap defined as liftM2 id in Haskell

    - by luke_randall
    Whilst trying to better understand Applicative, I looked at the definition of <*, which tends to be defined as ap, which in turn is defined as: ap :: (Monad m) => m (a -> b) -> m a -> m b ap = liftM2 id Looking at the type signatures for liftM2 and id, namely: liftM2 :: (Monad m) => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r id :: a -> a I fail to understand how just by passing in id, the relevant part of the type signature seems to transform from (a1 -> a2 -> r) -> m a1 to m (a -> b). What am I missing here?

    Read the article

  • .GIF re edit! Can't figure it out!!

    - by Adam C
    http://img227.imageshack.us/img227/1892/hatersgonna.gif That is the photo.. I am trying to cut around it so its a little smaller and make him walk the opposite direction. The reason I am doing this is for a VBulletin forum signature since it marquees left to right. I have tried editing the animation in Photoshop and I flipped the canvas to horizontal... I can't figure this out.. I've been at it for HOURS. hah Also if anyone can make it just a little darker that would be amazing. "no I'm not asking for free help" but any help would be great Thank you so much

    Read the article

  • Problems using jQuery $.ajax to pass data

    - by iboeno
    I'm using ASP.NET and attempting to call a method with a signature of [WebMethod] public static string GetInfo(string id){...} using the following javascript: var elementValue = $("#element").attr('id'); var d = "{id : " + elementValue + "}"; $.ajax({ type: "POST", url: "../WebPage.aspx/GetInfo", data: d, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { //do this } }); And this is not working. If instead I set elementValue = 2; it works fine. If I try to hardcode in a string value for testing purposes e.g. elementValue = "nameToLookUp"; It fails. Why is this happening, and how do I resolve it? On a side not, why is type: required to be POST instead of a GET? In the end I just want to pass a string value I want to look up in a DB and retrieving some json data.

    Read the article

  • MVC Model Binding to a collection where collection does not begin with a 0 index

    - by FloatLeft
    I'm trying to perform remote validation on a property of an item within a collection. The validation works OK on the first item of the collection. The http request to the validation method looks like: /Validation/IsImeiAvailable?ImeiGadgets[0].ImeiNumber=123456789012345 However on the 2nd item where the url looks like below, the validation doesn't work /Validation/IsImeiAvailable?ImeiGadgets[1].ImeiNumber=123456789012345 Now I'm pretty sure the reason for this, is that binding wont work on a collection that doesn't begin with a zero index. My validation method has a signature as below: public JsonResult IsImeiAvailable([Bind(Prefix = "ImeiGadgets")] Models.ViewModels.ImeiGadget[] imeiGadget) Because I'm passing an item within a collection I have to bind like this yet what I'm really passing is just a single value. Is there anyway I can deal with this other than just binding it as a plain old query string. Thanks Edit: This is the quick fix to get the Imei variable but I'd rather use the model binding: string imeiNumber = Request.Url.AbsoluteUri.Substring(Request.Url.AbsoluteUri.IndexOf("=")+1);

    Read the article

  • What is wrong with this simple type definition? (Expecting one more argument to...)

    - by fluteflute
    basic.hs: areaCircle :: Floating -> Floating areaCircle r = pi * r * r Command: *Main> :l basic.hs [1 of 1] Compiling Main ( Sheet1.hs, interpreted ) Sheet1.hs:2:15: Expecting one more argument to `Floating' In the type signature for `areaCircle': areaCircle :: Floating -> Floating Failed, modules loaded: none. I see that areaCircle :: Floating a => a -> a loads as expected. Why is the above version not acceptable?

    Read the article

  • Optional parameters for interfaces

    - by bryanjonker
    Using c# 4.0 -- building an interface and a class that implements the interface. I want to declare an optional parameter in the interface and have it be reflected in the class. So, I have the following: public interface IFoo { void Bar(int i, int j=0); } public class Foo { void Bar(int i, int j=0) { // do stuff } } This compiles, but it doesn't look right. The interface needs to have the optional parameters, because otherwise it doesn't reflect correctly in the interface method signature. Should I skip the optional parameter and just use a nullable type? Or will this work as intended with no side effects or consequences?

    Read the article

  • Python: How To copy function parameters into object's fields effortlessly ?

    - by bandana
    Many times I have member functions that copy parameters into object's fields. For Example: class NouveauRiches(object): def __init__(self, car, mansion, jet, bling): self.car = car self.mansion = mansion self.jet = jet self.bling = bling Is there a python language construct that would make the above code less tedious? One could use *args: def __init__(self, *args): self.car, self.mansion, self.jet, self.bling = args +: less tedious -: function signature not revealing enough. need to dive into function code to know how to use function -: does not raise a TypeError on call with wrong # of parameters (but does raise a ValueError) Any other ideas? (Whatever your suggestion, make sure the code calling the function does stays simple)

    Read the article

  • Right align text in an image with imagettftext(), PHP

    - by James Simpson
    I am setting up dynamic forum signature images for my users and I want to be able to put their username on the image. I am able to do this just fine, but since usernames are different lengths and I want to right align the username, how can I go about doing this when I have to set x & y coordinates. $im = imagecreatefromjpeg("/path/to/base/image.jpg"); $text = "Username"; $font = "Font.ttf"; $black = imagecolorallocate($im, 0, 0, 0); imagettftext($im, 10, 0, 217, 15, $black, $font, $text); imagejpeg($im, null, 90);

    Read the article

  • WebService Security

    - by LauzPT
    Hello, I'm developing an project, which consists in a webservice and a client application. It's a fair simple scenario. The webservice is connected to a database server, and the client consumes from the webserver in order to get information retrieved from the database. The thing is: 1. The client application can only display data after a previous authentication; 2. All the data transferred between Web Service and clients must be confidential; 3. Data integrity shouldn’t be compromised; I'm wondering what is the best way to achieve these requirements. The first thing I thought about, was sending the server a digital signature containing a client certificate, to be stored in the server, and used as comparison for authentication. But I investigated a little about webservice security, and I'm no longer certain that this is the best option. Can anyone give me an opinion about this? TIA

    Read the article

  • C# COM+ component isn't getting the constructor string

    - by Kyle W
    I've created a COM+ component in C# with a strong name, COM Visible, ProgId, etc... I've then registered the assembly with regasm, and imported it into the COM+ Applications in Component Services. It runs just fine, and loads up the DLL, except that the constructor string that is passed in is always empty. The method signature is protected override void Construct(string constructString), and it is being called before the method on the actual component. In the component details in COM+ Applications, the constructor string is checked and a value is entered. Any help is appreciated.

    Read the article

  • GAE datastore - count records between one minute ago and two minutes ago?

    - by Arthur Wulf White
    I am using GAE datastore with python and I want to count and display the number of records between two recent dates. for examples, how many records exist with a time signature between two minutes ago and three minutes ago in the datastore. Thank you. #!/usr/bin/env python import wsgiref.handlers from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.ext.webapp import template from datetime import datetime class Voice(db.Model): when = db.DateTimeProperty(auto_now_add=True) class MyHandler(webapp.RequestHandler): def get(self): voices = db.GqlQuery( 'SELECT * FROM Voice ' 'ORDER BY when DESC') values = { 'voices': voices } self.response.out.write(template.render('main.html', values)) def post(self): voice = Voice() voice.put() self.redirect('/') self.response.out.write('posted!') def main(): app = webapp.WSGIApplication([ (r'.*', MyHandler)], debug=True) wsgiref.handlers.CGIHandler().run(app) if __name__ == "__main__": main()

    Read the article

  • Why does Cache.Add return an object that represents the cached item?

    - by Pure.Krome
    From MSDN about the differences between Adding or Inserting an item the ASP.NET Cache: Note: The Add and Insert methods have the same signature, but there are subtle differences between them. First, calling the Add method returns an object that represents the cached item, while calling Insert does not. Second, their behavior is different if you call these methods and add an item to the Cache that is already stored there. The Insert method replaces the item, while the Add method fails. [emphasis mine] The second part is easy. No question about that. But with the first part, why would it want to return an object that represents the cached item? If I'm trying to Add an item to the cache, I already have/know what that item is? I don't get it. What is the reasoning behind this?

    Read the article

  • Alternatives to PropertyInfo.GetValue() for Mono?

    - by Trilok
    I have a method that has the following signature: private object GetNestedObject<y>(y objToAccess, string nestedObjectName) I'm using Reflection to get the nestedObject from the objToAccess and return it. This works well except it's really slow (I have to do this a few hundred thousand times). I came across HyperDescriptor, but since I'm running this on Linux, and Mono doesn't support TypeDescriptionProviders, I can't use it. Are there any alternatives to using getValue in this case? I could always hardcode in overrides for each type, but that is not desirable and would add a lot of maintenance overhead in my case.

    Read the article

  • Function template accepting nothing less than a bidirectional iterator or a pointer

    - by san
    I need a function template that accepts two iterators that could be pointers. If the two arguments are random_access iterators I want the return type to be an object of std::iterator<random_access_iterator_tag, ...> type else a std::iterator<bidirectional_iterator_tag, ...> type. I also want the code to refuse compilation if the arguments are neither a bidirectional iterator, nor a pointer. I cannot have dependency on third party libraries e.g. Boost Could you help me with the signature of this function so that it accepts bidirectional iterators as well as pointers, but not say input_iterator, output_iterator, forward_iterators. One partial solution I can think of is the following template<class T> T foo( T iter1, T iter2) { const T tmp1 = reverse_iterator<T>(iter1); const T tmp2 = reverse_iterator<T>(iter2); // do something } The idea is that if it is not bidirectional the compiler will not let me construct a reverse_iterator from it.

    Read the article

  • How do I marshal a pointer to an array of pointers to structures?

    - by Daniel Stutzbach
    I have a C function with the following signature: int my_function(int n, struct player **players) players is a pointer to an array of pointers to struct player objects. n is the number of pointers in the array. The function does not modify the array nor the contents of the structures, and it does not retain any pointers after returning. I tried the following: [DllImport("mylibary.dll")] static extern int my_function(int n, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] player_in []players); However, that marshals the data as a pointer to an array of structures, not a pointer to an array of pointers to structures.

    Read the article

  • C++ - checking if a class has a certain method at compile time

    - by jetwolf
    Here's a question for the C++ gurus out there. Is there a way to check at compile time where a type has a certain method, and do one thing if it does, and another thing if it doesn't? Basically, I have a template function template <typename T> void function(T t); and I it to behave a certain way if T has a method g(), and another way if it doesn't. Perhaps there is something that can be used together with boost's enable_if? Something like this: template <typename T> enable_if<has_method<T, g, void ()>, void>::type function(T t) { // Superior implementation calling t.g() } template <typename T> disable_if<has_method<T, g, void ()>, void>::type function(T t) { // Inferior implementation in the case where T doesn't have a method g() } "has_method" would be something that preferably checks both that T has a method named 'g', and that the method has the correct signature (in this case, void ()). Any ideas?

    Read the article

  • Bitmap.Save problems

    - by user284026
    Hello, can anyone tell me if you know to be a problem with Bitmap and steganography for WM 6? I am working on a project and i have to hide a digital signature in a bitmap. The algorithm works perfect, as in untill i have the image on the memory the bitmap contains the modified bytes. But after i save the image (Bitmap.Save()) and I reopen the image, than those bytes are lost. When i say lost i mean they are the orriginal bytes from when the picture was taken. Thank you.

    Read the article

  • A good way to implement useable Callbacks in C++

    - by Marcel J.
    I have a custom Menu class written in C++. To seperate the code into easy-to-read functions I am using Callbacks. Since I don't want to use Singletons for the Host of the Menu I provide another parameter (target) which will be given to the callback as the first parameter (some kind of workaround for the missing "this" reference). Registration-Signature AddItem(string s, void(*callback)(void*,MenuItem*), void* target = NULL) Example of a Registration menu->AddItem(TRANSLATE, "translate", &MyApp::OnModeSelected); Example of a Handler /* static */ void MyApp::OnModeSelected(void* that, MenuItem* item) { MyApp *self = (MyApp*)that; self->activeMode = item->text; } Is there anything one could consider dirty with this approach? Are there maybe better ones?

    Read the article

  • understanding syb boilerplate elimination

    - by Pradeep
    In the example given in http://web.archive.org/web/20080622204226/http://www.cs.vu.nl/boilerplate/ -- Increase salary by percentage increase :: Float -> Company -> Company increase k = everywhere (mkT (incS k)) -- "interesting" code for increase incS :: Float -> Salary -> Salary incS k (S s) = S (s * (1+k)) how come increase function compiles without binding anything for the first Company mentioned in its type signature. Is it something like assigning to a partial function? Why is it done like that?

    Read the article

  • Magento and unsetting a custom boolean attribute

    - by Spongeboy
    Hi, I've added an attribute to a customer address entity. Attribute setup code is as follows- 'entity_type_id'=>$customer_address_type_id, 'attribute_code'=>'signature_required', 'backend_type'=>'int', 'frontend_input'=>'boolean', 'frontend_label' => 'Signature required', 'is_global' => '1', 'is_visible' => '1', 'is_required' => '0', 'is_user_defined' => '0', I have then - added attribute to model\entity\setup.php added a HTML field on the edit form I am now getting the attribute saved to the database when the checkbox is checked. However, it is not being unset when checkbox is unchecked (I'm guessing due to checkbox input not being 'post'-ed if unchecked. What is the best way to uncheck this? Should I add a default value of 0? Or unset/delete the attribute before save in the controller? Should I add get/set methods to the model?

    Read the article

  • Action T synchronous and asynchronous

    - by raffaeu
    Hi everybody I have a contextmenustrip control that allows you to execute an action is two different flawours. Sync and Async. I am trying to covert everything using Generics so I did this: public class BaseContextMenu<T> : IContextMenu { private T executor ... public void Exec(Action<T> action){ action.Invoke(this.executor); } public void ExecAsync(Action<T> asyncAction){ ... } How I can write the async method in order to execute the generic action and 'do something' with the menu in the meanwhile? I saw that the signature of BeginInvoke is something like: asyncAction.BeginInvoke(thi.executor, IAsyncCallback, object);

    Read the article

  • Is there a design pattern for this ?

    - by ytrewq
    I have a component that needs to call a specific service depending on the input it receives. So my component has to look at the input and based on a configuration that says "for this input call this service with this data" needs to call the proper service. The services have a common signature method and a specific one (each). I thought about an abstract class that includes the signatures for all three methods. The implementation for the two services will override all three methods (throwing NotImplementedException for the methods that are not supported by current service). A component that could be initialized with a map (that for each input type will have the type of the service to be called) will also be defined. Do you have a better approach to cope this scenario ?

    Read the article

< Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >