Given graph, how could i represent it using adj matrix?. I have read lots of tutorials, post, slides, etc but i cant get my head round it, i just need that little push.
I have a table which has employee relationship defined within itself.
i.e.
EmpID Name SeniorId
-----------------------
1 A NULL
2 B 1
3 C 1
4 D 3
and so on...
Where Senior ID is a foreign key whose primary key table is same with refrence column EmpId
I want to clear all rows from this table without removing any constraint. How can i do this?
Deletion need to be performed like this
4, 3 , 2 , 1
How can I do this
I (and co-hackers) are building a sort of trivia game inspired by this blog post:
http://messymatters.com/calibration.
The idea is to give confidence intervals and learn how to be calibrated (when you're "90% sure" you should be right 90% of the time).
We're thus looking for, ideally, thousands of questions with unambiguous numerical answers.
Also, they shouldn't be too boring.
There are a lot of random statistics out there -- eg, enclosed water area in different countries -- that would make the game mind-numbing.
Things like release dates of classic movies are more interesting (to most people).
Other interesting ones we've found include Olympic records, median incomes for different professions, dates of famous inventions, and celebrity ages.
Scraping things like above, by the way, was my reason for asking this question:
http://stackoverflow.com/questions/2611418/scrape-html-tables
So, if you know of other sources of interesting numerical facts (in a parsable form) I'm eager for pointers to them.
Thanks!
Is there any common way to decompose an expression created by [NSPredicate predicateWithFormat] to objects NSComprasionPredicate, NSExpression and other?
For below example need to disassemble into components.
[NSPredicate predicateWithFormat:@"(0 != SUBQUERY(collection, $x, $x.name == "Name").@Count)"];
Hi,
I have to search a 25 GB corpus of wikipedia for a single word. I used grep but it takes lot of time. Is there a efficient and easy representation that can be made to search quickly. Also, I want to find exact match.
Thank you.
Anyone thought about how to write a memory manager (in C++) that is completely branch free? I've written a pool, a stack, a queue, and a linked list (allocating from the pool), but I am wondering how plausible it is to write a branch free general memory manager.
This is all to help make a really reusable framework for doing solid concurrent, in-order CPU, and cache friendly development.
Edit: by branchless I mean without doing direct or indirect function calls, and without using ifs. I've been thinking that I can probably implement something that first changes the requested size to zero for false calls, but haven't really got much more than that.
I feel that it's not impossible, but the other aspect of this exercise is then profiling it on said "unfriendly" processors to see if it's worth trying as hard as this to avoid branching.
Hi,
I'm working on visual studio in an x86. I would like to build my application for both x32 and x64. But i need to use the sqlite .net connector wich has a dll for x86 apps and another dll for x64 apps. How do i configure my visual studio to load a reference when my configuration is x64 and another when my configuration is x86?
Thanks,
Richard.
Hi I am using log4j.xml to log the informations. I have used log4j.xml file for creating the log files. I have given the absolute path for each log file in param tag value.
eg :
appender name="FA" class="org.apache.log4j.DailyRollingFileAppender"
param name="DatePattern" value="'_'yyyyMMdd"/
param name="File" value="D:/logFiles/GPreprocessor.log"/
layout class="com.dnb.genericpreprocessor.common.log.AppXMLLayout"/
/appender
I do not want to give "GPreprocessor.log" directly.Actually that file name is dynamic based on my project. However the location will always remain same as "D:/logFiles/" . Please help me in this as this is very urgent and important for me.
I have standard arithmetic expressions sotred as strings
eg. "WIDTH * 2 + HEIGHT * 2"
In this example WIDTH and HEIGHT
references other objects in my system and the literals
WIDTH and HEIGHT refers to a property (Name) on those
objects.
The problem I'm having is when the Name property on
an expression object changes the expression won't match
anymore.
One solution I came up with is to instead of storing
"WIDTH * 2 + HEIGHT * 2"
i store
"{ID_OF_WIDTH} * 2 + {ID_OF_HEIGHT} * 2"
And let my parser be able to parse this new syntax
and implement an interface or such on referenced objects
IExpressionReference
{
string IdentifierName { get; }
}
Anyone have a better/alternative solution to my problem?
Hi,
I have a dataset that has two datatables.
In the first datatable I have EmpNo,EmpName and EmpAddress
In the second datatable I have Empno,EmpJoindate, EmpSalary.
I want a result where I should show EmpName as the label and his/her details in the gridview
I populate a datalist with the first table, and have EmpNo as the datakeys.
Then I populate the gridview inside the datatable which has EmpNo,EmpJoinDate and EmpAddress.
My code is some what as below
Datalist1.DataSource = dt;
Datalist1.DataBind();
for (int i = 0; i < Datalist1.Items.Count; i++)
{
int EmpNo = Convert.ToInt32(Datalist1.DataKeys[i]);
GridView gv = (GridView)Datalist1.FindControl("gv");
gv.DataSource = dt2;
gv.DataBind();
}
Now I have a problem, I have to bind the Details of the corresponding Employee to the gridview. Whereas the above code will display all the details of all employees in the gridview.
If we use IEnumerable we give a condition where(a=a.eno=EmpNo), and bind that list to the gridview.
How do I do this in datatable.
kindly do not give me suggestions of altering the stored procedure which results the values in two tables, because that cannot be altered.
I have to find a solution within the existing objects I have.
Regards
Hema
I'm trying to make a UITableView that shows a blog post and comments for that post. My setup is a tableview in storyboard with two dynamic prototype cells. The first cell is for the post and should never change. The second cell represents the 0 to N comments.
My cellForRowAtIndexPath method shows the post cell properly, but fails to get the comment at the given index path (though if I comment out the fetch I get the appropriate number of comment cells with a green background that I set as a visual debug thing).
let comment = fetchedResultController.objectAtIndexPath(indexPath) as Comment
I get the following exception on this line:
2014-08-24 15:06:40.712 MessagePosting[21767:3266409] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x0000000101aa43e5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001037f9967 objc_exception_throw + 45
2 CoreFoundation 0x000000010198f4c3 -[__NSArrayM objectAtIndex:] + 227
3 CoreData 0x00000001016e4792 -[NSFetchedResultsController objectAtIndexPath:] + 162
Section and cell setup:
override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
switch section {
case 0:
return 1
default:
if let realPost:Post = post {
return fetchedResultController.sections[0].numberOfObjects
} else {
return 0
}
}
}
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
switch indexPath.section {
case 0:
let cell = tableView.dequeueReusableCellWithIdentifier(postViewCellIdentifier, forIndexPath: indexPath) as UITableViewCell
cell.backgroundColor = lightGrey
if let realPost:Post = self.post {
cell.textLabel.text = realPost.text
}
return cell
default:
let cell = tableView.dequeueReusableCellWithIdentifier(commentCellIdentifier, forIndexPath: indexPath) as UITableViewCell
cell.backgroundColor = UIColor.greenColor()
let comment = fetchedResultController.objectAtIndexPath(indexPath) as Comment // <---------------------------- :(
cell.textLabel.text = comment.text
return cell
}
}
FRC:
func controllerDidChangeContent(controller: NSFetchedResultsController!) {
tableView.reloadData()
}
func getFetchedResultController() -> NSFetchedResultsController {
fetchedResultController = NSFetchedResultsController(fetchRequest: taskFetchRequest(), managedObjectContext: managedObjectContext, sectionNameKeyPath: nil, cacheName: nil)
return fetchedResultController
}
func taskFetchRequest() -> NSFetchRequest {
if let realPost:Post = self.post {
let fetchRequest = NSFetchRequest(entityName: "Comment")
let sortDescriptor = NSSortDescriptor(key: "date", ascending: false)
fetchRequest.predicate = NSPredicate(format: "post = %@", realPost)
fetchRequest.sortDescriptors = [sortDescriptor]
return fetchRequest
} else {
return NSFetchRequest(entityName: "")
}
}
Hui folks,
I need to be able to store numbers like 3.5 in my table. So I've used the decimal type field. But if I enter 3.5 it round it up to 4. Am I being stupid or is it not the point of decimal to have a decimal point?
Thanks,
Jonesy
I am reading my DataTable as follow:
foreach ( DataRow o_DataRow in vco_DataTable.Rows )
{
//Insert More Here
}
It crash; because I insert more records.
How can I read my DataTable without reading the new records? Can I read by RowState?
Thanks
I have a server control that wraps an underlying class which manages a number of indexes to track where it is in a dataset (ie: RenderedRecordCount, ErroredRecordCount, NewRecordCount, etc.). I've got the server control rendering great, but OnDataBinding I'm having an issue as to seems to happen after CreateChildControls and before Render (both of which properly manage the iteration of the underlying indexes).
While I'm somewhat familiar with the ASP.NET page lifecycle, this one seems to be beyond me at the moment. So... How do I hook into the iterative process OnDataBinding uses so I can manage the underlying indexes? Will I have to iterate over the ITemplates myself, managing the indexes as I go or is there an easier solution? [edit: Agh... writing the problem out is very cathartic... I'm thinking this is exactly what I will need to do...]
Also... I implemented the iteration of the underlying indexes during CreateChildControls originally in the belief that was the proper place to hook in for events like OnDataBinding (thinking it was done as the controls were being .Add'd). Now it seems that this may actually be unnecessary. So I guess the secondary question is: What happens during CreateChildControls? Are the unadulterated (read: with various <%-tags in place) controls added to the .Controls collection without any other processing?
Hi,
I have a method which returns an array of fixed type objects (let's say MyObject).
The method creates a new empty Stack<MyObject>. Then, it does some work and pushes some number of MyObjects to the end of the Stack. Finally, it returns the Stack.ToArray().
It does not change already added items or their properties, nor remove them. The number of elements to add will cost performance. There is no need to sort/order the elements.
Is Stack a best thing to use? Or must I switch to Collection or List to ensure better performance and/or lower memory cost?
Hi Guys,
I need to work out a period of 6 months (backwards) from a given date.
Example date:
07/06/2010 00:00:00
needs to count back 6 months and display:
07/12/2009 00:00:00
I have been scanning through: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html and non of these functions make sense to me :(
Hope this makes sense and any help would be appriciated.
Kyle
I am not working with XSLT not too long. I read that variable of XSLT can't be updated on the fly, so how can i do the following task.
I want to sum up Purchase & Sales and put them into a variable, and make some decision according to these values. (For example, if Purchase is greater then sales then do something if not, do something else)
<rows>
<row>
<col attr2="Purchase" >100.00</col>
<col attr2="Sales" >100.00</col>
</row>
<row >
<col attr2="Purchase" >19.16</col>
<col attr2="Sales" >12.94</col>
</row>
<row >
<col attr2="Purchase" >0.67</col>
<col attr2="Sales" >2.74</col>
</row>
<row >
<col attr2="Purchase" >71.95</col>
<col attr2="Sales" >61.54</col>
</row>
<row >
<col attr2="Purchase" >3.62</col>
<col attr2="Sales" >14.72</col>
</row>
<row >
<col attr2="Purchase">8.80</col>
<col attr2="Sales">1.22</col>
</row>
<row >
<col attr2="Purchase" >-4.28</col>
<col attr2="Sales" >6.53</col>
</row>
</rows>
if anyone knows, please help me.
I've got a structure which holds names and ages.
I've made a linked-list of these structures, using this as a pointer:
aNode *rootA;
in my main.
Now i send **rootA to a function like so
addElement(5,"Drew",**rootA);
Because i need to pass rootA by reference so that I can edit it in other functions (in my actual program i have two roots, so return will not work)
The problem is, in my program, i can't say access the structure members.
*rootA->age = 4;
for example doesnt work.
Hopefully you guys can help me out.
Thanks!
I have a table that lists number of comments from a particular site like the following:
Date Site Comments Total
---------------------------------------------------------------
2010-04-01 00:00:00.000 1 5 5
2010-04-01 00:00:00.000 2 8 13
2010-04-01 00:00:00.000 4 2 7
2010-04-01 00:00:00.000 7 13 13
2010-04-01 00:00:00.000 9 1 2
I have another table that lists ALL sites for example from 1 to 10
Site
-----
1
2
...
9
10
Using the following code i can find out which sites are missing entries for the previous month:
SELECT s.site
from tbl_Sites s
EXCEPT
SELECT c.site
from tbl_Comments c
WHERE c.[Date] = DATEADD(mm, DATEDIFF(mm, 0, GetDate()) -1,0)
Producing:
site
-----
3
5
6
8
10
I would like to be able to insert the missing sites that is listed from my query into the comments table with some default values, i.e '0's
Date Site Comments Total
---------------------------------------------------------------
2010-04-01 00:00:00.000 3 0 0
2010-04-01 00:00:00.000 5 0 0
2010-04-01 00:00:00.000 6 0 0
2010-04-01 00:00:00.000 8 0 0
2010-04-01 00:00:00.000 10 0 0
the question is, how did i update/insert the table/values?
cheers,
Lee
I have a class as following
public class ScheduledUpdater
{
private static Queue<int> PendingIDs = new Queue<int>();
private static bool UpdateThreadRunning = false;
private static bool IsGetAndSaveScheduledUpdateRunning = false;
private static DataTable ScheduleConfiguration;
private static Thread updateRefTableThread;
private static Thread threadToGetAndSaveScheduledUpdate;
public static void ProcessScheduledUpdates(int ID)
{
//do some stuff
// if ( updateRefTableThread not already running)
// execute updateRefTableThread = new Thread(new ThreadStart(UpdateSchedulingRefTableInThrear));
// execute updateRefTableThread.Start();
//do some stuff
GetAndSaveScheduledUpdate(ID)
}
private static void UpdateSchedulingRefTableInThrear()
{
UpdateSchedulingRefTable();
}
public static void UpdateSchedulingRefTable()
{
// read DB and update ScheduleConfiguration
string query = " SELECT ID,TimeToSendEmail FROM TBLa WHERE MODE = 'WebServiceOrder' AND BDELETE = false ";
clsCommandBuilder commandBuilder = new clsCommandBuilder();
DataSet ds = commandBuilder.GetDataSet(query);
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
List<string> lstIDs = new List<string>();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
lstIDs.Add(ds.Tables[0].Rows[i]["ID"].ToString());
if (LastEmailSend.Contains(ds.Tables[0].Rows[i]["ID"].ToString()))
LastEmailSend[ds.Tables[0].Rows[i]["ID"].ToString()] = ds.Tables[0].Rows[i]["TimeToSendEmail"].ToString();
else
LastEmailSend.Add(ds.Tables[0].Rows[i]["ID"].ToString(), ds.Tables[0].Rows[i]["TimeToSendEmail"].ToString());
}
if (lstIDs.Count > 0)
{
string Ids = string.Join(",", lstIDs.ToArray()).Trim(',');
dhDBNames dbNames = new dhDBNames();
dbNames.Default_DB_Name = dbNames.ControlDB;
dhGeneralPurpose dhGeneral = new dhGeneralPurpose();
dhGeneral.StringDH = Ids;
DataSet result = commandBuilder.GetDataSet(dbNames, (object)dhGeneral, "xmlGetConfigurations");
if (result != null && result.Tables.Count > 0)
{
if (ScheduleConfiguration != null)
ScheduleConfiguration.Clear();
ScheduleConfiguration = result.Tables[0];
}
}
}
}
public static void GetAndSaveScheduledUpdate(int ID)
{
//use ScheduleConfiguration
if (ScheduleConfiguration == null)[1]
UpdateSchedulingRefTable();
DataRow[] result = ScheduleConfiguration.Select("ID = "+ID);
//then for each result row, i add this to a static Queue PendingIDs
}
}
The function UpdateSchedulingRefTable can be called any time from outside world (for instance if someone updates the schedule configuration manually)
ProcessScheduledUpdates is called from a windows service every other minute.
Problem:
Datatable ScheduleConfiguration is updated in the UpdateSchedulingRefTable (called from outside world - say manually) but when i try to use Datatable ScheduleConfiguration in GetAndSaveScheduledUpdate, i get the older version of values....
What am I missing in this stuff???
About EDIT: I thought the stuff i have not shown is quite obvious and possibly not desired, perhaps my structure is wrong :) and sorry for incorrect code previously, i made a simple function call as a thread initialization... sorry for my code indentation too because i don't know how to format whole block...
I have a vector X that contains positive numbers that I want to bin/discretize. For this vector, I want the numbers [0, 10) to show up just as they exist in the vector, but numbers [10,∞) to be 10+.
I'm using:
x <- c(0,1,3,4,2,4,2,5,43,432,34,2,34,2,342,3,4,2)
binned.x <- as.factor(ifelse(x > 10,"10+",x))
but this feels klugey to me. Does anyone know a better solution or a different approach?
mcpeterson
I am making a restrictive portal to a WiFi network using symfony, and I want to send a form as web service to other sites that want to use this portal. How should I solve this? I realize I could go the SOAP/WSDL route, but since symfony is already RESTful, it seems to me I could go the RESTful route with considerably less pain and loss of performance.
Right now, I have a working form, but I've only made a casual attempt to bring the form to a remote site by using cURL. The form does not work remotely since the routing is not set up correctly (I think). Can someone help me with this?
Thanks.
Hi
I have a file that has a single column of numbers. I have to subtract value in row1 from value in row2, row3-row2; row4-row3 , row5-row4 and so on for all the rows . Could anybody help me out with this ?
I've read the terms of service, and, from what I understand, I'm not allowed to store any information I retrieve from the Google Maps API. Are there any exceptions to this?
More to the point, I'm planning on building an application that shows the user several points of interest (like restaurants, libraries etc) at a certain distance around a location he chooses (it can be in one city or more, depending on the distance he chooses). There are two problems:
The first problem is that (at least for my country) the geocoder doesn't locate exact addresses, at best it only locates street names (but completely ignores street numbers) in larger cities. It is even worse for smaller rural areas. So the only way to accurately show the places on the map is by storing their coordinates in the database.
Another problem seems to be with calculating distances. To show the points located below a certain distance from the user, it would mean I would have to use GDirections to get all distances between the user's location and the other points, to see which ones to show. That would be really slow for the user (since I also have to set a small delay between requests), and it would also send a pretty large amount of requests to google. Would I be allowed to store those distances in a database?
The users would not be able to access a list of all the stored information, they would only see the names of the places, and a map with some markers on it.
Thank you.