I have to write a UDP client. Unfortunately, the source system is not always available
Is there a simple tool out there that I can use to create a fake UDP server/traffic on my machine?
I have a method in rails that is doing something like this:
a = Foo.new("bar")
a.save
b = Foo.new("baz")
b.save
...
x = Foo.new("123", :parent_id => a.id)
x.save
...
z = Foo.new("zxy", :parent_id => b.id)
z.save
The problem is this takes longer and longer the more entities I add. I suspect this is because it has to hit the database for every record. Since they are nested, I know I can't save the children before the parents are saved, but I would like to save all of the parents at once, and then all of the children. It would be nice to do something like:
a = Foo.new("bar")
b = Foo.new("baz")
...
saveall(a,b,...)
x = Foo.new("123", :parent_id => a.id)
...
z = Foo.new("zxy", :parent_id => b.id)
saveall(x,...,z)
That would do it all in only two database hits. Is there an easy way to do this in rails, or am I stuck doing it one at a time?
Hi guys,
I've got the scenario with two NSManagedObjects, Arm and Person. Between them is a many-to-one relationship Person.arms and inverse Arm.owner.
I'd like to write a simple NSPredicate where I've got the NSManagedObject *arm and I'd like to fetch the NSManagedObject *person that this arm belongs to. I could make a textual representation and look for that, but is there a better way where I can look it up by identity? Something like this perhaps?
NSEntityDescription *person = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:MOC];
NSPredicate *personPredicate = [NSPredicate predicateWithFormat:@"%@ IN arms", arm];
Cheers
Nik
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!
Hi there
I have a recruitment portal that people can use to advertise and search for jobs.
I would like the recruiters to be able to add a small javascript snippet to their personal websites, that will list jobs on my site.
how can i go about this?
I have webservices set up so the javascript can just call that, but i also need the result to be formatted and placed inline.
This should work in a simular way to google adsense.
I would really appreciate a small example
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
Hi my code is as such
var xhReq = new XMLHttpRequest();
xhReq.open("GET", linksRaw, false);
xhReq.send(null);
var serverResponse = xhReq.responseText;
var tempDiv = document.createElement('div');
tempDiv.innerHTML = serverResponse.replace(/<script(.|\s)*?\/script>/g, '');
var plzWork = tempDiv.getElementsByClassName('organizationID').innerHTML;
console.log(plzWork);
The value of 'plzWork' :-) which is logged to the firebug console is always 'undefined' while the link code is
<a class="organisationID" href="orglists.htm">Partner Organisations</a>
I'm writing this script in the latest versions of Greasemonkey and FF 3.6
Thanks
I do not see any Connection Configure dialog popping up when I try connecting 2 webparts.
I even tried using designer to connect webpart even though it gives me confirmation it does not appear to have been connected.... I am totally clueless.
I have a javascript that is calling a function addData(param1,param2,param3,param4) which is calling addClip at the end
And I need to pass those to a backing bean.
<a4j:form>
<a4j:jsFunction name="addClip" action="#{backingBean.goGo}">
<a4j:actionparam name="param1" assignTo="#{backingBean.param1}"/>
</a4j:jsFunction>
</a4j:form>
But I can't seem to pass any values to the backingbean. I've even tried setting a static value for the actionparam. But when I try to do a Systemout on the setParam1 method it only prints out null. Have I missed anything important?
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 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
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)"];
I have a LAMP server that uses ubuntu 9.10, apache2, mysql5 and php5.
When I login as root through the shell, I run a "ps aux" command and see something like the following
www-data 3151 0.1 4.3 220024 31032 ? S 12:22 0:00 /usr/sbin/apache2 -k start
www-data 3153 0.2 3.6 214776 26020 ? S 12:22 0:01 /usr/sbin/apache2 -k start
www-data 3162 0.3 5.1 225060 36920 ? S 12:26 0:01 /usr/sbin/apache2 -k start
www-data 3163 0.1 4.1 218872 29664 ? S 12:26 0:00 /usr/sbin/apache2 -k start
How come I see multiple lines for www-data? Does each line represent an actual user on my website?
I run into memory issues at times, so I'm trying to determine if these www-data statistics are related.
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.
If you've used GoToMeeting, that's the type of ID I want. I'd like it to be random so that it obfuscates the number of items being tracked and short, so that it's easy to reference manually; UUIDs are way too long. I'd like to avoid hitting persistent storage merely for performance reasons, but I can't think of any other way to avoid collisions. Is 9 digits enough to do something time-based?
I have 2 entities I want to link with KVO, one a single statTracker class that keeps track of different stats and the other an achievement class that contains information about achievements. Ideally what I want to be able to do is set up KVO by having an instance of the achievement class observe a value on the statTracker class and also set up a threshold value at which the achievement instance should be "triggered"(triggering in this case would mean showing a UIAlertView and changing a property on the achievement class.)
I'd like to also set these relationships up on instantiation of the achievement class if possible
so kind of like this:
Achievement *achievement1 = (Achievement *)[NSEntityDescription insertNewObjectForEntityForName:@"Achievement" inManagedObjectContext:[[CoreDataSingleton sharedCoreDataSingleton] managedObjectContext]];
[achievement1 setAchievementName:@"2 time launcher"];
[achievement1 setAchievementDescription:@"So you've decided to come back for more eh? Here are some achievement points to get you going"];
[achievement1 setAchievementPoints:[NSNumber numberWithInt:300];
[achievement1 setObjectToObserve:@"statTrackerInstace"
propertyToObserve:@"timesLaunched"
valueOfPropertToSatisfyAchievement:2]
Anyone out there know how I would set this up? Is there some way I could do this by way of relationships that I'm not seeing?
Thanks,
Nick
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'm looking for recommended validation frameworks, or patterns for an n-tier client application, i wanna write the validation once and ind it to wpf gui, and also for server side and client side related bussiness logic
I have two float arrays representing y values in a line chart. Now I want to align these two charts. Are there any existing algorithms for alignment of the two arrays?
A very simple example
a:
2.5 1.3 1.6 4.2 3.6
b:
3.3 1.4 2.5 1.3 1.6
Now after alignment it should be:
2.5 1.3 1.6 4.2 3.6
3.3 1.4 2.5 1.3 1.6
Hi,
I have a list of rows in an excel sheet which I need to load as historical transactions into a table in my rails applications. I saved the excel file as a csv file. I tried using csv from the standard library but keep getting the following exception CSV::IllegalFormatError.
Not sure how to even figure out where the problem lies. Any suggestions on how to do this.
thanks,
ash
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'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 elements of a list in couchdb documents. Let's say these are 3 elements in 3 documents:
{ "id" : "783587346", "type" : "aList", "content" : "joey", "sort" : 100.0 }
{ "id" : "358734ff6", "type" : "aList", "content" : "jill", "sort" : 110.0 }
{ "id" : "abf587346", "type" : "aList", "content" : "jack", "sort" : 120.0 }
A view retrieves all "aList" documents and displays them sorted by "sort".
Now I want to move the elements, when I want to move "jack" to the middle, I could do this atomic in one write and change it's sort key to 105.0. The view now returns the documents in the new sort order.
After a lot of sorting I could end up with sort keys like 50.99999 and 50.99998 after some years and in extreme situations run out of digits?
What can you recommend, is there a better way to do this? I'd rather keep the elements in seperate documents. Different users might edit different elements in parallel (which also can get tricky).
Maybe there is a much better way?