Daily Archives

Articles indexed Wednesday March 17 2010

Page 14/128 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Relational MySQL - fetched properties?

    - by Kelso.b
    I'm currently using the following PHP code: // Get all subordinates $subords = array(); $supervisorID = $this->session->userdata('supervisor_id'); $result = $this->db->query(sprintf("SELECT * FROM users WHERE supervisor_id=%d AND id!=%d",$supervisorID, $supervisorID)); $user_list_query = 'user_id='.$supervisorID; foreach($result->result() as $user){ $user_list_query .= ' OR user_id='.$user->id; $subords[$user->id] = $user; } // Get Submissions $submissionsResult = $this->db->query(sprintf("SELECT * FROM submissions WHERE %s", $user_list_query)); $submissions = array(); foreach($submissionsResult->result() as $submission){ $entriesResult = $this->db->query(sprintf("SELECT * FROM submittedentries WHERE timestamp=%d", $submission->timestamp)); $entries = array(); foreach($entriesResult->result() as $entries) $entries[] = $entry; $submissions[] = array( 'user' => $subords[$submission->user_id], 'entries' => $entries ); $entriesResult->free_result(); } Basically I'm getting a list of users that are subordinates of a given supervisor_id (every user entry has a supervisor_id field), then grabbing entries belonging to any of those users. I can't help but think there is a more elegant way of doing this, like SELECT FROM tablename where user->supervisor_id=2222 Is there something like this with PHP/MySQL? Should probably learn relational databases properly sometime. :(

    Read the article

  • Why does my ActivePerl program report 'Sorry. Ran out of threads'?

    - by Zaid
    Tom Christiansen's example code (à la perlthrtut) is a recursive, threaded implementation of finding and printing all prime numbers between 3 and 1000. Below is a mildly adapted version of the script #!/usr/bin/perl # adapted from prime-pthread, courtesy of Tom Christiansen use strict; use warnings; use threads; use Thread::Queue; sub check_prime { my ($upstream,$cur_prime) = @_; my $child; my $downstream = Thread::Queue->new; while (my $num = $upstream->dequeue) { next unless ($num % $cur_prime); if ($child) { $downstream->enqueue($num); } else { $child = threads->create(\&check_prime, $downstream, $num); if ($child) { print "This is thread ",$child->tid,". Found prime: $num\n"; } else { warn "Sorry. Ran out of threads.\n"; last; } } } if ($child) { $downstream->enqueue(undef); $child->join; } } my $stream = Thread::Queue->new(3..shift,undef); check_prime($stream,2); When run on my machine (under ActiveState & Win32), the code was capable of spawning only 118 threads (last prime number found: 653) before terminating with a 'Sorry. Ran out of threads' warning. In trying to figure out why I was limited to the number of threads I could create, I replaced the use threads; line with use threads (stack_size => 1);. The resultant code happily dealt with churning out 2000+ threads. Can anyone explain this behavior?

    Read the article

  • In C#, what thread will Events be handled in?

    - by Ben
    Hi, I have attempted to implement a producer/consumer pattern in c#. I have a consumer thread that monitors a shared queue, and a producer thread that places items onto the shared queue. The producer thread is subscribed to receive data...that is, it has an event handler, and just sits around and waits for an OnData event to fire (the data is being sent from a 3rd party api). When it gets the data, it sticks it on the queue so the consumer can handle it. When the OnData event does fire in the producer, I had expected it to be handled by my producer thread. But that doesn't seem to be what is happening. The OnData event seems as if it's being handled on a new thread instead! Is this how .net always works...events are handled on their own thread? Can I control what thread will handle events when they're raised? What if hundreds of events are raised near-simultaneously...would each have its own thread? Thank in advance! Ben

    Read the article

  • struts datagrid problem - can't solve this problem

    - by shien-angel
    i am creating datagrid using the struts-layout. and i encountered this problem javax.servlet.ServletException: DispatchMapping[/monitor/datagridBL]???????????????????? at org.apache.struts.actions.DispatchAction.getParameter(DispatchAction.java:325) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at jp.terasoluna.fw.web.struts.action.RequestProcessorEx.process(RequestProcessorEx.java:149) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at jp.co.anicom.fw.web.common.controller.RequestEncodeFilter.doFilter(RequestEncodeFilter.java:42) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at jp.co.anicom.fw.web.common.controller.SessionExpirationFilter.doFilter(SessionExpirationFilter.java:89) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) i have been looking for ways on how to solve this. would somebody help me please...

    Read the article

  • NHibernate / Fluent - Mapping multiple objects to single lookup table

    - by Al
    Hi all I am struggling a little in getting my mapping right. What I have is a single self joined table of look up values of certain types. Each lookup can have a parent, which can be of a different type. For simplicities sake lets take the Country and State example. So the lookup table would look like this: Lookups Id Key Value LookupType ParentId - self joining to Id base class public class Lookup : BaseEntity { public Lookup() {} public Lookup(string key, string value) { Key = key; Value = value; } public virtual Lookup Parent { get; set; } [DomainSignature] [NotNullNotEmpty] public virtual LookupType LookupType { get; set; } [NotNullNotEmpty] public virtual string Key { get; set; } [NotNullNotEmpty] public virtual string Value { get; set; } } The lookup map public class LookupMap : IAutoMappingOverride<DBLookup> { public void Override(AutoMapping<Lookup> map) { map.Table("Lookups"); map.References(x => x.Parent, "ParentId").ForeignKey("Id"); map.DiscriminateSubClassesOnColumn<string>("LookupType").CustomType(typeof(LookupType)); } } BASE SubClass map for subclasses public class BaseLookupMap : SubclassMap where T : DBLookup { protected BaseLookupMap() { } protected BaseLookupMap(LookupType lookupType) { DiscriminatorValue(lookupType); Table("Lookups"); } } Example subclass map public class StateMap : BaseLookupMap<State> { protected StateMap() : base(LookupType.State) { } } Now I've almost got my mappings set, however the mapping is still expecting a table-per-class setup, so is expecting a 'State' table to exist with a reference to the states Id in the Lookup table. I hope this makes sense. This doesn't seem like an uncommon approach when wanting to keep lookup-type values configurable. Thanks in advance. Al

    Read the article

  • Determine whether a canvas has been inserted into each page

    - by Hadi Teo
    Hi, Currently i have a code which will print OMR Mark on each pages. Basically i insert a canvas into each page and subsequently an OMR Mark Line Series are inserted into the canvas. Recently i found an issue that somehow one of the canvas is placed out of a page and it appears at the previous page instead of the current page. Below is the code snippet in how i inserted canvas as well as OMR Marks into each page: ' Start Code Snippet Sub GenerateOMR() Dim ShpCanvas As Shape Dim MaxPages As Integer Dim PNo As Integer ClearOMR MaxPages = Selection.Information(wdNumberOfPagesInDocument) For PNo = 1 To MaxPages Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=PNo, Name:="" Select Case PNo Case 1 Set ShpCanvas = ActiveDocument.Shapes.AddCanvas(0, 0.5, 600, 300) Case Else Set ShpCanvas = ActiveDocument.Shapes.AddCanvas(0, 0, 600, 300) End Select ' Add a canvas on each page With ShpCanvas .Name = "OMR_Canvas_" & CStr(PNo) .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage .RelativeVerticalPosition = wdRelativeVerticalPositionPage End With ' Insert a white background rectange and remove the rectangle border line With ShpCanvas.CanvasItems.AddShape(msoShapeRectangle, 536, 0, 64, 300) .Name = "OMR_WhiteBackground_" & CStr(PNo) .Fill.ForeColor.RGB = RGB(255, 255, 255) .Line.ForeColor.RGB = RGB(255, 255, 255) End With PrintOMRPage ShpCanvas, PNo Next PNo End Sub ' End Code Snippet There is a custom method called PrintOMRPage method which is not relevant here. My question now, how do i know whether a canvas has been inserted into a page ? Basically i will loop in all the pages and check whether a canvas has been inserted into that page. Apparently i cannot find the correct way. I have tried to check using ActiveDocument.Shapes(1).Top and validate whether the Top position is a negative value. But apparently the Top position is always measured from the top of each page. Thanks for the help. hadi teo

    Read the article

  • Is there an easy way to change iPhone Application Settings from within an application?

    - by Matt
    I've got application settings working just fine. However, I'd like to be able to change my app settings from within my app. It seems as though there should be some kind of generic way to add this functionality to my app without having to recreate all the controls myself. I mean, the code is already written in apple's settings app. Maybe someone wrote this code and open sourced it? (if it is not already available)

    Read the article

  • What guidelines should be followed when using an unstable/testing/stable branching scheme?

    - by Elliot
    My team is currently using feature branches while doing development. For each user story in our sprint, we create a branch and work it in isolation. Hence, according to Martin Fowler, we practice Continuous Building, not Continuous Integration. I am interested in promoting an unstable/testing/stable scheme, similar to that of Debian, so that code is promoted from unstable = testing = stable. Our definition of done, I'd recommend, is when unit tests pass (TDD always), minimal documentation is complete, automated functional tests pass, and feature has been demo'd and accepted by PO. Once accepted by the PO, the story will be merged into the testing branch. Our test developers spend most of their time in this branch banging on the software and continuously running our automated tests. This scares me, however, because commits from another incomplete story may now make it into the testing branch. Perhaps I'm missing something because this seems like an undesired consequence. So, if moving to a code promotion strategy to solve our problems with feature branches, what strategy/guidelines do you recommend? Thanks.

    Read the article

  • Relaunch of wwwCoder.com

    It's been years since I've been active in the community, but I'm back with a newly redesigned wwwCoder.com. The site was taken over by spammers, and was essientially a ghost town, but I reworked it to bring a technology topics aggregator. The site provides full text searching on the popular podcasts, vidcasts, and blogs. Hit the home page to get a quick summary of what's going on with Microsoft developers. Let me know what you think. Patrick Santry wwwCoder.com...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • openvpn and virtualbox

    - by hyperboreean
    Hi guys, I have a linux machine on which I occasionally run Windows XP in Virtual Box. All runs wonderful, except for the openvpn in XP, which can't connect to the vpn server running on a remote machine. The vpn client works from linux ... as far as I read until now it seems to be a problem of port forwarding ... I keep getting this error: TCP/UDP: Incoming packet rejected from 10.0.2.2:1194, expected peer address: (allow this incoming source address/port by removing --remote or adding --float) , but have no idea how to fix it.

    Read the article

  • sudo: must be setuid root

    - by Phuong Nguyen
    Recently, due to some messy stuff with master boot record, I have to re-install my Ubuntu. Before doing that, I back up all folder (exclude root, bin, sbin, tmp, media, mnt) to a NTFS partition. After installation of Ubuntu, I copied back all the folder using a nautilus (running by sudo nautilus). After that, I reboot my computer. And boom, now I cannot run sudo any more, my network services cannot run. When I run sudo from a terminal, I ge "must be setuid root" error. In ubuntu, root account is disabled by default, I don't know why all these files is no longer under ownership of my account. How would I recover back?

    Read the article

  • Troubleshooting painfully slow Windows XP boot

    - by shan
    When I reboot my machine, it takes around 10-15 minutes to boot. Tried removing unused programs, disk defragmentation, check disk, but I'm not able to identify the issue. Any ideas to troubleshoot to see whether there is any failure, trying to start a service/program?

    Read the article

  • file permissions and group ownership using sftp

    - by expaando
    Is there a way to have all files created by a particular user under sftp to have a specific group and file permissions? The user in question, of course, will be a member of the group, but it is not his primary group. In other words, is there a way for sftp to automatically duplicate the effects of umask and newgrp?

    Read the article

  • Symantec site slow only when using a Mac?

    - by cozmokramer8
    I didn't know this was possible but it certainly seems slow when only using a Mac. I participate in the Symantec Connect forums regularly and when I get on it with my Windows PC or laptop it loads perfectly, but my Mac laptop the site rarely loads or if it does it takes a couple minutes for each page. My question is why does a website run slower on the Mac vs PC? No other sites experience this same issue just the symantec connect forums. Thanks, Grant

    Read the article

  • Windows Server 2008 R2 - What now?

    - by MrStatic
    So I installed Windows Server 2008 R2, I have Exchange 2010 running for some mail. I installed BlackBerry Enterprise Server Express for kicks. This server runs dns/dhcp for 2 laptops. But what now? It has 200g's free on the main drive and a 150g external that I have mapped as a network drive. I am not sure what else to do with this thing. It was my main station but since my laptop is nicer I am running it headless and using the lcd monitor for it as a second monitor for the laptop when I am at home.

    Read the article

  • nohup SBCL ubuntu couldn't read from standard input

    - by Jim
    On Ubuntu I compiled sbcl 1.0.35 with threading. I can happily use sbcl from the command line and my hunchentoot website works with threading but when I logout it's gone. When I attempt to nohup sbcl nohup ./src/runtime/sbcl --core output/sbcl.core I get (SB-IMPL::SIMPLE-STREAM-PERROR "couldn't read from ~S" # 9) I've attempted various combinations of redirecting the standard input to /dev/null or a file and using the script command line option but I don't quite get what is going on. How do I start sbcl from the command line on linux with nohup and keep my repl(website) running?

    Read the article

  • Is there any .Net JIT Support from chip vendors?

    - by NoMoreZealots
    I know that ARM actually has some support for Java and SUN obviously, but I haven't really references seen any chip vendor supporting a .Net JIT compiler. I know IBM and Intel both support C compilers, as well as TI and many of the embedded chip vendors. When you think of it, all a JIT compiler is, is the last stages of compilation and optimization which you would think would be a good match for a chip vendor's expertize. Perhaps a standardized Plug In compilation engine for the VM would make sense. Microsoft is targeting .Net to embedded Windows platforms as well, so they are fair game. Pete

    Read the article

  • How can I initialize a 2d array in Perl?

    - by Mark
    How do I initialize a 2d array in perl? I am trying the following code: 0 use strict; 10 my @frame_events = (((1) x 10), ((1) x 10)); 20 print "$frame_events[1][1]\n"; but it gives the following error: Can't use string ("1") as an ARRAY ref while "strict refs" in use at ./dyn_pf.pl line 20. This syntax only seems to initialize a 1d array as print "$frame_events[1]\n" works. Though perl doesn't give any error during the assignment.

    Read the article

  • JanRain OpenID in PHP SREG?

    - by AFK
    I setup the demo with a modified login I found called open-id selector. the login works fine and the identity url comes back, but the SREG data I ask for is never populated, required or optional. I am logging into my page with a gmail account. Here is the code from my try_auth.php that I edited $sreg_request = Auth_OpenID_SRegRequest::build( // Required array('email'), // Optional array('fullname', 'gender', 'timezone', 'dob', 'country')); what gives?

    Read the article

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