Sorry it took so long, I don't always get back to projects right away at work unless they're critical need, which this one wasn't....I believe your idea works, I hadn't tried it before....I now have to test it on another screen though.....either way I'll mark it solved...don't know why I didn't think of that... I knew that those things existed I just didn't think to put the pieces together!!!! Thank you, onaclov

Hello, I wrote a little slide in box, that slides in from the edge of the screen, the problem i'm having is that I don't always know the size of the desktop if that makes sense, as well as spacially where things are, I.E. Suppose the start menu is on the right screen, with a second desktop on the left, I setup the position of the box according to that, then I move to another desktop where the left screen is the display with start menu, now the form is on the left edge of the secondary screen BUT now it's showing up on the left screen, since the secondary display is right of the primary, this is not awesome, any tips on how to resolve this issue...I hope i've explained myself clearly, if not I'll try to provide more details if needed.

I'm looking for programs that say have a function that runs too slow, and I can look at it and try to speed it up, via either algorithms, parallelism, code motion (parallelism is executing statments in an order that works best for the processor, code motion is moving things out of loops if possible, so they don't get executed x number of times when they really only need one), and other techniques we're learning.

If you know of any open source projects that I could look at that would be even better, but specific cases, someone saying "look at ubuntu" would not be helpful, now if they said, hey look at this function within the gnome window manager where we're drawing windows, it's running too slow, take a look at it and see if you can do something with it.!

I suppose I'm asking alot and I'm sorry but I just wanted to see if anyone had any ideas right off the top of their heads!
Thank you,
onaclov

I've been given an assignment in class to take some code and work on improving the optimization, we can either write new code or use old code.

For some reason I can't think of anything that would be a good example of code that can use multiple optimization techniques,
I.E. Code Motion, Parallelism, Algorithm...etc.

Does anyone have any suggestions?

Thank you,

Onaclov

I guess a simple solution would be to change your print to this:
[CODE]
$file = "somefileyouwanttostoreto.txt";
open(OUT, ">$file");
print OUT "strings that you want to output to file";
close(OUT);
[/CODE]

Not too hard to actually include the file itself in your code,

Basically if you're currently doing "print" you would just replace it with "print OUT" in the cases where you want to output.

The Filename can be somewhat dynamic in that you can make it's name based on the current date/iteration of your file.

Thank you,
onaclov

An alternate option is to use a hash table lookup, thus you just would pass in the name of the cricketeer and it would return a number, I.E.

[CODE]
%Cricketeers =(
"PersonA" => 1);
$tempString = "PersonA";
print $Cricketeers{$tempString} . " " . $tempString . "\n";
[/CODE]

This will output:
1 Person A

I don't have a book or whatever on me but you can add users and automatically assign the number's (using a loop for example), also it will sort I believe too, but you can use the same kind of call each time and it will return the number, this can be a nice thing because the array is indexed by the name not the number, so the "value" can actually be anything, it doesn't have to be numbers. it's just a "key value pair" the key being the cricketeer and the value being what you assigned to it.

Good luck

[QUOTE=pritaeas;1077625]OpenID:
[url]http://openid.net/developers/libraries/[/url]

I've tried the PHP library, and the examples worked out-of-the-box.[/QUOTE]

That looks really helpful so far, I'll have to try implementing it when I get home.

Thank you!!!

I'm really not sure if this is the place for this, but I guess I don't see any OpenID or SVN forums...LOL

I'm having a heck of a time finding this stuff, but basically what I'm looking to do, is if I try to go to my SVN page, I want it to redirect to a login page where I can use openID to login.

There are two things that look like they are holding me up:

  1. I don't know how to force the page to go to another page initially.
  2. I don't know how to implement openID.

I have a subversion server setup and all, I just don't know alot about web programming beyond some HTML I learned back in highschool.

If anyone knows of any good links for HOW to implement openID, redirecting SVN pages, as well as maybe even setting up a webpage front end for my SVN that would be even cooler!!!

Thank you for the help!

$target =~ m/^[yY]ou/; # this will grab lines starting with you or You (not sure if the character class is right, but it looks to be).
just do an "if" on that above search, and then don't print if it contains it, now if it's a multiline situation, you'll have to do some more adjusting on what lines to not print.

Thanks,
I will try these when I get home, I didn't realize I could "step through" a line by using the >> and a vector.

I am a little confused about:
istringstream iss(line);

I've never used it before, so just to clarify what you're saying is that we're assigning iss the line as a stream, then we can use our >> again on it?

That being the case line won't be able to use >> without doing that above line!

Again, Thank you,

Onaclov

So I guess my question is:

Can I grab an entire line using cin.getline(), and grab an entire line and ignore the whitespaces?

What I'm trying to do is grab the following line:
2 3
and I want to know how many numbers are in it?
OR maybe a better question would be how would I grab the 2 3 individually?

What I'm trying to do is grab 2 and 3 but if i use myfile >> number it grabs them one at a time, but I can't guarantee that the line will only contain 2 numbers (could be any number), and I want to use each line as inputs to a function....does that make sense?

(I'm attempting to solve the google codejam round 1 problem, where you basically take the numbers on the line square them and add them together, if the result is 1 then you're done, if the result is greater then 1 you split the two numbers again and do it all over again).

I just can't seem to figure out how to grab the two (or x) numbers so I can work with the data.....Once i have the data I think I can solve the problem fairly easy...LOL

Thank you for any help

I will say at least for me alot of times I put music on in the background so I can study in peace (at home), so when you go into a test and don't have that "common" element it can make the test harder to concentrate on, I'm not objective to being able to listen to music while testing (I mean seriously are we going to be doing whatever they are testing us on in the real world in complete silence?), but I mean its the persons decision to cheat and I dont' think that all people are that low and would do that, we had a discussion recently in one of my classes whether it was ethical to allow Ti-89's on our tests since Ti-83's couldn't do everything they did (particularly Diff eq and Calc stuff), but we decided if you can show your work and how you did it then it's gonna be hard to show every step if you didn't actually do at least a majority of it.

just my $.02

I know i've used print command; as well with varied success.

Ok, so this is confusing me alot, right now I have a structure as such:
[CODE]struct f_c_8 {
union {
float f;
unsigned char c[8];
};
};[/CODE]
now I declare a variable of that type

[CODE]f_c_8 Time;[/CODE]

However,

The following prints correct number
[CODE] fprintf (output_file_pointer,"\t\tTime: %f\n",event_data->Time); [/CODE]

And the following doesn't print correct number
[CODE]fprintf (output_file_pointer,"\t\tTime: %f\n",event_data->Time.f); [/CODE]

What I'm confused about is that I'm passing the fprintf the entire structure and saying print a floating point number from that, but if I actually call the floating point number variable, it doesn't print the floating point correctly.

Does this make sense to anyone, anywhere?

[QUOTE=seanl1;927359]So I was going through the course archives for our CS program and looked at some notes and quizzes from a class that was last taught in Spring of 2008 that I will be taking Fall of 2009. It's called Survey of Programming Languages and I found the section on grammar to be interesting.

Here are the questions I'm referencing:

Consider the regular expression a((ab)|(ba))b.

  1. Which one of the following strings is not accepted by this regular expression?
    • ab
    • aababb
    • ababb
    • abababab
  2. Which one of the following strings is accepted by this regular expression?
    • bababb
    • aababb
    • aabababa
    • abaabb
      [/QUOTE]
      I can at least look at this reference,
      Basically the regex can be broken down as such
      1. look for an a
      2. now look for either none or more ba,
        OR
        none or more ab
        (But not both)
      3. look for a b at the end.

Thus the first question #1 would fail on this line : ababb
because you have ababb and since there is no a after the second b it fails a "change" that would make this work would be:
ababab

For question #2 can you apply the same concept as the steps above and determine which will fail
(should be pretty easy to cut it down to 2 and from there just look closely)

Good luck and as far as the rest of your question I have no clue...sorry.

Sorry, not a python guy, kinda more of a perl guy (gonna try to learn python someday), but I expect that python has RegEx support, would it be possible to extract that data via a RegEx not sure if you can get a "match that tells you how many times it matched" query? You could just append them to a csv you can "search" each time you come upon a "new" word and if you already see it don't try to regex it......

Just a thought.

Thank you

Edit:
[code]
my $counter2 = ($string =~ s/AAA/AAA/g);
[/code]
basically it looks to me like that entire "thing" will return a value, I'll have to try some testing, but basically you could do something like the above and only do it on "new" words like I was saying

[code]# Fill in the following variables.

Source file in the format of

FirstName, LastName, ClassYear, Home Phone

$infile="US2010";

$tmpclass = substr($infile,$inlen_len -2);

Drive and folder location of class folders

$volume="E:\Class".$tmpclass;

Secondary Group Membership

$group="Class".$tmpclass;[/code]
I am not sure where you are gettting:
$inlen_len -2

I don't see it in the beginning where is the above code placed with relation to the rest of the program? if it's at the beginning I'm not sure where you're getting that length.....
(Although it's possible maybe it has nothing to do with the script's problems)

also have you tried perl -w <filename> to make sure you get as much debugging information as possible? additional debugging tips, I would recommend (or at least I try it when I'm running out of ideas as to what's wrong), is just print to the Standard Output comments or variables at different points, so you can see the flow of your program, your program may be going into a section that you weren't expecting and that might tell you where....

When you publish the project is there not a .exe file that is associated with it in the deployment folder, or have i mistaken the question?

first off...you're trying to store ji as a integer, and it's not an integer, you would most likely want to store it as a string or char array.
so what you would want to do is write it as string k, then say

k = "j" + i;

I believe that would be the "syntax" the + might or might not be right, I don't have a compiler in front of me.

Also in that case you don't need j as a char, you can just use the character j for real....if that makes sense....

so finally the code should look like this I think

string k;
for(int i=0;i<10;i++){
k="j" + i;
}

you might want to add a new line, or something like that to the end so you get a "string" that has all the items on a new line each.

Another option is to write a string array and store the j# in each item in the array.

Good luck,
Let us know how it turns out.

[QUOTE=GeekByChoiCe;913637]I have tested the code you posted and got no error messages. Anyway your code didn't work if i use frmMain.Viewlist so i assigned this control as parameter (Byval sender as Object) and hand it over to the class.
Hope this helps

[code=vb]
Public Class frmMain

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim Tasks As New Stuff
    Dim myThread As New Threading.Thread(AddressOf Tasks.getSome)
    myThread.Start(ViewList)
End Sub

End Class

Friend Class Stuff

Private Delegate Sub AddItemsDelegate(ByVal newItem As String)
Private cntrl As ComboBox

Friend Sub getSome(ByVal sender As Object)
    While frmMain.ViewList.Handle = Nothing Or frmMain.Handle = Nothing
        Threading.Thread.Sleep(10) 'wait till frmMain and Viewlist is created, else you might get an exception
    End While

    cntrl = DirectCast(sender, ComboBox) 'assign the frmMain.Viewlist to cntrl

    Dim i As Integer
    Dim location As Integer
    Dim someCounter As Integer = 2000
    Dim someText As String = "hey"

    For i = 1 To someCounter
        cntrl.Invoke(New AddItemsDelegate(AddressOf addItToBox), someText & i)
    Next
    location = cntrl.FindString("hey")
    cntrl.Invoke(New MethodInvoker(AddressOf enable)) 'use the standard MethodInvoker if there are no parameters needed
End Sub

Private Sub addItToBox(ByVal newItem As String)
    cntrl.Items.Add(newItem)
End Sub

Private Sub selectedIndex(ByVal num As Integer)
    cntrl.SelectedIndex = num
End Sub

Private Sub enable()
    cntrl.Enabled = True
End Sub

End Class
[/code][/QUOTE]

I haven't had time to play with it much for a while (and might not for a bit again),
"For now" I just used BG worker and passed back the results through the e, and then in the "work done" (can't ...

[QUOTE=rayken1;916028]Hi Prakash and Onclav2000,

Thanks for your answers. I still having some problem in solving my problem. I have sent the structure of the file am dealing with and the code I have so far come up with using Onclov2000 REGEX that captures only the first line in the file.

The structure of the text file is as follows:

FT CDS complement(7216..17805)
FT /locus_tag="TP01_0003"
FT /codon_start=1
FT /protein_id="XP_765530.1"
FT /db_xref="GI:71031777"
FT /db_xref="GeneID:3502673"
FT gene complement(<7216..>17805)
FT /locus_tag="TP01_0003"
FT /db_xref="GeneID:3502673"
FT mRNA complement(<7216..>17805)
FT /locus_tag="TP01_0003"
FT /product="hypothetical telomeric SfiI fragment 20 protein
FT 3"
FT /transcript_id="XM_760437.1"
FT /db_xref="GI:71031776"
FT /db_xref="GeneID:3502673"
[B]FT CDS complement(join(18028..18116,19351..20668))
FT /locus_tag="TP01_0004"
FT /note="go_function: nutrient reservoir activity [goid
FT 0045735]"[/B]
FT /codon_start=1
FT /protein_id="XP_765531.1"
FT /db_xref="GI:71031779"
FT /db_xref="GeneID:3503550"
FT gene complement(<18028..>20668)
FT /locus_tag="TP01_0004"
FT /db_xref="GeneID:3503550"
FT mRNA complement(join(<18028..18116,19351..>20668))
FT /locus_tag="TP01_0004"
FT /product="hypothetical protein"
FT /transcript_id="XM_760438.1"
FT /db_xref="GI:71031778"
FT /db_xref="GeneID:3503550"
FT CDS complement(20951..21967)
FT /locus_tag="TP01_0005"
FT /codon_start=1
FT /protein_id="XP_765532.1"
FT /db_xref="GI:71031781"
FT /db_xref="GeneID:3503551"
FT gene complement(<20951..>21967)
FT /locus_tag="TP01_0005"
FT /db_xref="GeneID:3503551"
FT mRNA complement(<20951..>21967)
FT /locus_tag="TP01_0005"
FT /product="hypothetical protein"
FT /transcript_id="XM_760439.1"
FT /db_xref="GI:71031780"
FT /db_xref="GeneID:3503551"

This is my code

!/usr/bin/perl

$file = 'Muguga.embl ';

open (F, $file) || die ("Could not open $file!");

while ($line = <F>)
{
($field1,$field2,$field3,$field4) = split( "\t" , $line);

print "$field1 $field2 $field3 $field4 \n";
my $string = (FT CDS complement(join(18028..18116,19351..20668))); # string to be searched

if ($string = ~ m/^FT \s+ CDS \s+ complement(join([0-9]+))$/)

search for the first line highlighted in bold

{
print 'match'
} else{
print 'no match';
}
}
close (F); ...

[QUOTE=siddhant3s;913562]
However the following will not work, it will cause naming conflicts:
[CODE] +--main.cpp-------------+
+-----------------------+
| #include <iostream> |
| #include "header.h" |
| #include "header.cpp" |
| main() |
| { |
| //blah blah |
| } |
+-----------------------+[/CODE]
here, you #included both the cpp and .h files.
Why this causes name conflicts is clear: because the header.h gets included twice; one from header.cpp and another from main.cpp itself.
This can be verified by using the
[CODE]$: g++ main.cpp -E | grep -v "#"[/CODE][/QUOTE]

Wouldn't a simple If Not Defined wrapped around the include solve the "conflict"?

Sorry I'm still learning too, so far this has been a quite informative post and I didn't even ask the question....LOL

I would check out process library.

There is also a link on Lifehacker for a tool called:
[URL="

The original post doesn't specify if it's a header file or not, thus my confusion, typically if you write a function in your header file, then #include it would that not be a legitamite way of doing it? This is of course we are talking about the function being in a header file.

This is gonna sound terrible, but Google. I did most of my learning in google, but that is primarily for syntax, if you know how to program but don't know the syntax, then simply search what you're trying to do (I'm sure it's probably the worst way to learn, but I get board reading books like that, I just need specific information and Google can get that to me quickly), Then again that works well for the ADD person who can't sit down and actually read a book like that..

Wouldn't you just use a "include" statement and include the second file in the first, then it's just a normal compile and the compiler will handle what files need to be compiled due to direct dependencies, or am I just not understanding the question????

Well this one will take up a little math, but figure out how many days have occured between then and now (# of years times 365.25) and then the number of days from the 4th of january to todays date.
now that you have that number you should be able to do a mod 7 and grab the remainder and multply by 7 that should give you the day. (remember there are 7 days a week thus the mod 7) There's a famous mathematician who used to use it that I read about it, but can't for the life of me remember what their name is (for some reason thinking gauss or descartes....)

According to [URL="

So I tried reading a little, I'm still having some problems:

An error occurred creating the form. See Exception.InnerException for details. The error is: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.

Not really sure where to go with that....I looked it up on google, and most of the 'responses' were "ohhh I found a dll that needed to be rebuild (because <STAThread()> _, didn't seem to work)

[ICODE]
Public Class frmMain
<STAThread()> _
Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Tasks As New Stuff

Dim myThread As New Threading.Thread(AddressOf Tasks.getSome)

    myThread.Start()

End Sub

End Class

Public Class Stuff
Private Delegate Sub AddItemsDelegate(ByVal newItem As String)
Private Delegate Sub EnableBox()

Public Sub getSome()

    Dim i As Integer
    Dim location As Integer
    Dim someCounter as Integer
    Dim someText as Integer
    someText = "hey"

    For i = 1 To someCounter                 
      frmMain.ViewList.Invoke(New AddItemsDelegate(AddressOf addItToBox), someText & i)
    Next
    location = frmMain.ViewList.FindString("hey")
    frmMain.Invoke(New EnableBox(AddressOf enable))
End Sub

<STAThread()> _
Private Sub addItToBox(ByVal newItem As String)

    frmMain.ViewList.Items.Add(newItem)

End Sub
<STAThread()> _
Private Sub selectedIndex(ByVal num As Integer)

    frmMain.ViewList.SelectedIndex = num

End Sub
<STAThread()> _
Private Sub enable()

    frmMain.ViewList.Enabled = True

End Sub

End Class
[/ICODE]

I think I'm just really confused. I thought I was getting it, basically I call a thread to start on it's own, then use an "invoke" to call a "local" function that isn't multithreaded, and ...

[QUOTE=GeekByChoiCe;912074]if you want to fill a control in a seperate thread then you have to invoke the control or the complete form. else you will get a cross thread exception.
Below an example....

[code=vb]
Private Delegate Sub AddItemsDelegate(ByVal newItem As String)

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim myThread As New Threading.Thread(AddressOf cmbThread)
    myThread.Start()
End Sub

Private Sub cmbThread()
    For i As Integer = 0 To 2000
        Me.Invoke(New AddItemsDelegate(AddressOf addItToBox), "item" & i)

'ComboBox1.Invoke(New AddItemsDelegate(AddressOf addItToBox), "item" & i)
Next

End Sub

Private Sub addItToBox(ByVal newItem As String)
    ComboBox1.Items.Add(newItem)
End Sub

[/code][/QUOTE]

so if I call invoke is that calling the "current" running instance? I'm not sure if I'm following why you get the cross thread error, I do recall getting that, but I'm not sure how the thread that has the actual form on it is related to the one that you would "invoke".

Sorry Maybe some links to stuff to read up on it might help if it's too much of a pain to explain.

Thank you,

When I'm attempting to load a program, there is a certain aspect that relies on a separate api to grab information to stick in a listbox (combobox whatever). I would like to be able to load the combobox on a separate thread because that part takes a good 2 minutes, the need for this to be loaded immediately is not there, I can stick a "loading" textbox next to it and when it's done loading change it to loaded, but I can't seem to figure out how to stick it on a separate thread, I tried BG worker but couldn't get it to work.....
I would say that unless you need the data in the combobox for some reason the rest of the program is 100% useable, so I don't want the user to have to wait for a component of the program to load when they may not need it. I hope that makes sense.

Anyone have any suggestions?

Thank you,
onaclov