I need advice on whether there is an application for generating cross tables. I would imagine it so that I entered at the beginning of team names. Subsequently I wrote results, but always one and the second correct field would enrolled opposite result. I want it to count the total score etc. .. I hope I have expanded well. I would like recommendations for any program.
In Excel I dont.
Thank you a thousand times for any advice.
http://imageshack.us/a/img849/9100/d70m.png
I am trying to build an application that allows users to submit names to be added to a db table (runningList). Before the name is added tho, I would like to check firstname and lastname against another table (controlList). It must exist in (controlList) or reply name not valid. If the name is valid I would like to then check firstname and lastname against (runningList) it make sure it isnt already there. If it isnt there, then insert firstname & lastname. If it is there, reply name already used.
Below is code that worked before I tried to add the test against the controlList,
I somehow broke it altogether while trying to add the extra step.
if (mysql_num_rows(mysql_query('SELECT * FROM runninglist WHERE firstname=\'' .$firstname . '\' AND lastname=\'' . $lastname . '\' LIMIT 1')) == 0)
{
$sql="INSERT INTO runninglist (firstname, lastname)
VALUES ('$_POST[firstname]','$_POST[lastname]')";
}
else
{
echo "This name has been used.";
}
Any direction would be appreciated.
Thanx
John
If I wanted to have a collection that described the (recursive) contents of a root directory, including directories and files, how would I store them? Or do I need to come up with an object that holds:
-Current directory
-Parent directory
-Files in directory
..and slap them all in one big list and manually work out the relationship at runtime from each entries Parent directory.
If I have an object instance and I know it is actually a boxed integer, then I can simply cast it back to int like this:
object o = GetSomethingByName("foo");
int i = (int)o;
However, I don't actually know that the value is an integer. I only know that it can be assigned to an integer. For example, it could be a byte, and the above code would throw InvalidCastException in that case. Instead I would have to do this:
object o = GetSomethingByName("foo");
int i = (int)(byte)o;
The value could also be a short, or something else which can be assigned to an int. How do I generalize my code to handle all those cases (without handling each possibility separately)?
Hi,
I'm refactoring some specs, in controller specs I have a before(:each) which sets up things required in the session
my before filter is...
config.before(:each, :type => :controller) do
...
session[:current_user] = @user
session[:instance] = @instance
...
end
@user and @instance are also set in the before(:each)
i've just hidden them for readability here
I get the following error when running the controller tests
undefined method `session' for nil:NilClass
I would expect the global before callbacks to have the same things as the ones in the individual tests but I guess maybe they are loaded before the rails environment has been initialised?
Thanks
Hello all,
I need some help with a SQL query. Here is what I need to do. I'm lost on a few aspects as outlined below.
I've four relevant tables:
Table A has the price per unit for all resources. I can look up the price using a resource id.
Table B has the funds available to a given user.
Table C has the resource production information for a given user (including the number of units to produce everyday).
Table D has the number of units ever produced by any given user (can be identified by user id and resource id)
Having said that, I need to run a batch job on a nightly basis to do the following:
a. for all users, identify whether they have the funds needed to produce the number of resources specified in table C and deduct the funds if they are available from table B (calculating the cost using table A).
b. start the process to produce resources and after the resource production is complete, update table D using values from table C after the resource product is complete.
I figured the second part can be done by using an UPDATE with a subquery. However, I'm not sure how I should go about doing part a. I can only think of using a cursor to fetch each row, examine and update. Is there a single sql statement that will help me avoid having to process each row manually? Additionally, if any rows weren't updated, the part b. SQL should not produce resources for that user.
Basically, I'm attempting to modify the sql being used for this logic that currently is in a stored procedure to something that will run a lot faster (and won't process each row separately).
Please let me know any ideas and thoughts.
Thanks! - Azeem
I'm making a database program. I want the user to be able to define their own columns, as many as they want. How would I then define each record in its class file?(Since the properties would be different user to user)
EDIT:
It's part of a school assignment-it's going to hold different scores and the likes for the teacher for different students they can add, but they will also be able to add a new assignment, test(a column) .
Im sort of confused by it. The best I could find was reading through the cplusplus.com tutorial and all they have to say about pointers to classes.
"It is perfectly valid to create pointers that point to classes. We simply have to consider that once declared, a class becomes a valid type, so we can use the class name as the type for the pointer"
Which tells me nothing about when to use them over the normal instantiation.
I've seen the - operator many times, and looked at some codes but cant really decipher why they did it.
Generic examples will be appreciated; but more specifically related to gui programming. Its where I encountered it first.
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(nameLabel, 0, 0);
mainLayout->addWidget(nameLine, 0, 1);
mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
mainLayout->addWidget(addressText, 1, 1);
Why not
QGridLayout mainLayout
mainLayout.addWidget
...
(It doesnt compile if I change the sample code to that and try it but you get the point)
Thanks in advance
I'm in love with the function in Eclipse "assign to field". Basically, when I have
getString();
and I type ctrl-2, Eclipse converts this into
String getString = getString();
Is this possible in VS 2010?
Let's assume I have an array of object properties I'd like to access:
$properties = array('foo', 'bar');
I'd like to loop through the object and access these properties dynamically (specifically, I'm trying to dynamically handle missing JSON elements based on an array of expected elements):
foreach ($data as $item) {
foreach ($properties as $property) {
if (empty($item->{$property})) {
// Do something
}
}
}
Each $item in $data should have the properties 'foo' and 'bar'. If empty(), I'll handle them.
I'm trying to get the loop (in line 3) to access $item-{'foo'} and $item-{'bar'}, but it's not working.
Any idea why?
Thanks!
Given this extension method
public static void Until(this Action action, Func<bool> booleanFunc)
{
while (!booleanFunc())
action();
}
is it possible to turn this
var x = 0;
Action ac = () => x += 1;
ac.Until(() => x == 5);
into something of this sort
var x = 0;
(() => x += 1).Until(() => x == 5);
That is, a one liner?
select @[email protected]('*')
for xml raw,type
Above statement will generate following alert:
Msg 6819, Level 16, State 3, Line 2
The FOR XML clause is not allowed in a ASSIGNMENT statement.
Hi,
Recently I saw some code like this:
<tr>
<th> Some label: </th>
<td> <input type="text" value=""/> </td>
<th> Another label: </th>
<td> <input type="text" value=""/> </td>
</tr>
I am used to table headers being used like
<tr>
<th> Some label: </th>
<th> Another label: </th>
</tr>
<tr>
<td> <input type="text" value=""/> </td>
<td> <input type="text" value=""/> </td>
</tr>
How are table headers supposed to be used? The first example above, lead me to some pretty funky formatting issues, and it seems like in example 1 <label> should be used in place of <th>.
I'm writing an web-app that keeps track of deadlines. With this app you have to be able to update records that are being saved in an SQL DB.
However I'm having some problem with my update in my aspx-file.
<asp:GridView ID="gv_editMilestones" runat="server" DataSourceID="sql_ds_milestones"
CellPadding="4" ForeColor="#333333" GridLines="None" Font-Size="Small"
AutoGenerateColumns="False" DataKeyNames="id" Visible="false"
onrowupdated="gv_editMilestones_RowUpdated"
onrowupdating="gv_editMilestones_RowUpdating"
onrowediting="gv_editMilestones_RowEditing">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id"
ReadOnly="True" Visible="false"/>
<asp:BoundField DataField="ms_id" HeaderText="ms_id"
SortExpression="ms_id" ReadOnly="True"/>
<asp:BoundField DataField="ms_description" HeaderText="ms_description"
SortExpression="ms_description"/>
<%-- <asp:BoundField DataField="ms_resp_team" HeaderText="ms_resp_team"
SortExpression="ms_resp_team"/>--%>
<asp:TemplateField HeaderText="ms_resp_team" SortExpression="ms_resp_team">
<ItemTemplate>
<%# Eval("ms_resp_team") %>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DDL_ms_resp_team" runat="server"
DataSourceID="sql_ds_ms_resp_team" DataTextField="team_name"
DataValueField="id">
<%--SelectedValue='<%# Bind("ms_resp_team") %>'--%>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ms_focal_point" HeaderText="ms_focal_point"
SortExpression="ms_focal_point" />
<asp:BoundField DataField="ms_exp_date" HeaderText="ms_exp_date"
SortExpression="ms_exp_date" DataFormatString="{0:d}"/>
<asp:BoundField DataField="ms_deal" HeaderText="ms_deal"
SortExpression="ms_deal" ReadOnly="True"/>
<asp:CheckBoxField DataField="ms_active" HeaderText="ms_active"
SortExpression="ms_active"/>
</Columns>
<FooterStyle BackColor="#CCCC99" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#999999" />
</asp:GridView>
<asp:SqlDataSource ID="sql_ds_milestones" runat="server"
ConnectionString="<%$ ConnectionStrings:testServer %>"
SelectCommand="SELECT [id]
,[ms_id]
,[ms_description]
,(SELECT [team_name] FROM [NSBP].[dbo].[tbl_teams] as teams
WHERE milestones.[ms_resp_team] = teams.[id]) as 'ms_resp_team'
,[ms_focal_point]
,[ms_exp_date]
,(SELECT [deal] FROM [NSBP].[dbo].[tbl_deals] as deals
WHERE milestones.[ms_deal] = deals.[id]) as 'ms_deal'
,[ms_active]
FROM [NSBP].[dbo].[tbl_milestones] as milestones"
UpdateCommand="UPDATE [NSBP].[dbo].[tbl_milestones]
SET [ms_description] = @ms_description
,[ms_focal_point] = @ms_focal_point
,[ms_active] = @ms_active
WHERE [ms_id] = @ms_id">
<UpdateParameters>
<asp:Parameter Name="ms_description" Type="String" />
<%-- <asp:Parameter Name="ms_resp_team" Type="String" />--%>
<asp:Parameter Name="ms_focal_point" Type="String" />
<asp:Parameter Name="ms_exp_date" Type="DateTime" />
<asp:Parameter Name="ms_active" Type="Boolean" />
<%-- <asp:Parameter Name="ms_id" Type="String" />--%>
</UpdateParameters>
</asp:SqlDataSource>
You can see my complete GridView-structure + my datasource bound to this GridView.
There is nothing written in my onrowupdating-function in my code-behind file.
Thx in advance
Hi, i wrote the following code :
NSString *table = [[NSString alloc]initWithString:@"<table>"] ;
for (NSDictionary *row in rows)
{
table = [table stringByAppendingString:@"<tr>"];
NSArray *cells = [row objectForKey:@"cells"];
for (NSString *cell in cells){
table = [table stringByAppendingString:@"<td>"];
table = [table stringByAppendingString:cell];
table = [table stringByAppendingString:@"</td>"];
}
table = [table stringByAppendingString:@"</tr>"];
index++;
}
table = [table stringByAppendingString:@"</table>"];
return [table autorelease];
the rows are json response parsed by jsonlib
this string is returned to a viewcontroller that loads it into a webview ,but i keep getting exc_bad_access for this code on completion of the method that calls it , i don't even have to load it to the webview just calling this method and not using the nsstring causes the error on completion of the calling method... any help will be apperciated thanks .
Hello,
I'm looking for a way to use pthread rwlock structure with conditions routines in C++.
I have two questions:
First: How is it possible and if we can't, why ?
Second: Why current POSIX pthread have not implemented this behaviour ?
To understand my purpose, I explain what will be my use: I've a producer-consumer model dealing with one shared array. The consumer will cond_wait when the array is empty, but rdlock when reading some elems. The producer will wrlock when adding(+signal) or removing elems from the array.
The benefit of using rdlock instead of mutex_lock is to improve performance: when using mutex_lock, several readers would block, whereas using rdlock several readers would not block.
I've recently downloaded Entity Framework Code First CTP5, and have a trouble with this scenario. I have two tables as follows:
Members table
ID
Name
Comments table
ID
Comment
CommentedMemberID
CommentMemberID
And, the data should be like the following:
Members
ID Name
1 Mike
2 John
3 Tom
Comments
ID Comment CommentedMemberID CommentMemberID
1 Good 1 2
2 Good 1 3
3 Bad 2 1
Then, I coded as shown below:
public class Member
{
public int ID {get; set; }
public string Name { get; set;}
public virtual ICollection Comments { get; set;}
}
public class Comment
{
public int ID { get; set; }
public string Comment { get; set; }
public int CommentedMemberID { get; set; }
public int CommentMemberID{ get; set; }
public virtual Member CommentedMember { get; set; }
public virtual Member CommentMember { get; set; }
}
public class TestContext : DbContext
{
public DbSet Members { get; set; }
public DbSet Comments { get; set; }
}
But when I run these models on my cshtml, it gives me errors saying "Cannot create CommentMember instance" or something like that (Sorry, I already changed my models to proceed the EF Code First evaluation, so can't reproduce the same error).
I've also tried to use OnModelCreating on the TestContext, but can't find any good instructions and don't know what to do. I saw a blog post of the EF Code First CTP3, and it seems there was a RelatedTo attribute in that version, but now it has gone.
Could anyone know how to get it work properly? Or is this a totally wrong way to go with this scenario?
Thanks,
Yoo
Let's say we have an empty bathtub. We've lost the plug, so once water is added it will drain away at a constant rate of 2 liters pr. minute. We add water to the tub in increments. 60 liters at 10:51, 30 liters at 11:54 and 50 liters at 13:18.
So, the question is: How can I find out how much water is in the bathtub at any given time?
I have three text boxes on the stage id=red, blue, green same as the keys in my
cars Object/Array
public function carsToBox():void
{
var cars:Object={red:"300zx",blue:"Skyline",green:"Supra"};
for(var tempObj:String in cars)
{
tempObj.text= cars[tempObj];//this trows errors
}
}
So I'm thinking "tempObj.text" would equal red.text but I can't stick "tempObj" with ".text" is there a way this can be done?
I want to organize my c++ variables and functions in the following way: function prototypes in a header file "stuff.h", function implementation in "stuff.cpp", then say #include "stuff.h" in main.cpp (so I can call functions implemented in stuff.cpp). So far so good. Now I want to declare some variables in stuff.cpp that have global scope (so I can modify the variables in functions implemented in stuff.cpp and main.cpp). This doesn't seem to work. How can I do this?
Hi,
I would like to add some debugs for my simple ruby functions and I wrote a function as below,
def debug(&block)
varname = block.call.to_s
puts "#{varname} = #{eval(varname,block)}"
end
debug {:x} #prints x = 5
debug {:y} #prints y = 5
I understand that eval is evil. So I have two questions.
Is there any way to write that debug method without using eval? If NO is there a preferred way to do this?
Is there any way to pass a list of arguments to this method? I would ideally prefer debug {:x, :y. :anynumOfvariables}. I could not quite figure out how to factor that into the debug method (i.e, to take a list of arguments)
Hello All,
I am writing a little install script for some software. All it does is unpack a target tar, and then i want to permanently set some environment variables - principally the location of the unpacked libs and updating $PATH. Do I need to programmatically edit the .bashrc file, adding the appropriate entries to the end for example, or is there another way? What's standard practice?
Thanks
I wonder if the following script can be optimized somehow. It does write a lot to disk because it deletes possibly up-to-date rows and reinserts them. I was thinking about applying something like "insert ... on duplicate key update" and found some possibilities for single-row updates but I don't know how to apply it in the context of INSERT INTO ... SELECT query.
CREATE OR REPLACE FUNCTION update_member_search_index() RETURNS VOID AS $$
DECLARE
member_content_type_id INTEGER;
BEGIN
member_content_type_id := (SELECT id FROM django_content_type WHERE app_label='web' AND model='member');
DELETE FROM watson_searchentry WHERE content_type_id = member_content_type_id;
INSERT INTO watson_searchentry (engine_slug, content_type_id, object_id, object_id_int, title, description, content, url, meta_encoded)
SELECT 'default',
member_content_type_id,
web_member.id,
web_member.id,
web_member.name,
'',
web_user.email||' '||web_member.normalized_name||' '||web_country.name,
'',
'{}'
FROM web_member INNER JOIN web_user ON (web_member.user_id = web_user.id) INNER JOIN web_country ON (web_member.country_id = web_country.id)
WHERE web_user.is_active=TRUE;
END;
$$ LANGUAGE plpgsql;
EDIT: Schemas of web_member, watson_searchentry, web_user, web_country: http://pastebin.com/3tRVPPVi.
(content_type_id, object_id_int) in watson_searchentry is unique pair in the table but atm the index is not present (there is no use for it).
This script should be run at most once a day for full rebuilds of search index.