Daily Archives

Articles indexed Wednesday April 7 2010

Page 9/131 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Help installing delayed_job

    - by Mike
    I'm trying to use collectiveidea's delayed_job gem The installation instructions include Rake tasks are not automatically loaded from gems, so you’ll need to add the following to your Rakefile: begin require 'delayed/tasks' rescue LoadError STDERR.puts "Run `rake gems:install` to install delayed_job" end Where is my Rakefile? And what is a Rakefile?

    Read the article

  • using LIKE with logical operators

    - by ryanthegecko
    i can't seem to figure out how to combine LIKE with an OR or AND: DELETE * FROM persons WHERE FirstName = 'Abe' AND LastName LIKE '%coln'; Looks like it should owrk to me but I get error 1064 (syntax0 Is there a correct way to do this?

    Read the article

  • Stats/Monitor/Inspector for beanstalkd

    - by Tim Lytle
    Does anyone know of an app that can monitor a beanstalkd queue? I'm looking for something that shows stats on tubes and jobs, and allows you to inspect the details. I'm not really picky about language/platform, just want to know if there's something out there before I write my own.

    Read the article

  • Overloading operator>> to a char buffer in C++ - can I tell the stream length?

    - by exscape
    I'm on a custom C++ crash course. I've known the basics for many years, but I'm currently trying to refresh my memory and learn more. To that end, as my second task (after writing a stack class based on linked lists), I'm writing my own string class. It's gone pretty smoothly until now; I want to overload operator that I can do stuff like cin my_string;. The problem is that I don't know how to read the istream properly (or perhaps the problem is that I don't know streams...). I tried a while (!stream.eof()) loop that .read()s 128 bytes at a time, but as one might expect, it stops only on EOF. I want it to read to a newline, like you get with cin to a std::string. My string class has an alloc(size_t new_size) function that (re)allocates memory, and an append(const char *) function that does that part, but I obviously need to know the amount of memory to allocate before I can write to the buffer. Any advice on how to implement this? I tried getting the istream length with seekg() and tellg(), to no avail (it returns -1), and as I said looping until EOF (doesn't stop reading at a newline) reading one chunk at a time.

    Read the article

  • OSX: Why is GetProcessInformation() causing a segfault?

    - by anthony
    Here's my C method to get the pid of the Finder process. GetProcessInformation() is causing a segfault. Why? Here's the function: static OSStatus GetFinderPID(pid_t *pid) { ProcessSerialNumber psn = {kNoProcess, kNoProcess}; ProcessInfoRec info; OSStatus status = noErr; info.processInfoLength = sizeof(ProcessInfoRec); info.processName = nil; while (!status) { status = GetNextProcess(&psn); if (!status) { status = GetProcessInformation(&psn, &info); } if (!status && info.processType == 'FNDR' && info.processSignature == 'MACS') { return GetProcessPID(&psn, pid); } } return status; } Here's the backtrace: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000032aaaba7 0x00007fffffe00623 in __bzero () (gdb) bt #0 0x00007fffffe00623 in __bzero () #1 0x00007fff833adaed in CreateFSRef () #2 0x00007fff833ab53b in FSPathMakeRefInternal () #3 0x00007fff852fc32d in _CFGetFSRefFromURL () #4 0x00007fff852fbfe0 in CFURLGetFSRef () #5 0x00007fff85dd273f in GetProcessInformation () #6 0x0000000100000bef in GetFinderPID [inlined] () at /path/to/main.c:21

    Read the article

  • PHP ORMs: Doctrine vs. Propel

    - by Tom
    Hi, I'm starting a new project with symfony which is readily integrated with Doctrine and Propel, but I of course need to make a choice.... I was wondering if more experienced people out there have general pros and/or cons for going with either of these two? Thanks a lot. EDIT: Thanks for the all the responses, useful stuff. There's no truly correct answer to this question so I'll just mark as approved the one that got the most popular up-votes.

    Read the article

  • Grafting LINQ onto C# 2 library

    - by P Daddy
    I'm writing a data access layer. It will have C# 2 and C# 3 clients, so I'm compiling against the 2.0 framework. Although encouraging the use of stored procedures, I'm still trying to provide a fairly complete ability to perform ad-hoc queries. I have this working fairly well, already. For the convenience of C# 3 clients, I'm trying to provide as much compatibility with LINQ query syntax as I can. Jon Skeet noticed that LINQ query expressions are duck typed, so I don't have to have an IQueryable and IQueryProvider (or IEnumerable<T>) to use them. I just have to provide methods with the correct signatures. So I got Select, Where, OrderBy, OrderByDescending, ThenBy, and ThenByDescending working. Where I need help are with Join and GroupJoin. I've got them working, but only for one join. A brief compilable example of what I have is this: // .NET 2.0 doesn't define the Func<...> delegates, so let's define some workalikes delegate TResult FakeFunc<T, TResult>(T arg); delegate TResult FakeFunc<T1, T2, TResult>(T1 arg1, T2 arg2); abstract class Projection{ public static Condition operator==(Projection a, Projection b){ return new EqualsCondition(a, b); } public static Condition operator!=(Projection a, Projection b){ throw new NotImplementedException(); } } class ColumnProjection : Projection{ readonly Table table; readonly string columnName; public ColumnProjection(Table table, string columnName){ this.table = table; this.columnName = columnName; } } abstract class Condition{} class EqualsCondition : Condition{ readonly Projection a; readonly Projection b; public EqualsCondition(Projection a, Projection b){ this.a = a; this.b = b; } } class TableView{ readonly Table table; readonly Projection[] projections; public TableView(Table table, Projection[] projections){ this.table = table; this.projections = projections; } } class Table{ public Projection this[string columnName]{ get{return new ColumnProjection(this, columnName);} } public TableView Select(params Projection[] projections){ return new TableView(this, projections); } public TableView Select(FakeFunc<Table, Projection[]> projections){ return new TableView(this, projections(this)); } public Table Join(Table other, Condition condition){ return new JoinedTable(this, other, condition); } public TableView Join(Table inner, FakeFunc<Table, Projection> outerKeySelector, FakeFunc<Table, Projection> innerKeySelector, FakeFunc<Table, Table, Projection[]> resultSelector){ Table join = new JoinedTable(this, inner, new EqualsCondition(outerKeySelector(this), innerKeySelector(inner))); return join.Select(resultSelector(this, inner)); } } class JoinedTable : Table{ readonly Table left; readonly Table right; readonly Condition condition; public JoinedTable(Table left, Table right, Condition condition){ this.left = left; this.right = right; this.condition = condition; } } This allows me to use a fairly decent syntax in C# 2: Table table1 = new Table(); Table table2 = new Table(); TableView result = table1 .Join(table2, table1["ID"] == table2["ID"]) .Select(table1["ID"], table2["Description"]); But an even nicer syntax in C# 3: TableView result = from t1 in table1 join t2 in table2 on t1["ID"] equals t2["ID"] select new[]{t1["ID"], t2["Description"]}; This works well and gives me identical results to the first case. The problem is if I want to join in a third table. TableView result = from t1 in table1 join t2 in table2 on t1["ID"] equals t2["ID"] join t3 in table3 on t1["ID"] equals t3["ID"] select new[]{t1["ID"], t2["Description"], t3["Foo"]}; Now I get an error (Cannot implicitly convert type 'AnonymousType#1' to 'Projection[]'), presumably because the second join is trying to join the third table to an anonymous type containing the first two tables. This anonymous type, of course, doesn't have a Join method. Any hints on how I can do this?

    Read the article

  • Overloading *(iterator + n) and *(n + iterator) in a C++ iterator class?

    - by exscape
    (Note: I'm writing this project for learning only; comments about it being redundant are... uh, redundant. ;) I'm trying to implement a random access iterator, but I've found very little literature on the subject, so I'm going by trial and error combined with Wikpedias list of operator overload prototypes. It's worked well enough so far, but I've hit a snag. Code such as exscape::string::iterator i = string_instance.begin(); std::cout << *i << std::endl; works, and prints the first character of the string. However, *(i + 1) doesn't work, and neither does *(1 + i). My full implementation would obviously be a bit too much, but here's the gist of it: namespace exscape { class string { friend class iterator; ... public: class iterator : public std::iterator<std::random_access_iterator_tag, char> { ... char &operator*(void) { return *p; // After some bounds checking } char *operator->(void) { return p; } char &operator[](const int offset) { return *(p + offset); // After some bounds checking } iterator &operator+=(const int offset) { p += offset; return *this; } const iterator operator+(const int offset) { iterator out (*this); out += offset; return out; } }; }; } int main() { exscape::string s = "ABCDEF"; exscape::string::iterator i = s.begin(); std::cout << *(i + 2) << std::endl; } The above fails with (line 632 is, of course, the *(i + 2) line): string.cpp: In function ‘int main()’: string.cpp:632: error: no match for ‘operator*’ in ‘*exscape::string::iterator::operator+(int)(2)’ string.cpp:105: note: candidates are: char& exscape::string::iterator::operator*() *(2 + i) fails with: string.cpp: In function ‘int main()’: string.cpp:632: error: no match for ‘operator+’ in ‘2 + i’ string.cpp:434: note: candidates are: exscape::string exscape::operator+(const char*, const exscape::string&) My guess is that I need to do some more overloading, but I'm not sure what operator I'm missing.

    Read the article

  • Proper way to assert type of variable in Python

    - by Morlock
    In using a function, I wish to ensure that the type of the variables are as expected. How to do it right? Here is an example fake function trying to do just this before going on with its role: def my_print(text, begin, end): """Print text in UPPER between 'begin' and 'end' in lower """ for i in (text, begin, end): assert type(i) == type("") out = begin.lower() + text.upper() + end.lower() print out Is this approach valid? Should I use something else than type(i) == type("") ? Should I use try/except instead? Thanks pythoneers

    Read the article

  • lock file so that it cannot be deleted

    - by JoeCool
    I'm working with two independent c/c++ applications on Windows where one of them constantly updates an image on disk (from a webcam) and the other reads that image for processing. This works fine and dandy 99.99% of the time, but every once in a while the reader app is in the middle of reading the image when the writer deletes it to refresh it with a new one. The obvious solution to me seems to be to have the reader put some sort of a lock on the file so that the writer can see that it can't delete it and thus spin-lock on it until it can delete and update. Is there anyway to do this? Or is there another simple design pattern I can use to get the same sort of constant image refreshing between two programs? Thanks, -Robert

    Read the article

  • [rails] do we need database level constraints

    - by shrimpy
    i have the same problem as in the following post http://stackoverflow.com/questions/1451570/ruby-on-rails-database-migration-not-creating-foreign-keys-in-mysql-tables so i am wondering, why rails do not support generate foreign key by default??? it is not necessary??? or we suppose to do it manually?

    Read the article

  • Creating Custom Assertions in Oracle Web service Manager (OWSM)

    - by sachin
    I am trying to create example given at this site: http://download.oracle.com/docs/cd/E12839_01/web.1111/b32511/custom_assertions.htm#CIHFGJAG but While compiling I get following errors: Error(63,64): cannot access oracle.annotation.logging.Publish Error: error: in class file D:\Installations\Oracle\Middleware_11g\oracle_common\modules\oracle.wsm.common_11.1.1\wsm-policy-core.jar/oracle/wsm/resources/enforcement/EnforcementMessageID.class: unknown enum constant oracle.annotation.logging.Publish.NO Error(69,28): cannot access oracle.annotation.logging.Category Error(70,48): cannot find variable FAULT_FAILED_CHECK Error(75,17): cannot access oracle.annotation.logging.Severity I have included: wsm-policy-core.jar, wsm-agent-core.jar findjars.com shows oracle.annotation.logging.Publish present in: logging-utils.jar I downloaded latest oc4j, but still not able to find this jar or resolve the issue. Please help!

    Read the article

  • Would Like Multiple Checkboxes to Update World PNG Image Using Mogrify to FloodFill Countries With C

    - by socrtwo
    Hi. I'm seeing in another forum if the best way to do this is with Javascript or Ajax but I'm wondering if there is an even easier simpler way. I'm trying to create a web service where users can check which countries they have visited from a list of 175 or so and a World map image would then instantly update with a filled color. There are other similar services, but I'm envisioning mine to be both updating from checks in checkboxes and by clicking on the target country in the displayed image say with an imagemap. Additionally other solutions display all the visited countries in the same color. I would like different colors for different countries or at least for those countries that touch. Eventually I would like to include a feature that enables the choice of which colors to assign countries. I found a Sourceforge project called pwmfccd. It's simply an open source image of the world and the coordinates on the PNG image for all the countries. You can use mogrify from ImageMagick and floodfill to fill the countries with color. I have done this successfully, locally with batch files. My ISP has told me where mogrify is located, basically "/usr/bin/mogrify". I now have a horrendously complicated cgi script which if it worked is set to redraw the world map image with each checkbox. It's here. It also redraws the whole web page with each check. The web page starts here. Of course this is not at all efficient, and I think probably the real way to go is Ajax or Javascript, so that maybe just the image gets changed and redrawn, not the whole web page. Sorry I don't even know the difference between Javascript and Ajax and their relative merits at this point. I suppose you could make just one part of the image update with each check or click on the image instead of even just the image redrawing, but I have never even heard of a hint at being able to do that for irregularly shaped image elements like countries. So I guess an Image map and sister checkbox entries tied to mogrify events redrawing the user's personal copy of the image with an image refresh would be the only way to go. So how do you do this with something other than Javascript or Ajax or is that definitely the way to go and if so, how would you do it? Or can you after all cut up a web based image into irregular puzzle shaped piece which you can redraw individually at will. Thanks in advance for reading and considering answering this post.

    Read the article

  • Page-specific logic in Joomla

    - by Casebash
    I am trying to enable JavaScript in a Joomla template to behave differently depending on the page. In particular, I have set the Key Reference as that appears to be the most appropriate value I could find for this purpose. Unfortunately, I can't seem to access it in my code. I tried: $this->params->get("keyref") and a few other variations, but they simply returned a blank. How can I retrieve this value or is there a better way of writing page specific logic. Related Articles Joomla load script in a specific page: This would work, but seems like overkill for what I want to do here.

    Read the article

  • How to host WCF service and TCP server on same socket?

    - by Ole Jak
    Tooday I use ServiceHost for self hosting WCF cervices. I want to host near to my WCF services my own TCP programm for direct sockets operations (like lien to some sort of broadcasting TCP stream) I need control over namespaces (so I would be able to let my clients to send TCP streams directly into my service using some nice URLs like example.com:port/myserver/stream?id=1 or example.com:port/myserver/stream?id=anything and so that I will not be bothered with Idea of 1 client for 1 socket at one time moment, I realy want to keep my WCF services on the same port as my own server or what it is so to be able to call www.example.com:port/myWCF/stream?id=222...) Can any body please help me with this? I am using just WCF now. And I do not enjoy how it works. That is one of many resons why I want to start migration to clear TCP=) I can not use net-tcp binding or any sort of other cool WS-* binding (tooday I use the simpliest one so that my clients like Flash, AJAX, etc connect to me with ease). I needed Fast and easy in implemrnting connection protocol like one I created fore use with Sockets for real time hi ammount of data transfering. So.. Any Ideas? Please - I need help.

    Read the article

  • MapKit internal calls causing crash

    - by Ronnie Liew
    I have a MKMapView in the view of a UIViewController. The app will crash randomly when the I pop the UIViewController off from the UINavigationController. In the dealloc method of the UIViewController, I have already assigned the MKMapView delegate to nil as below: - (void)dealloc { mapView.delegate = nil; [_mapView release]; _mapView = nil; [super dealloc]; } The crash log are also attached as follows: Crash log #1: Thread 0 Crashed: 0 libobjc.A.dylib 0x000026f6 objc_msgSend + 18 1 MapKit 0x0005676c -[MKUserLocationPositionAnimation animationDidStop:finished:] + 64 2 QuartzCore 0x00015a26 run_animation_callbacks(double, void*) + 282 3 QuartzCore 0x000158dc CA::timer_callback(__CFRunLoopTimer*, void*) + 100 4 CoreFoundation 0x00056bac CFRunLoopRunSpecific + 2112 5 CoreFoundation 0x00056356 CFRunLoopRunInMode + 42 6 GraphicsServices 0x00003b2c GSEventRunModal + 108 7 GraphicsServices 0x00003bd8 GSEventRun + 56 8 UIKit 0x00002768 -[UIApplication _run] + 384 9 UIKit 0x0000146c UIApplicationMain + 688 10 Refill 0x00002aea main (main.m:14) 11 Refill 0x00002a60 start + 44 Crash log#2 Thread 0 Crashed: 0 libobjc.A.dylib 0x000026f4 objc_msgSend + 16 1 MapKit 0x0005a20e -[MKUserLocationViewInternal userLocationViewAccuracyDidUpdate] + 42 2 MapKit 0x0005676c -[MKUserLocationPositionAnimation animationDidStop:finished:] + 64 3 QuartzCore 0x00015a26 run_animation_callbacks(double, void*) + 282 4 QuartzCore 0x000158dc CA::timer_callback(__CFRunLoopTimer*, void*) + 100 5 CoreFoundation 0x00056bac CFRunLoopRunSpecific + 2112 6 CoreFoundation 0x00056356 CFRunLoopRunInMode + 42 7 GraphicsServices 0x00003b2c GSEventRunModal + 108 8 GraphicsServices 0x00003bd8 GSEventRun + 56 9 UIKit 0x00002768 -[UIApplication _run] + 384 10 UIKit 0x0000146c UIApplicationMain + 688 11 Refill 0x00002aea main (main.m:14) 12 Refill 0x00002a60 start + 44 Seems like the MapKit is trying to update the MKMapView on the user location but the delegate has already been deallocated. What else I am missing here?

    Read the article

  • "<" operator error

    - by Nona Urbiz
    Why is the ( i < UniqueWords.Count ) expression valid in the for loop, but returns "CS0019 Operator '<' cannot be applied to operands of type 'int' and 'method group'" error when placed in my if? They are both string arrays, previously declared. for (int i = 0;i<UniqueWords.Count;i++){ Occurrences[i] = Words.Where(x => x.Equals(UniqueWords[i])).Count(); Keywords[i] = UniqueWords[i]; if (i<UniqueURLs.Count) {rURLs[i] = UniqueURLs[i];} } EDITED to add declarations: List<string> Words = new List<string>(); List<string> URLs = new List<string>(); //elements added like so. . . . Words.Add (referringWords); //these are strings URLs.Add (referringURL); UniqueWords = Words.Distinct().ToList(); UniqueURLs = URLs.Distinct().ToList(); SOLVED. thank you, parentheses were needed for method .Count() I still do not fully understand why they are not always necessary. Jon Skeet, thanks, I guess I don't understand what exactly the declarations are either then? You wanted the actual values assigned? They are pulled from an external source, but are strings. I get it! Thanks. (the ()'s at least.)

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >