Search Results

Search found 1426 results on 58 pages for 'damien joe'.

Page 12/58 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Validate number of nested attributes

    - by Damien MATHIEU
    Hello, I have a model with nested attributes : class Foo < ActiveRecord::Base has_many :bar accepts_nested_attributes_for :bar end It works fine. However I'd want to be sure that for every Foo, I have at least two Bar. I can't access the bar_attributes in my validations so it seems I can't validate it. Is there any clean way to do so ?

    Read the article

  • Delete document with an empty ID

    - by Damien MATHIEU
    Hello, I have a CouchDB database in production. One of the documents has been edited (in Futon by an other developer). And it's lost it's ID (don't ask me how he did it). So now the document's id is an empty string, which makes it impossible to edit or delete via Futon. Is there a way I could hack into CouchDB to delete that document anyway ?

    Read the article

  • Control is set to false, jQuery selector fails

    - by Damien Joe
    Hi I have some controls on an asp.net modal which I show manually via code behind. Now I am trying to attach a selector on one of the controls inside pageLoad(), problem being is that the modal container is initially set to visible=false. I tried checking for length but it still throws exception if ($('#<%= myControl.ClientId %>').length > 0) { $('#<%= myControl.ClientID %>').click(function() { // Do work }); } Compiler Error Message: CS0103: The name 'myControl' does not exist in the current context

    Read the article

  • Is there a better way to write this repetitive event-declaration code in C# when implementing an int

    - by Damien Wildfire
    I have a lot of code like the following, where I explicitly implement some events required by an interface. public class IMicrowaveNotifier { event EventHandler<EventArgs> DoorClosed; event EventHandler<EventArgs> LightbulbOn; // ... } public class Microwave : IMicrowaveNotifier { private EventHandler<EventArgs> _doorClosed; event EventHandler<EventArgs> IMicrowaveNotifier.DoorClosed { add { lock (this) _doorClosed += value; } remove { lock (this) _doorClosed -= value; } } private EventHandler<EventArgs> _lightbulbOn; event EventHandler<EventArgs> IMicrowaveNotifier.LightbulbOn { add { lock (this) _lightbulbOn += value; } remove { lock (this) _lightbulbOn -= value; } } // ... } You can see that much of this is boilerplate. In Ruby I'd be able to do something like this: class Microwave has_events :door_closed, :lightbulb_on, ... end Is there a similar shorter way of removing this boilerplate in C#? Update: I left a very important part out of my example: namely, the events getting implemented are part of an interface, and I want to implement it explicitly. Sorry for not mentioning this earlier!

    Read the article

  • Enum : get the keys list

    - by Damien MATHIEU
    Hello, I'm not a java developer. But I'm currently taking a look at Android applications development so I'm doing a bit of nostalgy, doing some java again after not touching it for three years. I'm looking forward using the "google-api-translate-java" library. In which there is a Language class. It's an enum allowing to provide the language name and to get it's value for Google Translate. I can easily get all the values with : for (Language l : values()) { // Here I loop on one value } But what I'd want to get is a list of all the keys names (FRENCH, ENGLISH, ...). Is there something like a "keys()" method that'd allow me to loop through all the enum's keys ?

    Read the article

  • How to stop a Timer-X timer (jQuery)

    - by Damien K.
    I'm using Timer-X's timerDelayCall function in order to have a repeating rotator on my page, which starts automatically as the page loads: jQuery.timerDelayCall({ interval: 2000, repeat: true, callback: function(timer) { ... (my rotator logic here) } } }); The problem is that I'm trying to make a function that includes stopping that timer: function signUp() { ... (timer stop code here) } The documentation stats that timer.stop() does that, but however I format it, I get errors about it not being declared. I have tried every variation I can think of, such as: timer.stop(); jQuery.timer.stop(); $(document).timer.stop(); jQuery.timerDelayCall({ callback: function(timer) { timer.stop() } }); I'm sure I'm missing something simple - I come from a PHP background yet I'm new to javascript - but can't see what it is exactly. Help is much appreciated!

    Read the article

  • Updating a C# 2.0 events example to be idiomatic with C# 3.5?

    - by Damien Wildfire
    I have a short events example from .NET 2.0 that I've been using as a reference point for a while. We're now upgrading to 3.5, though, and I'm not clear on the most idiomatic way to do things. How would this simple events example get updated to reflect idioms that are now available in .NET 3.5? // Args class. public class TickArgs : EventArgs { private DateTime TimeNow; public DateTime Time { set { TimeNow = value; } get { return this.TimeNow; } } } // Producer class that generates events. public class Metronome { public event TickHandler Tick; public delegate void TickHandler(Metronome m, TickArgs e); public void Start() { while (true) { System.Threading.Thread.Sleep(3000); if (Tick != null) { TickArgs t = new TickArgs(); t.Time = DateTime.Now; Tick(this, t); } } } } // Consumer class that listens for events. public class Listener { public void Subscribe(Metronome m) { m.Tick += new Metronome.TickHandler(HeardIt); } private void HeardIt(Metronome m, TickArgs e) { System.Console.WriteLine("HEARD IT AT {0}",e.Time); } } // Example. public class Test { static void Main() { Metronome m = new Metronome(); Listener l = new Listener(); l.Subscribe(m); m.Start(); } }

    Read the article

  • Stopping jQuery Jumping to Newly Loaded Content.

    - by Damien
    I have a div with is replaced upon certain user actions. These actions are performed under the div that is being replaced and in the case that the div is too large to fit completely into the view window, along with the buttons used to change it underneath, the browser will jump to the top of the newly loaded div. Which is annoying. Does anyone know of a way to stop these? Cheers. Here is the jQuery code. ChartContent is a small blob of html function UpdateChartImage(ChartContent) { //do updates on div here var existingChart = $("#" + $(ChartContent).attr("id")); existingChart.fadeOut("fast", function() { existingChart.replaceWith(ChartContent); }).fadeIn("fast"); } Incidentally I have prevented the button from doing it's default behaviour so I don't think it's related to that.

    Read the article

  • Casting/dereferencing member variable pointer from void*, is this safe?

    - by Damien
    Hi all, I had a problem while hacking a bigger project so I made a simpel test case. If I'm not omitting something, my test code works fine, but maybe it works accidentally so I wanted to show it to you and ask if there are any pitfalls in this approach. I have an OutObj which has a member variable (pointer) InObj. InObj has a member function. I send the address of this member variable object (InObj) to a callback function as void*. The type of this object never changes so inside the callback I recast to its original type and call the aFunc member function in it. In this exampel it works as expected, but in the project I'm working on it doesn't. So I might be omitting something or maybe there is a pitfall here and this works accidentally. Any comments? Thanks a lot in advance. (The problem I have in my original code is that InObj.data is garbage). #include <stdio.h> class InObj { public: int data; InObj(int argData); void aFunc() { printf("Inside aFunc! data is: %d\n", data); }; }; InObj::InObj(int argData) { data = argData; } class OutObj { public: InObj* objPtr; OutObj(int data); ~OutObj(); }; OutObj::OutObj(int data) { objPtr = new InObj(data); } OutObj::~OutObj() { delete objPtr; } void callback(void* context) { ((InObj*)context)->aFunc(); } int main () { OutObj a(42); callback((void*)a.objPtr); }

    Read the article

  • Is this a good way to generically deserialize objects?

    - by Damien Wildfire
    I have a stream onto which serialized objects representing messages are dumped periodically. The objects are one of a very limited number of types, and other than the actual sequence of bytes that arrives, I have no way of knowing what type of message it is. I would like to simply try to deserialize it as an object of a particular type, and if an exception is thrown, try again with the next type. I have an interface that looks like this: public interface IMessageHandler<T> where T : class, IMessage { T Handle(string message); } // elsewhere: // (These are all xsd.exe-generated classes from an XML schema.) public class AppleMessage : IMessage { ... } public class BananaMessage : IMessage { ... } public class CoconutMessage : IMessage { ... } Then I wrote a GenericHandler<T> that looks like this: public class GenericHandler<T> : IMessageHandler<T> where T: class, IMessage { public class MessageHandler : IMessageHandler { T IMessageHandler.Handle(string message) { T result = default(T); try { // This utility method tries to deserialize the object with an // XmlSerializer as if it were an object of type T. result = Utils.SerializationHelper.Deserialize<T>(message); } catch (InvalidCastException e) { result = default(T); } return result; } } } Two questions: Using my GenericHandler<T> (or something similar to it), I'd now like to populate a collection with handlers that each handle a different type. Then I want to invoke each handler's Handle method on a particular message to see if it can be deserialized. If I get a null result, move onto the next handler; otherwise, the message has been deserialized. Can this be done? Is there a better way to deserialize data of unknown (but restricted) type?

    Read the article

  • Continuously reading from a stream in C#?

    - by Damien Wildfire
    I have a Stream object that occasionally gets some data on it, but at unpredictable intervals. Messages that appear on the Stream are well-defined and declare the size of their payload in advance (the size is a 16-bit integer contained in the first two bytes of each message). I'd like to have a StreamWatcher class which detects when the Stream has some data on it. Once it does, I'd like an event to be raised so that a subscribed StreamProcessor instance can process the new message. Can this be done with C# events without using Threads directly? It seems like it should be straightforward, but I can't get quite get my head around the right way to design this.

    Read the article

  • Trying to reconcile global ip address and Vhosts

    - by puk
    I have been using my local machine as a web server for a while, and I have several websites set up locally on my machine, all with similar Vhost files like the one seen here /etc/apache2/sites-available/john.smith.com: <VirtualHost *:80> RewriteEngine on RewriteOptions Inherit ServerAdmin [email protected] ServerName john.smith.com ServerAlias www.john.smith.com DocumentRoot /home/john/smith # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost CustomLog /var/log/apache2/access.log comonvhost </VirtualHost> then I set up the /etc/hosts file like so for every Vhost: 192.168.1.100 www.john.smith.com john.smith.com 192.168.1.100 www.jane.smith.com jane.smith.com 192.168.1.100 www.joe.smith.com joe.smith.com 192.168.1.100 www.jimbob.smith.com jimbob.smith.com Now I am hosting my friend's website until he gets a permanent domain. I have port forwarding set up to redirect port 80 to my machine, but I don't understand how the global ip fits into all of this. Do I for example use the following web site addresses (assume global ip is 12.34.56.789): 12.34.56.789.john.smith 12.34.56.789.jane.smith 12.34.56.789.joe.smith 12.34.56.789.jimbob.smith

    Read the article

  • Asyncronus javascript rendering widgets

    - by Joe J
    Hey all, I'm creating a javascript widget so third partys (web designers) can post a link on their website and it will render the widget on their site. Currently, I'm doing this with just a script link tag: <div class="some_random_div_in_html_body"> <script type='text/javascript' src='http://remotehost.com/link/to/widget.js'></script> </div> However, this has the side-effect of slowing down a thrid party's website render times of the page if my site is under a load. Therefore, I'd like the third party website to request the widget link from my site asyncronously and then render it on their site when the widget link loads completely. The Google Analytics javascript snippet seems to have a nice bit of asyncronous code that does a nice async request to model off of, but I'm wondering if I can modify it so that it will render content on the third party's site. Using the example below, I want the content of http://mysite.com/link/to/widget.js to render something in the "message" id field. <HTML> <HEAD><TITLE>Third Party Site</TITLE><STYLE>#message { background-color: #eee; } </STYLE></HEAD> <BODY> <div id="message">asdf</div> <script type="text/javascript"> (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = 'http://mysite.com/link/to/widget.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </BODY> </HTML> I don't know if what I'm trying to do constitutes Cross Site Scripting (still a bit vague on that concept) but am wondering if what I'm trying to do is possible. Or if anyone has any other approaches to creating javascript widgets effectively, I'd appreciate any advice. Thanks for reading this. Joe

    Read the article

  • Using dynamic parameters in email publisher subjectSettings block with CruiseControl.Net

    - by Joe
    I am trying to get dynamic parameters to be used in the email publisher's subjectSettings block. For example, <project> ... <parameters> <textParameter> <name>version</name> <display>Version to install</display> <description>The version to install.</description> <required>true</required> </textParameter> </parameters> <tasks> ... </tasks> <publishers> .... <email includeDetails="TRUE"> <from>buildmaster</from> <mailhost>localhost</mailhost> <users> <user name="Joe" group="buildmaster" address="jdavies" /> </users> <groups> <group name="buildmaster"> <notifications> <notificationType>Always</notificationType> </notifications> </group> <group name="users"> <notifications> <notificationType>Success</notificationType> <notificationType>Fixed</notificationType> </notifications> </group> </groups> <subjectSettings> <subject buildResult="Success" value="Version ${version} installed." /> <subject buildResult="Fixed" value="Version ${version} fixed and installed." /> </subjectSettings> <modifierNotificationTypes> <notificationType>Success</notificationType> </modifierNotificationTypes> </email> </project> I have tried using ${version} and $[version]. When I use $[version], the entire subject line is empty! Are dynamic parameters supported in this case, and if so, what am I doing wrong?

    Read the article

  • LINQ to SQL select distinct from multiple colums

    - by Morron
    Hi, I'm using LINQ to SQL to select some columns from one table. I want to get rid of the duplicate result also. Dim customer = (From cus In db.Customers Select cus.CustomerId, cus.CustomerName).Distinct Result: 1 David 2 James 1 David 3 Smith 2 James 5 Joe Wanted result: 1 David 2 James 3 Smith 5 Joe Can anyone show me how to get the wanted result? Thanks.

    Read the article

  • Searching 2 fields at the same time

    - by donpal
    I have a table of first and last names firstname lastname --------- --------- Joe Robertson Sally Robert Jim Green Sandra Jordan I'm trying to search this table based on an input that consists of the full name. For example: input: Joe Robert I thought about using SELECT * FROM tablename WHERE firstname LIKE BUT the table stores the first and last name separately, so I'm not sure how to do the search in this case

    Read the article

  • SQL help on a name dilemma

    - by Ardman
    I have a column which has surname and firstname plus salutation in. e.g. Bloggs,Joe,Mr I need to break this out into Bloggs Joe Mr as 3 seperate columns. Any ideas appreciated. How, the other thing is I won't know how many commas are in the initial column.

    Read the article

  • C Programming - My program is good enough for my assignment but I know its not good

    - by Joe
    Hi there I'm just starting an assignment for uni and it's raised a question for me. I don't understand how to return a string from a function without having a memory leak. char* trim(char* line) { int start = 0; int end = strlen(line) - 1; /* find the start position of the string */ while(isspace(line[start]) != 0) { start++; } //printf("start is %d\n", start); /* find the position end of the string */ while(isspace(line[end]) != 0) { end--; } //printf("end is %d\n", end); /* calculate string length and add 1 for the sentinel */ int len = end - start + 2; /* initialise char array to len and read in characters */ int i; char* trimmed = calloc(sizeof(char), len); for(i = 0; i < (len - 1); i++) { trimmed[i] = line[start + i]; } trimmed[len - 1] = '\0'; return trimmed; } as you can see I am returning a pointer to char which is an array. I found that if I tried to make the 'trimmed' array by something like: char trimmed[len]; then the compiler would throw up a message saying that a constant was expected on this line. I assume this meant that for some reason you can't use variables as the array length when initialising an array, although something tells me that can't be right. So instead I made my array by allocating some memory to a char pointer. I understand that this function is probably waaaaay sub-optimal for what it is trying to do, but what I really want to know is: 1. Can you normally initialise an array using a variable to declare the length like: char trimmed[len]; ? 2. If I had an array that was of that type (char trimmed[]) would it have the same return type as a pointer to char (ie char*). 3. If I make my array by callocing some memory and allocating it to a char pointer, how do I free this memory. It seems to me that once I have returned this array, I can't access it to free it as it is a local variable. Many thanks in advance Joe

    Read the article

  • How to specify the order of XmlAttributes, using XmlSerializer

    - by demoncodemonkey
    XmlElement has an "Order" attribute which you can use to specify the precise order of your properties (in relation to each other anyway) when serializing using XmlSerializer. Is there a similar thing for XmlAttribute? I just want to set the order of the attributes from something like <MyType end="bob" start="joe" /> to <MyType start="joe" end="bob" /> This is just for readability, my own benefit really.

    Read the article

  • Convert json data to javascript array - in multi-dimensional sense

    - by AW-GWTF899
    I have a json array say { "People": { "Person": [ {"FirstName": "John", "LastName": "Smith"} {"FirstName": "Joe", "LastName": "Bloggs"} {"FirstName": "Wendy", "LastName": "Deng"} ] } } And I want to convert this into a javascript array (something like this) var persons = [ ["FirstName", "John", "LastName", "Smith"], ["FirstName", "Joe", "LastName", "Bloggs"], ["FirstName", "Wendy", "LastName": "Deng"] ]; How do I accomplish this? Hope my question makes sense and I realise the javascript array initialization may not be the correct way to put it. Thanks.

    Read the article

  • Create a binary indicator matrix in R

    - by Brian Vanover
    I have a list of data indicating attendance to conferences like this: Event Participant ConferenceA John ConferenceA Joe ConferenceA Mary ConferenceB John ConferenceB Ted ConferenceC Jessica I would like to create a binary indicator attendance matrix of the following format: Event John Joe Mary Ted Jessica ConferenceA 1 1 1 0 0 ConferenceB 1 0 0 1 0 ConferenceC 0 0 0 0 1 Is there a way to do this in R? Sorry for the poor formatting.

    Read the article

  • SQL Reset Identity ID in already populated table

    - by rockinthesixstring
    hey all. I have a table in my DB that has about a thousand records in it. I would like to reset the identity column so that all of the ID's are sequential again. I was looking at this but I'm ASSuming that it only works on an empty table Current Table ID | Name 1 Joe 2 Phil 5 Jan 88 Rob Desired Table ID | Name 1 Joe 2 Phil 3 Jan 4 Rob Thanks in advance

    Read the article

  • Cucumber Failing with Nokogiri

    - by Paul
    I just started using Cucumber and in the simplest of scenarios I throw the following error: undefined method has_key?' for #<Nokogiri::XML::Element:0x10677a400> (NoMethodError) ./features/step_definitions/web_steps.rb:36:in/^(?:|I )fill in "([^"])" with "([^"])"$/' features/authentication.feature:9:in `When I fill in "user_name" with "Joe User"' The Scenario is as follows... Scenario: Signup Given I go to the signup page When I fill in "user_name" with "Joe User" Is this a problem in the Scenario, Cucumber, or Nokogiri? Any Solutions?

    Read the article

  • javascript simple object creation test: opera leaks?

    - by joe
    Hi, I am trying to figure out certain memory leak conditions in javascript on a few browsers. Currently I'm only testing FF 3.6, Opera 10.10, and Safari 4.0.3. I've started with a fairly simple test, and can confirm no memory leaks in Firefox and Safari. But Opera just takes memory and never gives it back. What gives? Here's the test: <html> <head> <script type="text/javascript"> window.onload = init; //window.onunload = cleanup; var a=[]; function init() { var d = document.createElement('div'); d.innerHTML = "page loading..."; document.body.appendChild(d); for (var i=0; i<400000; i++) { a[i] = new Obj("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); } d.innerHTML = "PAGE LOADED"; } function cleanup() { for (var i=0; i<400000; i++) { a[i] = null; } } function Obj(msg) { this.msg=msg; } </script> </head> <body> </body> </html> I shouldn't need the cleanup() call on window.unload, but tried that also. No luck. As you can see this is simple JS, no circular DOM links, no closures. I monitor the memory usage using 'top' on Mac 10.4.11. Memory usage spikes up on page load, as expected. In FF and Safari reloading the page does not use any further memory, and all memory is returned when the window (tab) is closed. In Opera, memory spikes on load, and seems to also spike further on each reload (but not always...). But regardless of reload, memory never goes back down below the initial load spike. I had hoped this was a no-brainer test that all browsers would pass, so I could move on to more "interesting" conditions. Am I doing something wrong here? Or is this a known Opera issue? Thanks! -joe

    Read the article

  • c++, object life-time of anonymous (unnamed) variables

    - by Joe Steeve
    In the following code, the object constructed in the last line of 'main()', seems to be destroyed before the end of the expression. The destructor is called before the '<<' is executed. Is this how it is supposed to be? #include <string> #include <sstream> #include <iostream> using std::string; using std::ostringstream; using std::cout; class A : public ostringstream { public: A () {} virtual ~A () { string s; s = str(); cout << "from A: " << s << std::endl; } }; int main () { string s = "Hello"; A os; os << s; cout << os.str() << std::endl; A() << "checking this"; } This is the output: Hello from A: 0x80495f7 from A: Hello This is the gdb log: (gdb) b os.cxx : 18 Breakpoint 1 at 0x80492b1: file os.cxx, line 18. (2 locations) (gdb) r Starting program: /home/joe/sandbox/test/os Hello Breakpoint 1, ~A (this=0xbffff37c, __in_chrg=<value optimized out>, __vtt_parm=<value optimized out>) at os.cxx:18 18 cout << "from A: " << s << std::endl; (gdb) p s.c_str () $1 = 0x804b45c "0x80495f7" (gdb) p *s.c_str () $2 = 48 '0' (gdb) c Continuing. from A: 0x80495f7 Breakpoint 1, ~A (this=0xbffff2bc, __in_chrg=<value optimized out>, __vtt_parm=<value optimized out>) at os.cxx:18 18 cout << "from A: " << s << std::endl; (gdb) p s.c_str () $3 = 0x804b244 "Hello" (gdb) p *s.c_str () $4 = 72 'H' (gdb) c Continuing. from A: Hello Program exited normally. (gdb)

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >