I have a table with 42 million records. 32 million have a null value and I would like to generate a new guid for each one. Should I do this in batches?
Also, going forward, I would like a new guid added to the field on the insert of a new record. What is the best way to do this?
The field is not the primary key, which is an auto-incrementing integer.
I'm still kind of undecided which is the best practice to handle em.remove(entity) with this entity being in several collections mapped using mappedBy in JPA.
Consider an entity like a Property that references three other entities: a Descriptor, a BusinessObject and a Level entity. The mapping is defined using @ManyToOne in the Property entity and using @OneToMany(mappedBy...) in the other three objects. That inverse mapping is defined because there are some situations where I need to access those collections.
Whenever I remove a Property using em.remove(prop) this element is not automatically removed from managed entities of the other three types. If I don't care about that and the following page load (webapp) doesn't reload those entities the Property is still found and some decisions might be taken that are no longer true.
The inverse mappings may become quite large and though I don't want to use something like descriptor.getProperties().remove(prop) because it will load all those properties that might have been lazy loaded until then.
So my currently preferred way is to refresh the entity if it is managed: if (em.contains(descriptor)) em.refresh(descriptor) - which unloads a possibly loaded collection and triggers a reload upon the next access.
Is there another feasible way to handle all those mappedBy collections of already loaded entites?
How do I get the number of packages transmitted per TCP connection?
I am using Java, but i know I will have to fetch the number from the underlying OS, so this quastion applies to Linux and Windows operating systems and will have different answers for each of them, I assume.
I need this information to profile the network load of an application which seems to send too many small packages by flushing the socket streams too often.
I have 5 worksheets and a textbox on each worksheet. I would like all the textboxes to display the same value, which would be whatever the user enters in the first textbox. So once a value is entered in textbox1 on sheet1, textbox2 on sheet2, etc. will be populated with the same value.
I'm looking for something like changing linkedcell =WorksheetName!textbox1 although I'm pretty sure that is incorrect.
I have a question regarding float type conversion in Struts2.
I have a form that contains a serie of normal input elements.
A serie of textfields with an add button by the side of each one is included in the window. Clicking on one of this buttons has the effect of adding an input type "hidden" inside the form with the value of its correspondent textfield. That value will often be a float number that, this is very important, uses the point format (example: 1.34).
The inputs created look like this:
<input class="hidden_material" type="hidden" name="form[0].cantidad_formulacion" value='1.34'">
<input class="hidden_material" type="hidden" name="form[1].cantidad_formulacion" value='1.54'">
Anyway, the whole proccess is made correctly until the data is used by the server after the form submission. The numbers are present as if the point wouldn't have been placed in the number (using the example above, as 134).
If a comma is used (as in 1,34), there wouldn't be a problem. But that will not be the case with the users of the system. How could I solve this problem?
I'm in a situation now were I need to convert a datarow I've fetched from a query into a new instance of an object. I can do the obvious looping through columns and 'manually' assign these to properties of the object - or I can look into reflection such as this: http://www.codeproject.com/Articles/11914/Using-Reflection-to-convert-DataRows-to-objects-or
What would I base the decision on? Just scalability??
I would like to know if there's exists some simple code to get to the page i know its ID , I would like to create small input (no matter where in templates)from where the people can easily get to the page if they know it's page ID . I have the girls portfolio in wordpress - portfolio=pages x jobs in clubs offers=posts , I would like the girls portfolios to be easily searchable by ID(s) , if possible the same for the posts=jobs in clubs
I have a mysql table set up like so:
user_id | document
44 [blob]
44 [blob]
44 [blob]
46 [blob]
I'd like to export all of user_id 44's data to an SQLite3 file.
Best way to go about this without writing a script that reads the data and dumps it into a SQLite file?
We need to be able to do a 'sort by relevance' search of a database for our application, but Googling 'sort by relevance custom search' doesn't do much good other than seeing Google Custom Search a 1000 times. It's a Cocoa CoreData database (double alliteration) if that matters. Thanks!
Hi,
How do I check with C if a port on my local machine (if required by passing an IP or interface, too), is in listen state? I don't want to connect to this port for checking because I don't want to irritate the service behind this port.
I want to use this to add the missing net.tcp.listen item to Zabbix.
I was wondering if anyone new how to get access the metadata (the date in particular) from jpg, arw and dng files.
I've recently lost the folder structure after a merge operation gone-bad and would like to rename the recovered files according to the metadata.
I'm planning on creating a little C++ app to dig into each file and get the metadata.
any input is appreciated.
( alternatively, if you know of an app that already does this I'd like to know :)
I have a form in a Compact Framework application. When the user presses the 'X' button in the top right, the screen doesn't refresh until the users taps anywhere on the screen.
The form is being shown using this code:
using (var customerDetailsForm = ObjectFactory.Get<CustomerDetailsForm>())
{
customerDetailsForm.AssignCustomerId(customerId);
customerDetailsForm.ShowDialog();
}
I have a weird situation involving the need of a double inner join. I have tried the query I need, I just don't know how to make rails do it.
The Data
Account (has_many :sites)
Site (habtm :users, belongs_to :account)
User (habtm :sites)
Ignore that they are habtm or whatever, I can make them habtm or has_many :through.
I want to be able to do
@user.accounts
or
@account.users
Then of course I should be able to do
@user.accounts < @some_other_account
And then have @user.sites include all the sites from @some_other_account.
I've fiddled with habtm and has_many :through but can't get it to do what I want.
Basically I need to end up with a query like this (copied from phpmyadmin. Tested and works):
SELECT accounts.*
FROM accounts
INNER JOIN sites ON sites.account_id = accounts.id
INNER JOIN user_sites ON sites.id = user_sites.site_id
WHERE user_sites.user_id = 2
Can I do this? Is it even a good idea to have this double join? I am assuming it would work better if users had the association with accounts to begin with, and then worry about getting @user.sites instead, but it works better for many other things if it is kept the way it is (users <- sites).
def common_elements(list1, list2):
"""
Return a list containing the elements which are in both list1 and list2
>>> common_elements([1,2,3,4,5,6], [3,5,7,9])
[3, 5]
>>> common_elements(['this','this','n','that'],['this','not','that','that'])
['this', 'that']
"""
for element in list1:
if element in list2:
return list(element)
Got that so far, but can't seem to get it to work! Thanks
I have an iPhone application and I am porting it over to Android.
I have a service/controller that spawns new threads to perform some network tasks.
I use performSelectorOnMainThread in my iPhone app. How can I have my Java app do the same or similar thing?
I have a servlet that receives some POST data. Because this data is x-www-form-urlencoded, a string such as ???? would be encoded to サボテン.
How would I unencode this string back to the correct characters? I have tried using URLDecoder.decode("encoded string", "UTF-8"); but it doesn't make a difference.
The reason I would like to unencode them, is because, before I display this data on a webpage, I escape & to & and at the moment, it is escaping the &s in the encoded string so the characters are not showing up properly.
I am exploring a structure of folders with C# projects such as the following:
Projects
ProjectA
ProjectB
ProjectC
ProjectD
Scattered around in the same folders as the .csproj files, there are several solution (.sln) files. Is there a fast way to find all the solutions that contain ProjectD.csproj? I can open them one by one and see what they contain, but I would like a feature such as "find all the solutions containing this project".
What are the implications of using a INSERT INTO foo ... SELECT FROM bar JOIN baz ... style insert statement versus using the same SELECT statement to dump (bar, baz) to a file, and then insert into foo by loading the file?
In my messing around, I haven't seen a huge difference. I would assume the former would use more memory, but the machine that this runs on has 8GB of RAM, and I never even see it go past half used.
Are there any huge (or long term) performance implications that I'm not seeing? Advantages/disadvantages of either?
Say i have loaded some random address like 0x00001234 into eax. Is there a way to test that this address is valid/exists before jumping to it or dereferencing it?
Or do I have to implement an exception handler?
I would like to safely be able to simulate open with O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW and O_CREAT | O_WRONLY | O_APPEND | O_NOFOLLOW on systems that do not support O_NOFOLLOW. I can somewhat achieve what I am asking for with:
struct stat lst;
if (lstat(filename, &lst) != -1 && S_ISLNK(lst.st_mode)) {
errno = ELOOP;
return -1;
}
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
int fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW, mode);
but then I introduce a race condition and possibly a security problem.
I thought about maybe creating a dummy file with only the user being able to write, kind of like touching filename, doing the lstat check, and then using chmod after I finish writing (to correct the file mode bits), but I could be overlooking something major (e.g. if the file at filename exists, is not a regular file, or is already a symbolic link).
What do you think?
I am trying to create a macro that brings in the name of the sheet and combine it with text. For example, for sheet one, I want it to say "ThisIs_Sheet1_Test" in I5 of Sheet1. There are several sheets but it should work for all of them.
What is wrong with my code? I think the underscore might be ruining it all. Here's what I have:
Dim SheetName As String
Public Sub CommandButton1_Click()
SheetName = ActiveSheet.Name
Sheets("Sheet1").Range("I5", "I5") = ThisIs_" & SheetName.text & "_Test
Sheets("Sheet2").Range("H5", "H5") = ThisIs_" & SheetName.text & "_Test
Sheets("Sheet3").Range("G5", "G5") = ThisIs_" & SheetName.text & "_Test
End Sub
Hi.
I have a table in DB which contains summaries for days. Some days may not have the values.
I need to display table with results where each column is a day from user selected range.
I've tried to play with timestamp (end_date - start_date / 86400 - how many days in report, then use DATEDIFF(row_date, 'user_entered_start_date') and create array from this indexes), but now I've got whole bunch of workarounds for summer time :( Any examples or ideas how to make this correct?
P.S. I need to do this on PHP side, because DB is highly loaded.
I am working on a project where I need to embed a web server into my C# application so the application could display it's status via HTTP. I suppose I'll want to configure it through the http also.
I am looking for an open-source library written in C# and with a licensing scheme that will allow me to link it into my existing closed source code (LGPL). Any suggestions of specific products or where to look first?
It would be great if that product could have some kind of scripting, at least templates. All html output would go from the application, only resources would be stored on the disk (images, icons, ...)
EDIT:
I would like it to run under .NET 2.0, however.
Apologies for the vague question. Here it is: I have a table object created by LINQ to SQL. I am copying entries from one table to an "archive" table that has all the columns of the original, plus a couple extra ones.
It feels sloppy to iterate through every object and manually define the mapping like:
foreach (oldTable in dbContextOldTables)
{
var newTable = new NewTable();
newTable.TableID = oldTable.ID;
newTable.Title = oldTable.Title;
... (repeat for twenty columns)
newTable.ColumnThatIsntInOldTable = "Data that will be the same for every row";
dbContext.NewTables.InsertOnSubmit(newTable);
}
dbContext.SubmitChanges();
Is there a clever way to do this?