text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
Trying to make a MySQL-based application support MS SQL, I ran into the following issue:
I keep MySQL's auto\_increment as unsigned integer fields (of various sizes) in order to make use of the full range, as I know there will never be negative values. MS SQL does not support the unsigned attribute on all integer types, so I have to choose between ditching half the value range or creating some workaround.
One very naive approach would be to put some code in the database abstraction code or in a stored procedure that converts between negative values on the db side and values | [
0.17096742987632751,
0.3202739655971527,
0.05110645294189453,
-0.2090679407119751,
-0.1882910579442978,
0.026788951829075813,
0.6165508031845093,
0.05549494922161102,
0.04188603162765503,
-0.18337076902389526,
0.09251169115304947,
0.6930063366889954,
-0.5368664264678955,
-0.009463128633797... | |
from the larger portion of the unsigned range. This would mess up sorting of course, and also it would not work with the auto-id feature (or would it some way?).
I can't think of a *good* workaround right now, is there any? Or am I just being fanatic and should simply forget about half the range?
*Edit:
@Mike Woodhouse: Yeah, I guess you're right. There's still a voice in my head saying that maybe I could reduce the field's size if I optimize its utilization. But if there's no easy way to do this, it's probably not worth worrying about it.*
When | [
0.9182213544845581,
0.13380523025989532,
-0.04016280919313431,
-0.10903313010931015,
0.1040579155087471,
0.11183876544237137,
0.32857179641723633,
-0.04287519305944443,
-0.2117432802915573,
-0.32583045959472656,
0.0009629518608562648,
0.5952791571617126,
-0.031231336295604706,
-0.067886032... | |
is the problem likely to become a real issue?
Given current growth rates, how soon do you expect signed integer overflow to happen in the MS SQL version?
Be pessimistic.
How long do you expect the application to live?
Do you still think the factor of 2 difference is something you should worry about?
(I have no idea what the answers are, but I think we should be sure that we really have a problem before searching any harder for a solution) | [
0.17127487063407898,
0.09018967300653458,
0.5327429175376892,
0.15527570247650146,
0.18255314230918884,
-0.25890493392944336,
0.34562474489212036,
0.21619431674480438,
-0.4400622844696045,
-0.46159517765045166,
0.21054483950138092,
0.35613980889320374,
-0.1674845665693283,
0.13731938600540... | |
How do you stop the designer from auto generating code that sets the value for public properties on a user control?
Use the DesignerSerializationVisibilityAttribute on the properties that you want to hide from the designer serialization and set the parameter to Hidden.
```
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Name
{
get;
set;
}
``` | [
0.22758835554122925,
-0.18305589258670807,
0.012140738777816296,
0.12625126540660858,
0.19765326380729675,
-0.14682626724243164,
0.08132684230804443,
-0.20190967619419098,
-0.15444813668727875,
-0.44174593687057495,
-0.2576989531517029,
0.7842685580253601,
-0.49927520751953125,
0.339357107... | |
I have a database with names in it such as John Doe etc. Unfortunately some of these names contain quotes like Keiran O'Keefe. Now when I try and search for such names as follows:
```
SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe'
```
I (understandably) get an error.
How do I prevent this error from occurring. I am using Oracle and PLSQL.
The escape character is ', so you would need to replace the quote with two quotes.
For example,
`SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe'`
becomes
`SELECT * FROM PEOPLE WHERE SURNAME='O''Keefe'`
That said, it's probably incorrect to do this yourself. Your language may have a function to escape strings | [
0.365524560213089,
0.4639008641242981,
-0.5538936853408813,
0.2926476299762726,
-0.03209514170885086,
-0.1075344905257225,
0.3452901244163513,
-0.14961907267570496,
-0.05340234562754631,
-0.13701856136322021,
0.1345873773097992,
0.26529771089553833,
-0.47600722312927246,
0.1448938548564911... | |
for use in SQL, but an even better option is to use parameters. Usually this works as follows.
Your SQL command would be :
`SELECT * FROM PEOPLE WHERE SURNAME=?`
Then, when you execute it, you pass in "O'Keefe" as a parameter.
Because the SQL is parsed before the parameter value is set, there's no way for the parameter value to alter the structure of the SQL (and it's even a little faster if you want to run the same statement several times with different parameters).
I should also point out that, while your example just causes an error, you open youself up to | [
0.24856452643871307,
0.07255320250988007,
-0.24499887228012085,
-0.14355134963989258,
-0.08028242737054825,
-0.015012107789516449,
0.15678614377975464,
-0.047229960560798645,
-0.048962630331516266,
-0.47975119948387146,
-0.3018696904182434,
0.34055963158607483,
-0.39554262161254883,
0.1412... | |
a lot of other problems by not escaping strings appropriately. See <http://en.wikipedia.org/wiki/SQL_injection> for a good starting point or the following classic [xkcd comic](http://xkcd.com/327/).
 | [
0.0074729821644723415,
-0.13649418950080872,
0.08236713707447052,
0.23940561711788177,
-0.10162553191184998,
-0.08734653145074844,
0.18062818050384521,
-0.3105447292327881,
-0.3276406526565552,
-0.31876200437545776,
-0.2791815996170044,
0.6118128299713135,
-0.2592514753341675,
-0.191351175... | |
I have done a bit of research into this and it seems that the only way to sort a data bound combo box is to sort the data source itself (a DataTable in a DataSet in this case).
If that is the case then the question becomes what is the best way to sort a DataTable?
The combo box bindings are set in the designer initialize using
```
myCombo.DataSource = this.typedDataSet;
myCombo.DataMember = "Table1";
myCombo.DisplayMember = "ColumnB";
myCombo.ValueMember = "ColumnA";
```
I have tried setting
```
this.typedDataSet.Table1.DefaultView.Sort = "ColumnB DESC";
```
But that makes no difference, I have tried setting this in the control constructor, before and after a typedDataSet.Merge call.
If you're | [
-0.18570059537887573,
-0.19251488149166107,
0.3931196331977844,
-0.15594853460788727,
0.22687488794326782,
0.24277064204216003,
-0.07253683358430862,
-0.49704667925834656,
-0.13743269443511963,
-0.9486042261123657,
-0.2252076119184494,
0.3622788190841675,
-0.3756667971611023,
-0.0361244715... | |
using a DataTable, you can use the (DataTable.DefaultView) [DataView.Sort](http://msdn.microsoft.com/en-us/library/system.data.dataview.sort.aspx) property. For greater flexibility you can use the [BindingSource](http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx) component. BindingSource will be the DataSource of your combobox. Then you can change your data source from a DataTable to List without changing the DataSource of the combobox.
> The BindingSource component serves
> many purposes. First, it simplifies
> binding controls on a form to data by
> providing currency management, change
> notification, and other services
> between Windows Forms controls and
> data sources. | [
0.24272191524505615,
-0.2265346199274063,
0.6989162564277649,
0.2985774576663971,
-0.02587391808629036,
-0.20274126529693604,
-0.24954190850257874,
-0.5463894009590149,
-0.32962727546691895,
-1.0687549114227295,
-0.2411012202501297,
0.24508041143417358,
-0.42632949352264404,
0.247138410806... | |
As per my understanding stateless session beans are used to code the business logic. They can not store data in their instance variables because their instance is shared by multiple requests. So they seem to be more like Singleton classes. However the difference is contain creates (or reuses from pool) the separate instance of stateless session beans for every request.
After googling I could find the reasoning that the Java EE specification says they are suppose to be single threaded. But I can't get the reason why the are specified to be **SINGLE THREADED**?
The SLSBs are single threaded because of the | [
0.32336169481277466,
0.13659845292568207,
-0.0185689814388752,
0.15072564780712128,
-0.13759905099868774,
-0.08438171446323395,
0.3284003734588623,
0.09319929778575897,
-0.4497484266757965,
-0.38803383708000183,
-0.026362478733062744,
0.08111201226711273,
-0.5788378715515137,
0.35187673568... | |
TX Context, Principal is associated with a bean instance when it is called. These beans are pooled and unless the max pool size is reached are processed in separate threads ( Vendor dependent).
If SLSBs were designed thread safe every call would have looked like a servlet doGet/Post with request info containing Tx Context , Security Context info and etc. So at least the code looks clean (developer dependent). | [
0.2219713032245636,
-0.37778010964393616,
0.33136436343193054,
0.023047106340527534,
-0.2566985785961151,
-0.027750706300139427,
0.03886033967137337,
-0.12189283221960068,
-0.3265013098716736,
-0.24409228563308716,
-0.06339194625616074,
0.5064128637313843,
-0.44398194551467896,
0.161206871... | |
I have a solution in Visual Studio 2005(professional Edition) which in turn has 8 projects.I am facing a problem that even after i set the Command Arguments in the Project settings of the relevant project, it doesnt accept those command line arguments and it shows argc = 1, inspite of me giving more than 1 command arguments. Tried making the settings of this Solution similar to a working solution, but no success.
Any pointers?
-Ajit.
Hmm.. Are you sure the specified project is set as the start project (right click > set as startup project) ??
Oh, and obviously you need to be | [
0.030421970412135124,
0.042890019714832306,
0.485170841217041,
-0.06927700340747833,
-0.19196350872516632,
0.13003139197826385,
0.19809740781784058,
-0.18314185738563538,
-0.36708444356918335,
-0.3129579722881317,
0.005980819929391146,
0.5988014936447144,
-0.2955309748649597,
0.02965402603... | |
in the correct configuration mode ^\_^
(Notice it can be changed to *debug | build | all configurations* ) | [
0.02396753616631031,
0.008228654973208904,
0.18823331594467163,
-0.2804934084415436,
0.48490503430366516,
-0.11753149330615997,
0.5883991718292236,
0.04014100506901741,
0.013277794234454632,
-0.7073969841003418,
-0.40684428811073303,
0.6017658114433289,
-0.36587417125701904,
0.161379963159... | |
I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder.
What I am doing now is looking up the "date modified" in the shared folder, opened up recent modified documents and use the "Track Change" function in MS Word to apply the changes. I find this a bit tedious.
So will it be better and easier if I commit this in a version control database?
Basically I want to keep | [
0.2514377534389496,
0.42617881298065186,
0.41026854515075684,
-0.07346140593290329,
0.38417938351631165,
0.045309603214263916,
0.3488810956478119,
-0.019056962803006172,
-0.3561190962791443,
-0.6988310813903809,
-0.179136723279953,
0.45035219192504883,
0.19633790850639343,
0.54366552829742... | |
different version of a file.
---
What have I learn from answers:
* Use Time Machine to save different
version (or Shadow copy in Vista)
* There is a difference between text
and binary documents when you use
version control app. (I didn't know
that)
* Diff won't work on binary files
* A notification system (ie email) for revision is great
* Google Docs revision feature.
**Update** :
I played around with Google Docs revision feature and feel that it is almost right for me. Just a bit annoyed with the too frequent versioning (autosaving).
But what feels right for me doesn't mean it feels right for my dept. Will they | [
0.3673963248729706,
0.16569967567920685,
0.619305431842804,
0.09960237145423889,
0.20861698687076569,
-0.034303534775972366,
0.35118022561073303,
0.14189991354942322,
-0.3428508937358856,
-0.8580376505851746,
-0.11153186857700348,
0.6780893802642822,
0.022652849555015564,
0.297719717025756... | |
be okay with saving all these documents with Google?
I guess one thing that nobody seems to have asked is if you have a legal requirement to store history of changes to the doc's?
Whether you do or don't is going to have an impact on what solutions you can consider.
Also a notification mechanism for out of date copies is also a bundle of fun. If engineer A has a copy of a document and engineer B then edits it and commits the changes you want engineer A to be notified that his copy is out of date.
Document control can become a | [
0.4501168131828308,
0.08129619061946869,
0.3455316722393036,
0.3632853627204895,
0.4964183568954468,
-0.4374089539051056,
0.0398109145462513,
0.20087292790412903,
-0.2985978424549103,
-0.6653777360916138,
0.1449832022190094,
0.5315058827400208,
-0.26890912652015686,
0.17119859158992767,
... | |
real can of worms quite easily.
Maybe keep the doc's under CVS or SVN and set it up so that emails are generated to whoever has checked out a copy when updates for the same doc. are checked in to the repository?
Edit: I forgot to add don't forget to use the binary switch, e.g. -kb for CVS, when adding the new doc. Otherwise, you will get any sequences of data that happen to match the ascii for keyword strings having the relevant config management data appended thereby corrupting your doc. data. | [
0.5585474371910095,
-0.0664784237742424,
0.06506987661123276,
0.1189507395029068,
0.04910215735435486,
-0.2538069188594818,
0.2577381134033203,
0.2735261619091034,
0.07764336466789246,
-0.5934327840805054,
0.16369569301605225,
0.9868980646133423,
-0.4132988750934601,
0.20021122694015503,
... | |
We have a Windows Service written in C#. The service spawns a thread that does this:
```
private void ThreadWorkerFunction()
{
while(false == _stop) // stop flag set by other thread
{
try
{
openConnection();
doStuff();
closeConnection();
}
catch (Exception ex)
{
log.Error("Something went wrong.", ex);
Thread.Sleep(TimeSpan.FromMinutes(10));
}
}
}
```
We put the Thread.Sleep in after a couple | [
0.38011258840560913,
-0.08297082781791687,
0.37451595067977905,
-0.21325145661830902,
0.5861473679542542,
-0.14096564054489136,
0.3851551115512848,
0.046576060354709625,
-0.13209384679794312,
-0.7111698389053345,
-0.31271782517433167,
0.5346301198005676,
-0.3032117187976837,
0.357123672962... | |
of times when the database had gone away and we came back to 3Gb logs files full of database connection errors.
This has been running fine for months, but recently we've seen a few instances where the log.Error() statement logs a "System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable" exception and then never ever comes back. The service can be left running for days but nothing more will be logged.
Having done some reading I know that Thread.Sleep is not ideal, but why would it simply never come back?
Dig in and find out? Stick a debugger on that bastard!
I | [
0.549688458442688,
0.3376203179359436,
0.3201946020126343,
0.138666570186615,
0.1818562150001526,
-0.24341188371181488,
0.7422730922698975,
0.34048697352409363,
-0.5907987952232361,
-0.34565499424934387,
0.10538864880800247,
0.3370588421821594,
-0.305817574262619,
0.5385257005691528,
-0.... | |
can see at least the following possibilities:
1. the logging system hangs;
2. the thread exited just fine but the service is still running because some other part has a logic error.
And maybe, but almost certainly not, the following:
* Sleep() hangs.
But in any case, attaching a debugger will show you whether the thread is still there and whether it really has hung. | [
0.6857416033744812,
-0.2149425894021988,
0.30536872148513794,
0.08996478468179703,
0.24763812124729156,
-0.1918935775756836,
0.33497247099876404,
0.005113910883665085,
-0.6910629868507385,
-0.18447555601596832,
-0.203604593873024,
0.28221747279167175,
-0.1174892708659172,
0.209637433290481... | |
I have an application on which I am implementing localization.
I now need to dynamically reference a name in the resouce file.
assume I have a resource file called Login.resx, an a number of strings: foo="hello", bar="cruel" and baz="world"
normally, I will refer as:
String result =Login.foo;
and result=="hello";
my problem is, that at code time, I do not know if I want to refer to foo, bar or baz - I have a string that contains either "foo", "bar" or "baz".
I need something like:
Login["foo"];
Does anyone know if there is any way to dynamically reference a string in a resource file?
You'll need to instance | [
0.18203063309192657,
-0.04895029589533806,
0.3740193843841553,
-0.11195720732212067,
0.12347722798585892,
0.23489350080490112,
0.41708385944366455,
0.02585786208510399,
-0.25170981884002686,
-0.8539565205574036,
-0.11325341463088989,
0.521923840045929,
-0.19983701407909393,
0.6850626468658... | |
a [`ResourceManager`](http://msdn.microsoft.com/en-us/library/aa984408%28VS.71%29.aspx) for the `Login.resx`:
```
var resman = new System.Resources.ResourceManager(
"RootNamespace.Login",
System.Reflection.Assembly.GetExecutingAssembly()
)
var text = resman.GetString("resname");
```
It might help to look at the generated code in the code-behind files of the resource files that are created by the IDE. These files basically contain readonly properties for each resource that makes a query to an internal resource manager. | [
0.05683811008930206,
-0.2527020275592804,
0.3628934621810913,
0.07072876393795013,
0.10015430301427841,
-0.11641361564397812,
0.23714463412761688,
-0.45854946970939636,
-0.27132558822631836,
-0.8027347326278687,
-0.46140462160110474,
0.6764876842498779,
-0.04414032772183418,
0.271910190582... | |
My understanding is that [wxWidgets](http://www.wxwidgets.org) is for a number of programming languages (C++, Python, Perl, and C#/.NET) but that does not include C. Is there a similar framework for the C programming language, or is this not something that C is used for?
You can try [GTK+](http://www.gtk.org/). I believe wxWidgets implementation for linux is written in GTK+. | [
0.5236169695854187,
0.13330420851707458,
0.036726176738739014,
0.025720743462443352,
-0.12614035606384277,
-0.2959716022014618,
0.0644211396574974,
0.05849609524011612,
-0.14155283570289612,
-0.4791770577430725,
-0.014505045488476753,
0.5136695504188538,
-0.362337201833725,
-0.067717276513... | |
I need to match and remove all tags using a regular expression in Perl. I have the following:
```
<\\??(?!p).+?>
```
But this still matches with the closing `</p>` tag. Any hint on how to match with the closing tag as well?
Note, this is being performed on xhtml.
I came up with this:
```
<(?!\/?p(?=>|\s.*>))\/?.*?>
x/
< # Match open angle bracket
(?! # Negative lookahead (Not matching and not consuming)
\/? # 0 or 1 /
p | [
0.343465119600296,
0.16904956102371216,
0.7264518737792969,
-0.3015955090522766,
-0.12973281741142273,
-0.013010614551603794,
-0.14158087968826294,
-0.5158860087394714,
0.13275568187236786,
-0.36284762620925903,
0.034515880048274994,
0.8062978982925415,
-0.4910166561603546,
-0.228043645620... | |
# p
(?= # Positive lookahead (Matching and not consuming)
> # > - No attributes
| # or
\s # whitespace
.* # anything up to
> # close angle brackets - with attributes
) | [
0.1635904759168625,
0.24512849748134613,
0.37268736958503723,
0.00409446656703949,
0.10578442364931107,
0.36257705092430115,
-0.0666109248995781,
-0.4280218780040741,
-0.09611739963293076,
-0.5173617005348206,
-0.17562676966190338,
0.565839946269989,
-0.2637127935886383,
-0.400331795215606... | |
# close positive lookahead
) # close negative lookahead
# if we have got this far then we don't match
# a p tag or closing p tag
# with or without attributes
\/? # optional close tag symbol (/)
.*? | [
0.16123321652412415,
0.2182713896036148,
0.8088587522506714,
-0.06491474062204361,
-0.19575920701026917,
0.016497334465384483,
0.36936312913894653,
-0.13687388598918915,
0.06835100799798965,
-0.4176974892616272,
-0.3056013882160187,
0.6696939468383789,
-0.18400366604328156,
-0.371156096458... | |
# and anything up to
> # first closing tag
/
```
This will now deal with p tags with or without attributes and the closing p tags, but will match pre and similar tags, with or without attributes.
It doesn't strip out attributes, but my source data does not put them in. I may change this later to do this, but this will suffice for now. | [
0.13864904642105103,
0.1648392677307129,
0.5911729335784912,
0.010159877128899097,
-0.0855831578373909,
-0.16992056369781494,
-0.1358243077993393,
-0.13910125195980072,
-0.03724491223692894,
-0.7413846254348755,
-0.21358217298984528,
0.7180642485618591,
-0.1474868208169937,
-0.434055179357... | |
What I am trying to do is change the background colour of a table cell <td> and then when a user goes to print the page, the changes are now showing.
I am currently using an unobtrusive script to run the following command on a range of cells:
```
element.style.backgroundColor = "#f00"
```
This works on screen in IE and FF, however, when you go to Print Preview, the background colours are lost.
Am I doing something wrong?
Have you tried hard-coding the values just to see if background-colors are showing on the print-preview at all? I think it is a setting in the Browser. | [
0.45132315158843994,
0.06216507405042648,
0.450274258852005,
-0.3457161486148834,
-0.07980797439813614,
0.08388479799032211,
0.34636130928993225,
-0.091956228017807,
-0.2112039476633072,
-0.862194299697876,
0.16962425410747528,
0.5191953182220459,
-0.36834636330604553,
0.035780228674411774... | |
My automated script for starting and stopping VMWare Server virtual machines has stopped working. vmware-cmd has started raising the error:
> The ordinal 3288 could not be located in the dynamic link library LIBEAY32.dll.
I am not aware of any specific change or update when this started happening.
I have found a bunch of other people reporting this problem (or very similar) but no solution.
Do you know what caused this error, and/or how to fix this?
Have discovered that this only occurs when the script is run on a different drive to the one where the EXE is located. As a work around | [
0.32916930317878723,
0.2076173573732376,
0.15832914412021637,
0.22155293822288513,
-0.026547426357865334,
-0.18087691068649292,
0.3976336419582367,
0.23268884420394897,
-0.3551532030105591,
-0.500014066696167,
0.09049101918935776,
0.6312700510025024,
-0.20226356387138367,
0.358309626579284... | |
for this I have simply moved the scripts execution.
Apparently the DLL relates to SSL, which isn't relevant to what I'm doing, so this is a suitable workaround. I'm guessing that the problem is caused by changes in the EXE for how it determines relative paths (unlikley as nothing (AFAICT) has changed). Or the %PATH% environmental variable has changed (more likely).
Hope this helps someone in the future. | [
0.21134434640407562,
-0.05515202879905701,
0.3327726423740387,
0.021533114835619926,
-0.0569550022482872,
0.0386103093624115,
0.37889906764030457,
0.03299061208963394,
-0.20865271985530853,
-0.8350401520729065,
0.1490277498960495,
0.4728935658931732,
-0.26468658447265625,
0.207610219717025... | |
Can someone please tell me how to submit an HTML form when the return key is pressed and if there are no buttons in the form?
**The submit button is not there**. I am using a custom div instead of that.
IMO, this is the cleanest answer:
```html
<form action="" method="get">
Name: <input type="text" name="name"/><br/>
Pwd: <input type="password" name="password"/><br/>
<div class="yourCustomDiv"/>
<input type="submit" style="display:none"/>
</form>
```
Better yet, if you are using javascript to submit the form using the custom div, you should also use javascript to create it, and to set the display:none style on the button. This way users with | [
0.19402895867824554,
0.0605442188680172,
0.3610652685165405,
0.14799334108829498,
-0.13716277480125427,
-0.3035183548927307,
0.3656943440437317,
-0.28736305236816406,
-0.17786674201488495,
-0.9716307520866394,
-0.08478831499814987,
0.41647422313690186,
-0.14975756406784058,
-0.025057662278... | |
javascript disabled will still see the submit button and can click on it.
---
It has been noted that display:none will cause IE to ignore the input. I created a [new JSFiddle example](http://jsfiddle.net/Suyw6/1/) that starts as a standard form, and uses progressive enhancement to hide the submit and create the new div. I did use the CSS styling from [StriplingWarrior](https://stackoverflow.com/questions/29943/how-to-submit-a-form-when-the-return-key-is-pressed/6602788#6602788). | [
0.12663565576076508,
-0.004767194855958223,
0.6200023889541626,
-0.24620011448860168,
-0.2688208222389221,
-0.3594225347042084,
0.334552526473999,
-0.45807430148124695,
0.01968315802514553,
-0.9454329609870911,
-0.33456820249557495,
0.4526911675930023,
-0.1702217012643814,
-0.2920481562614... | |
So I'm working on some legacy code that's heavy on the manual database operations. I'm trying to maintain some semblance of quality here, so I'm going TDD as much as possible.
The code I'm working on needs to populate, let's say a `List<Foo>` from a DataReader that returns all the fields required for a functioning Foo. However, if I want to verify that the code in fact returns one list item per one database row, I'm writing test code that looks something like this:
```
Expect.Call(reader.Read()).Return(true);
Expect.Call(reader["foo_id"]).Return((long) 1);
// ....
Expect.Call(reader.Read()).Return(true);
Expect.Call(reader["foo_id"]).Return((long) 2);
// ....
Expect.Call(reader.Read()).Return(false);
```
Which is rather tedious and rather easily broken, too.
How should I be approaching | [
0.30635085701942444,
0.3619653582572937,
0.0866457149386406,
-0.16869257390499115,
-0.08244135230779648,
-0.05023849010467529,
0.3758859634399414,
-0.2448665350675583,
0.005482763517647982,
-0.48131677508354187,
-0.07324449717998505,
0.8621033430099487,
-0.24806353449821472,
-0.02477836981... | |
this issue so that the result won't be a huge mess of brittle tests?
Btw I'm currently using Rhino.Mocks for this, but I can change it if the result is convincing enough. Just as long as the alternative isn't TypeMock, because their EULA was a bit too scary for my tastes last I checked.
Edit: I'm also currently limited to C# 2.
To make this less tedious, you will need to encapsulate/refactor the mapping between the DataReader and the Object you hold in the list. There is quite of few steps to encapsulate that logic out. If that is the road you want | [
0.34637829661369324,
0.4662491977214813,
0.22769489884376526,
0.15218022465705872,
-0.016788676381111145,
0.1570426970720291,
0.41203486919403076,
0.03865367919206619,
-0.2720637321472168,
-0.5616610050201416,
0.04318360984325409,
0.5830914378166199,
0.002268509939312935,
0.115525573492050... | |
to take, I can post code for you. I am just not sure how practical it would be to post the code here on StackOverflow, but I can give it a shot to keep it concise and to the point. Otherwise, you are stuck with the tedious task of repeating each expectation on the index accessor for the reader. The encapsulation process will also get rid of the strings and make those strings more reusable through your tests.
Also, I am not sure at this point how much you want to make the existing code more testable. Since this is legacy | [
0.7423025369644165,
-0.05007962882518768,
0.04170677065849304,
0.3116037845611572,
0.05359342321753502,
-0.2550849914550781,
0.056177474558353424,
-0.031388379633426666,
-0.13678215444087982,
-0.7362303733825684,
0.3812936842441559,
0.3674050569534302,
-0.16626203060150146,
0.1270215362310... | |
code that wasn't built with testing in mind. | [
0.4265534281730652,
0.1543411761522293,
-0.44567427039146423,
0.5249934792518616,
-0.10097900032997131,
-0.1733955442905426,
0.3405148684978485,
-0.22352544963359833,
0.28113505244255066,
-0.2901540994644165,
0.19019216299057007,
0.1362117975950241,
-0.2380298227071762,
-0.1697806268930435... | |
I want to practice my skills away from a keyboard (i.e. pen and paper) and I'm after simple practice questions like Fizz Buzz, Print the first N primes.
What are your favourite simple programming questions?
I've been working on <http://projecteuler.net/> | [
0.61170494556427,
-0.07852573692798615,
0.073806531727314,
-0.08384441584348679,
0.18146038055419922,
0.06589046120643616,
-0.0051375278271734715,
0.1510390192270279,
-0.10454050451517105,
-0.6560515761375427,
0.15400594472885132,
0.42163169384002686,
0.01870371773838997,
-0.23051922023296... | |
I have the following html code:
```
<h3 id="headerid"><span onclick="expandCollapse('headerid')">⇑</span>Header title</h3>
```
I would like to toggle between up arrow and down arrow each time the user clicks the span tag.
```
function expandCollapse(id) {
var arrow = $("#"+id+" span").html(); // I have tried with .text() too
if(arrow == "⇓") {
$("#"+id+" span").html("⇑");
} else { | [
0.08837967365980148,
-0.07878738641738892,
0.9754047989845276,
-0.5054144859313965,
0.09579531848430634,
0.10963167250156403,
-0.11317168176174164,
-0.6067769527435303,
-0.11247547715902328,
-0.7595121264457703,
0.14438532292842865,
0.8162978887557983,
-0.17190201580524445,
-0.128795072436... | |
$("#"+id+" span").html("⇓");
}
}
```
My function is going always the else path. If I make a javacript:alert of `arrow` variable I am getting the html entity represented as an arrow. How can I tell jQuery to interpret the `arrow` variable as a string and not as html.
When the HTML is parsed, what JQuery sees in the DOM is a `UPWARDS DOUBLE ARROW` ("⇑"), not the entity reference. Thus, in your Javascript code you should test for `"⇑"` or | [
-0.06402593106031418,
0.0722694844007492,
0.7500033378601074,
-0.33047720789909363,
-0.16695505380630493,
0.010999348014593124,
0.37304750084877014,
-0.47528836131095886,
-0.3322620391845703,
-0.3867637813091278,
-0.03788306564092636,
0.736292839050293,
-0.41272297501564026,
-0.23837175965... | |
`"\u21d1"`. Also, you need to change what you're switching to:
```
function expandCollapse(id) {
var arrow = $("#"+id+" span").html();
if(arrow == "\u21d1") {
$("#"+id+" span").html("\u21d3");
} else {
$("#"+id+" span").html("\u21d1"); | [
0.10098527371883392,
-0.19015344977378845,
0.7671896815299988,
-0.6260262727737427,
-0.008021024987101555,
0.008025143295526505,
0.17295198142528534,
-0.49468129873275757,
-0.28389716148376465,
-0.6609112024307251,
-0.3884638249874115,
0.8519243001937866,
-0.37631165981292725,
-0.336701780... | |
}
}
``` | [
0.17493881285190582,
0.41805654764175415,
0.05209751054644585,
-0.04864929988980293,
0.437467485666275,
-0.15825650095939636,
0.13202530145645142,
0.5446501970291138,
0.35430577397346497,
-0.4846813380718231,
-0.2295716553926468,
0.546978771686554,
-0.3188462555408478,
0.2798506021499634,
... | |
I have to load a PDF within a page.
Ideally I would like to have a loading animated gif which is replaced once the PDF has loaded.
I'm pretty certain that it cannot be done.
Pretty much anything else than PDF works, even Flash. (Tested on Safari, Firefox 3, IE 7)
Too bad. | [
0.09184606373310089,
0.174757719039917,
0.48430347442626953,
0.09966250509023666,
-0.22270998358726501,
-0.39120256900787354,
0.32842257618904114,
0.29525426030158997,
-0.2128325253725052,
-0.6748235821723938,
-0.05521447956562042,
0.6134808659553528,
-0.14233039319515228,
-0.1220902353525... | |
How can I use XPath to select an XML-node based on its content?
If I e.g. have the following xml and I want to select the <author>-node that contains Ritchie to get the author's full name:
```
<books>
<book isbn='0131103628'>
<title>The C Programming Language</title>
<authors>
<author>Ritchie, Dennis M.</author>
<author>Kernighan, Brian W.</author>
</authors>
</book> | [
0.3833518922328949,
0.626331090927124,
-0.2581599950790405,
-0.07099082320928574,
-0.022996777668595314,
0.02315882034599781,
-0.12025122344493866,
-0.07006760686635971,
-0.13396300375461578,
-0.22209835052490234,
0.015608237124979496,
0.24654358625411987,
-0.30870896577835083,
0.009967918... | |
<book isbn='1590593898'>
<title>Joel on Software</title>
<authors>
<author>Spolsky, Joel</author>
</authors>
</book>
</books>
```
```
/books/book/authors/author[contains(., 'Ritchie')]
```
or
```
//author[contains(., 'Ritchie')]
``` | [
-0.20186589658260345,
0.39862436056137085,
-0.09663329273462296,
0.2288583666086197,
0.2712146043777466,
0.2979874908924103,
0.12434325367212296,
0.0440797358751297,
0.2483901083469391,
-0.4610552191734314,
-0.24793381989002228,
0.30711662769317627,
-0.1036670058965683,
0.24426302313804626... | |
Is there some way to do multi-threading in JavaScript?
See <http://caniuse.com/#search=worker> for the most up-to-date support info.
The following was the state of support circa 2009.
---
The words you want to google for are [JavaScript Worker Threads](http://www.google.com/search?q=JavaScript+worker+threads)
Apart from from [Gears](http://gears.google.com/) there's nothing available right now, but there's plenty of talk about how to implement this so I guess watch this question as the answer will no doubt change in future.
Here's the relevant documentation for Gears: [WorkerPool API](http://code.google.com/apis/gears/api_workerpool.html)
WHATWG has a Draft Recommendation for worker threads: [Web Workers](http://www.whatwg.org/specs/web-workers/current-work/)
And there's also Mozilla’s [DOM Worker Threads](https://wiki.mozilla.org/DOMWorkerThreads)
---
**Update:** June 2009, current state of browser support for JavaScript threads
**Firefox 3.5** | [
0.14596858620643616,
0.24378333985805511,
0.3880388140678406,
-0.116468146443367,
-0.059114642441272736,
0.24359282851219177,
0.21832036972045898,
0.06825415045022964,
-0.3898888826370239,
-0.5117270350456238,
0.10223329067230225,
0.5578494071960449,
-0.24184976518154144,
-0.13101148605346... | |
has web workers. Some demos of web workers, if you want to see them in action:
* [Simulated Annealing](http://blog.mozbox.org/post/2009/04/10/Web-Workers-in-action) ("Try it" link)
* [Space Invaders](https://web.archive.org/web/20120406122342/https://developer.mozilla.org/web-tech/2008/12/04/web-workers-part-2) (link at end of post)
* [MoonBat JavaScript Benchmark](http://www.yafla.com/dforbes/Web_Workers_and_You__A_Faster_More_Powerful_JavaScript_World) (first link)
The Gears plugin can also be installed in Firefox.
**Safari 4**, and the **WebKit nightlies** have worker threads:
* [JavaScript Ray Tracer](http://blog.owensperformance.com/2009/02/safari-4-worker-threads-javascript-domination/)
**Chrome** has Gears baked in, so it can do threads, although it requires a confirmation prompt from the user (and it uses a different API to web workers, although it will work in any browser with the Gears plugin installed):
* [Google Gears WorkerPool Demo](http://code.google.com/apis/gears/samples/hello_world_workerpool/hello_world_workerpool.html) (not a good example as | [
0.4640721380710602,
0.0509396456182003,
0.11087293177843094,
0.009751379489898682,
-0.11358872801065445,
0.18503764271736145,
0.006064221262931824,
-0.08538495004177094,
-0.3577089309692383,
-0.7524697780609131,
-0.10119667649269104,
0.493721067905426,
-0.13983166217803955,
-0.286229670047... | |
it runs too fast to test in Chrome and Firefox, although IE runs it slow enough to see it blocking interaction)
**IE8** and **IE9** can only do threads with the Gears plugin installed | [
0.16956499218940735,
-0.055292073637247086,
0.4628238081932068,
-0.09910302609205246,
0.2191496342420578,
0.02635110542178154,
0.17083455622196198,
0.16451936960220337,
0.010902072302997112,
-0.9941316843032837,
0.1775265336036682,
0.7986376881599426,
-0.24566425383090973,
-0.1529763191938... | |
The [Apple Developer Documentation](http://developer.apple.com/documentation/AppleApplications/Reference/SafariWebContent/UsingiPhoneApplications/chapter_6_section_4.html) (link is dead now) explains that if you place a link in a web page and then click it whilst using Mobile Safari on the iPhone, the Google Maps application that is provided as standard with the iPhone will launch.
How can I launch the same Google Maps application with a specific address from within my own native iPhone application (i.e. not a web page through Mobile Safari) in the same way that tapping an address in Contacts launches the map?
**NOTE: THIS ONLY WORKS ON THE DEVICE ITSELF. NOT IN THE SIMULATOR.**
For iOS 5.1.1 and lower, use | [
0.11085151135921478,
0.15054239332675934,
0.5017304420471191,
0.06314319372177124,
0.19286906719207764,
-0.05428213253617287,
0.22252590954303741,
-0.03534093126654625,
-0.3624032735824585,
-0.541628897190094,
-0.11347364634275436,
0.44257059693336487,
-0.09018149971961975,
-0.199341863393... | |
the `openURL` method of `UIApplication`. It will perform the normal iPhone magical URL reinterpretation. so
```
[someUIApplication openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=London"]]
```
should invoke the Google maps app.
From iOS 6, you'll be invoking Apple's own Maps app. For this, configure an `MKMapItem` object with the location you want to display, and then send it the `openInMapsWithLaunchOptions` message. To start at the current location, try:
```
[[MKMapItem mapItemForCurrentLocation] openInMapsWithLaunchOptions:nil];
```
You'll need to be linked against MapKit for this (and it will prompt for location access, I believe). | [
-0.3227442502975464,
0.04830080270767212,
0.9949168562889099,
-0.021507639437913895,
-0.11858958750963211,
-0.2031620740890503,
0.3566325902938843,
-0.02179919369518757,
-0.20431193709373474,
-0.771018385887146,
-0.5589105486869812,
0.1886553317308426,
-0.20875142514705658,
0.1607137471437... | |
I just listened to the StackOverflow team's 17th podcast, and they talked so highly of [ASP.NET MVC](http://www.asp.net/mvc/) that I decided to check it out.
But first, I want to be sure it's worth it. I already created a base web application (for other developers to build on) for a project that's starting in a few days and wanted to know, based on your experience, if I should take the time to learn the basics of MVC and re-create the base web application with this model.
Are there really big pros that'd make it worthwhile?
EDIT: It's not an existing project, it's a project | [
0.7890405654907227,
0.10201814770698547,
0.30862918496131897,
0.028785258531570435,
0.05192342400550842,
-0.37727198004722595,
-0.06249594688415527,
-0.046628307551145554,
-0.31822213530540466,
-0.4974340796470642,
0.34814581274986267,
0.5219318270683289,
0.19345150887966156,
0.00284765660... | |
about to start, so if I'm going to do it it should be now...
---
I just found this
> It does not, however, use the existing post-back model for interactions back to the server. Instead, you'll route all end-user interactions to a Controller class instead - which helps ensure clean separation of concerns and testability (**it also means no viewstate or page lifecycle with MVC based views**).
How would that work? No viewstate? No events?
If you are quite happy with WebForms today, then maybe ASP.NET MVC isn't for you.
I have been frustrated with WebForms for a really long time. I'm definitely not alone | [
0.33449575304985046,
-0.2337283343076706,
0.6329962015151978,
0.12007596343755722,
-0.2104593813419342,
-0.31730344891548157,
0.08221106231212616,
0.10344642400741577,
-0.3926037549972534,
-0.9625515937805176,
0.14561080932617188,
0.35156121850013733,
-0.06894552707672119,
0.47518095374107... | |
here. The smart-client, stateful abstraction over the web breaks down severely in complex scenarios. I happen to love HTML, Javascript, and CSS. WebForms tries to hide that from me. It also has some really complex solutions to problems that are really not that complex. Webforms is also inherently difficult to test, and while you can use MVP, it's not a great solution for a web environment...(compared to MVC).
MVC will appeal to you if...
- you want more control over your HTML
- want a seamless ajax experience like every other platform has
- want testability through-and-through
- want meaningful URLs
- HATE dealing with postback | [
0.25359299778938293,
0.27945631742477417,
-0.03996538370847702,
0.40402573347091675,
-0.4107385277748108,
-0.33823248744010925,
0.13126030564308167,
0.16323821246623993,
-0.25647425651550293,
-0.7634850144386292,
0.19536608457565308,
0.3799319863319397,
-0.15419499576091766,
0.042752902954... | |
& viewstate issues
And as for the framework being Preview 5, it is quite stable, the design is mostly there, and upgrading is not difficult. I started an app on Preview 1 and have upgraded within a few hours of the newest preview being available. | [
0.5256654620170593,
-0.20958282053470612,
0.71783846616745,
0.17103353142738342,
-0.24154315888881683,
-0.23036669194698334,
0.007090000435709953,
-0.0560636930167675,
0.2318478673696518,
-0.9347941875457764,
0.27879953384399414,
0.7900000810623169,
-0.0074206008575856686,
0.11414445191621... | |
I have two points (a line segment) and a rectangle. I would like to know how to calculate if the line segment intersects the rectangle.
From my "Geometry" class:
```
public struct Line
{
public static Line Empty;
private PointF p1;
private PointF p2;
public Line(PointF p1, PointF p2)
{
this.p1 = p1;
this.p2 = p2;
}
public PointF P1
{ | [
-0.48484325408935547,
-0.3601427674293518,
0.7403947114944458,
-0.12651397287845612,
-0.12015130370855331,
0.31183379888534546,
-0.0702023059129715,
-0.2568257749080658,
-0.031270354986190796,
-0.687193751335144,
-0.3543643057346344,
-0.06717697530984879,
-0.1197454184293747,
0.19870492815... | |
get { return p1; }
set { p1 = value; }
}
public PointF P2
{
get { return p2; }
set { p2 = value; }
}
public float X1
{
get { return p1.X; }
set { p1.X = value; } | [
-0.5215835571289062,
-0.1584189534187317,
0.2778730094432831,
0.0860324427485466,
0.02467045933008194,
0.26955363154411316,
-0.05408450588583946,
-0.2981891632080078,
0.2628627419471741,
-0.27880653738975525,
-0.42889314889907837,
0.2625306248664856,
-0.25529468059539795,
-0.47513732314109... | |
}
public float X2
{
get { return p2.X; }
set { p2.X = value; }
}
public float Y1
{
get { return p1.Y; }
set { p1.Y = value; }
}
public float Y2
{
get { return | [
-0.16498619318008423,
-0.0983145534992218,
0.0652146190404892,
0.1981925368309021,
0.1126546710729599,
0.14281624555587769,
-0.014591383747756481,
-0.16582196950912476,
0.07389219105243683,
-0.2867184579372406,
-0.43755248188972473,
0.5040788054466248,
-0.2652057409286499,
-0.2934342026710... | |
p2.Y; }
set { p2.Y = value; }
}
}
public struct Polygon: IEnumerable<PointF>
{
private PointF[] points;
public Polygon(PointF[] points)
{
this.points = points;
}
public PointF[] Points
{
get { return points; }
set { points = value; }
}
public int Length | [
-0.3528199791908264,
-0.17493459582328796,
0.5763841867446899,
-0.07878551632165909,
-0.25902867317199707,
0.4043404161930084,
0.023699799552559853,
-0.18360334634780884,
-0.313876748085022,
-0.5905176401138306,
-0.36800074577331543,
0.053371820598840714,
0.04084046557545662,
0.02564819715... | |
{
get { return points.Length; }
}
public PointF this[int index]
{
get { return points[index]; }
set { points[index] = value; }
}
public static implicit operator PointF[](Polygon polygon)
{
return polygon.points;
}
public static implicit operator Polygon(PointF[] points)
{ | [
-0.4832375943660736,
-0.1405685544013977,
0.27687355875968933,
-0.08963552117347717,
-0.3495083749294281,
0.4497923254966736,
0.013751943595707417,
-0.12224430590867996,
-0.18151597678661346,
-0.624388575553894,
-0.3473464846611023,
0.09658454358577728,
-0.26085805892944336,
-0.05470986291... | |
return new Polygon(points);
}
IEnumerator<PointF> IEnumerable<PointF>.GetEnumerator()
{
return (IEnumerator<PointF>)points.GetEnumerator();
}
public IEnumerator GetEnumerator()
{
return points.GetEnumerator();
}
}
public enum Intersection
{
None,
Tangent,
Intersection,
Containment
}
public static class Geometry
{
public static Intersection IntersectionOf(Line line, Polygon polygon)
{
if (polygon.Length == | [
-0.3675643801689148,
-0.30615735054016113,
0.4683237075805664,
0.12661370635032654,
-0.15298224985599518,
0.31940537691116333,
0.08131254464387894,
-0.24041791260242462,
-0.2080637514591217,
-0.8424353003501892,
-0.436764657497406,
0.26382461190223694,
-0.1622324287891388,
0.20501439273357... | |
0)
{
return Intersection.None;
}
if (polygon.Length == 1)
{
return IntersectionOf(polygon[0], line);
}
bool tangent = false;
for (int index = 0; index < polygon.Length; index++) | [
-0.4818868637084961,
-0.23595377802848816,
0.5781073570251465,
-0.09184246510267258,
-0.11955748498439789,
0.33963248133659363,
0.3645574748516083,
-0.006408658344298601,
-0.19278208911418915,
-0.5779810547828674,
-0.33293020725250244,
0.342449426651001,
-0.247764453291893,
-0.004815760999... | |
{
int index2 = (index + 1)%polygon.Length;
Intersection intersection = IntersectionOf(line, new Line(polygon[index], polygon[index2]));
if (intersection == Intersection.Intersection)
{
return intersection;
} | [
-0.5317882895469666,
-0.11629045754671097,
0.5946183800697327,
-0.09689312428236008,
-0.013967053964734077,
0.4203323721885681,
0.19022096693515778,
-0.21982374787330627,
-0.229579895734787,
-0.6782650351524353,
-0.241889089345932,
0.17803841829299927,
-0.43384039402008057,
0.0387968495488... | |
if (intersection == Intersection.Tangent)
{
tangent = true;
}
}
return tangent ? Intersection.Tangent : IntersectionOf(line.P1, polygon);
}
public static Intersection IntersectionOf(PointF point, Polygon polygon)
{ | [
-0.751558244228363,
-0.31877070665359497,
0.6198674440383911,
0.09955175220966339,
-0.09308652579784393,
0.45783936977386475,
-0.013958322815597057,
0.17976722121238708,
-0.197670117020607,
-0.5507866144180298,
-0.4222193658351898,
0.4046276807785034,
-0.22884050011634827,
-0.0528456717729... | |
switch (polygon.Length)
{
case 0:
return Intersection.None;
case 1:
if (polygon[0].X == point.X && polygon[0].Y == point.Y)
{ | [
0.03859914094209671,
-0.2678554952144623,
0.29326313734054565,
0.024306176230311394,
0.05743759870529175,
0.11735732853412628,
-0.0002624139015097171,
-0.3277910351753235,
-0.4070013165473938,
-0.5290147662162781,
-0.34660378098487854,
0.1669320911169052,
-0.25234344601631165,
0.0844840630... | |
return Intersection.Tangent;
}
else
{
return Intersection.None;
} | [
-0.5164809823036194,
0.013981963507831097,
0.40086832642555237,
-0.10917877405881882,
-0.12350639700889587,
0.31696781516075134,
0.13654814660549164,
0.40306153893470764,
-0.3049616515636444,
-0.6063087582588196,
-0.17916789650917053,
0.6637310981750488,
-0.3144451379776001,
0.097511939704... | |
case 2:
return IntersectionOf(point, new Line(polygon[0], polygon[1]));
}
int counter = 0;
int i;
PointF p1;
int n = polygon.Length;
p1 = polygon[0];
if (point == | [
-0.4222681224346161,
-0.22897331416606903,
0.3353705406188965,
-0.20024792850017548,
-0.035262297838926315,
0.27650147676467896,
0.19728656113147736,
-0.40821585059165955,
-0.17574529349803925,
-0.5569486618041992,
-0.3678942918777466,
0.2973857522010803,
-0.3694826662540436,
-0.0849356725... | |
p1)
{
return Intersection.Tangent;
}
for (i = 1; i <= n; i++)
{
PointF p2 = polygon[i % n];
if (point == p2)
{ | [
-0.4801194965839386,
-0.03252188861370087,
0.5796487927436829,
-0.3436352014541626,
-0.1857225000858307,
0.5271090269088745,
0.22026918828487396,
-0.26410290598869324,
-0.2887197434902191,
-0.4221387803554535,
-0.4259360432624817,
0.20820923149585724,
-0.3099140226840973,
-0.28479433059692... | |
return Intersection.Tangent;
}
if (point.Y > Math.Min(p1.Y, p2.Y))
{
if (point.Y <= Math.Max(p1.Y, p2.Y))
{ | [
-0.4999796748161316,
-0.17938438057899475,
0.5473529100418091,
0.06572926789522171,
0.020751317963004112,
0.5144135355949402,
0.05258075147867203,
0.2039874792098999,
0.010124700143933296,
-0.5167979598045349,
-0.233220174908638,
0.6646957993507385,
0.03327490761876106,
-0.1294709891080856... | |
if (point.X <= Math.Max(p1.X, p2.X))
{
if (p1.Y != p2.Y)
{ | [
-0.3841394782066345,
-0.07506753504276276,
0.24182046949863434,
0.02156444452702999,
0.23739367723464966,
0.14549118280410767,
0.12045539915561676,
-0.20419436693191528,
0.29014822840690613,
-0.14343078434467316,
-0.3955804407596588,
0.29915207624435425,
-0.06582488864660263,
-0.2320359647... | |
double xinters = (point.Y - p1.Y) * (p2.X - p1.X) / (p2.Y - p1.Y) + p1.X;
if (p1.X == p2.X || point.X <= xinters)
counter++; | [
0.12049251794815063,
-0.22435802221298218,
0.5364503264427185,
-0.25758758187294006,
-0.22606374323368073,
0.3109169006347656,
0.2563633322715759,
-0.6425237655639648,
-0.11167163401842117,
-0.13493017852306366,
-0.36710312962532043,
0.4284711480140686,
-0.2850092947483063,
0.1023337170481... | |
}
}
}
}
p1 = p2;
}
return (counter % 2 | [
-0.24136844277381897,
-0.01534359622746706,
0.1943589597940445,
-0.25002041459083557,
0.1438775658607483,
0.20330312848091125,
0.41355323791503906,
-0.48730218410491943,
-0.07109659165143967,
-0.1752547025680542,
-0.2230716198682785,
0.6295894980430603,
-0.4317165017127991,
0.0261887349188... | |
== 1) ? Intersection.Containment : Intersection.None;
}
public static Intersection IntersectionOf(PointF point, Line line)
{
float bottomY = Math.Min(line.Y1, line.Y2);
float topY = Math.Max(line.Y1, line.Y2);
bool heightIsRight = point.Y >= bottomY &&
point.Y <= topY; | [
-0.42832252383232117,
-0.20461565256118774,
0.9591963291168213,
-0.0291423536837101,
0.17710666358470917,
0.24622440338134766,
0.19798429310321808,
-0.14137472212314606,
-0.2189675271511078,
-0.1924927681684494,
-0.37158891558647156,
0.18984778225421906,
-0.1317606270313263,
0.114212378859... | |
//Vertical line, slope is divideByZero error!
if (line.X1 == line.X2)
{
if (point.X == line.X1 && heightIsRight)
{
return Intersection.Tangent;
}
else | [
-0.2965865433216095,
-0.4340614080429077,
0.7986336946487427,
0.06423468887805939,
0.09753353893756866,
0.39022794365882874,
0.23653163015842438,
-0.1888904571533203,
-0.1877238154411316,
-0.35294869542121887,
-0.13955090939998627,
0.6692674160003662,
0.18120001256465912,
0.169706329703331... | |
{
return Intersection.None;
}
}
float slope = (line.X2 - line.X1)/(line.Y2 - line.Y1);
bool onLine = (line.Y1 - point.Y) == (slope*(line.X1 - point.X));
if (onLine && heightIsRight)
{ | [
-0.31652215123176575,
-0.18811367452144623,
0.9702170491218567,
-0.20712485909461975,
0.10671175271272659,
0.02555968053638935,
0.2564767301082611,
-0.26960957050323486,
-0.03132038190960884,
-0.12016845494508743,
-0.3212765157222748,
0.48124411702156067,
0.07773569226264954,
0.08032617717... | |
return Intersection.Tangent;
}
else
{
return Intersection.None;
}
}
}
``` | [
-0.31644338369369507,
0.2654693126678467,
0.5436021685600281,
-0.1423158347606659,
-0.052491445094347,
0.07442836463451385,
0.08672701567411423,
0.36368706822395325,
-0.27785709500312805,
-0.5899204015731812,
-0.22068092226982117,
0.7923154830932617,
-0.3655642569065094,
0.1786165386438369... | |
Let's suppose you deploy a network-attached appliances (small form factor PCs) in the field. You want to allow these to call home after being powered on, then be identified and activated by end users.
Our current plan involves the user entering the MAC address into an activation page on our web site. Later our software (running on the box) will read the address from the interface and transmit this in a "call home" packet. If it matches, the server response with customer information and the box is activated.
We like this approach because it's easy to access, and usually printed on external | [
0.32606059312820435,
0.20067961513996124,
0.5553764700889587,
-0.14747612178325653,
0.43868857622146606,
0.039888493716716766,
-0.07243268191814423,
-0.1533309370279312,
0.08967192471027374,
-0.5461233258247375,
-0.3213963508605957,
0.7188882231712341,
0.013106971979141235,
-0.032318703830... | |
labels (FCC requirement?).
Any problems to watch out for? (The hardware in use is small form factor so all NICs, etc are embedded and would be very hard to change. Customers don't normally have direct acccess to the OS in any way).
I know Microsoft does some crazy fuzzy-hashing function for Windows activation using PCI device IDs, memory size, etc. But that seems overkill for our needs.
--
@Neall Basically, calling into our server, for purposes of this discussion you could call us the manufacturer.
Neall is correct, we're just using the address as a constant. We will read it and transmit it | [
1.0014610290527344,
0.11126244068145752,
0.3833114504814148,
0.21766571700572968,
0.15710940957069397,
-0.3411926031112671,
0.04551427438855171,
0.254506379365921,
-0.023904580622911453,
-0.39562034606933594,
0.000692127097863704,
0.316413015127182,
-0.1708439737558365,
0.5943376421928406,... | |
within another packet (let's say HTTP POST), not depending on getting it somehow from Ethernet frames.
I don't think there's anything magic about what you're doing here - couldn't what you're doing be described as:
"At production we burn a unique number into each of our devices which is both readable by the end user (it's on the label) and accessible to the internal processor. Our users have to enter this number into our website along with their credit-card details, and the box subsequently contacts to the website for permission to operate"
"*Coincidentally* we also use this number as the MAC address for | [
0.8212037086486816,
0.204891636967659,
0.33863550424575806,
0.09602758288383484,
0.3118366301059723,
-0.01790376752614975,
0.2328566163778305,
-0.047373268753290176,
-0.1842513233423233,
-0.4281787872314453,
-0.04299226030707359,
0.38066011667251587,
0.13411922752857208,
0.0842156857252121... | |
network packets as we have to uniquely assign that during production anyway, so it saved us duplicating this bit of work"
I would say the two obvious hazards are:
1. People hack around with your device and change this address to one which someone else has already activated. Whether this is likely to happen depends on some relationship between how hard it is and how expensive whatever they get to steal is. You might want to think about how easily they can take a firmware upgrade file and get the code out of it.
2. Someone uses a combination of firewall/router rules and | [
0.4888966679573059,
-0.1451188325881958,
0.0872671976685524,
0.3015590012073517,
0.25144535303115845,
-0.4891297519207001,
0.34815508127212524,
0.17300470173358917,
-0.1877620369195938,
-0.8301889300346375,
0.04895757883787155,
0.44330620765686035,
-0.4276752471923828,
0.001212747418321669... | |
a bit of custom software to generate a server which replicates the operation of *your* 'auth server' and grants permission to the device to proceed. You could make this harder with some combination of hashing/PKE as part of the protocol.
As ever, some tedious, expensive one-off hack is largely irrelevant, what you don't want is a class-break which can be distributed over the internet to every thieving dweep. | [
0.5929641127586365,
-0.019570425152778625,
-0.013975708745419979,
0.3590894639492035,
-0.1311095654964447,
-0.17789632081985474,
0.40868714451789856,
0.16880612075328827,
-0.17557592689990997,
-0.19215454161167145,
-0.21731147170066833,
0.46456336975097656,
-0.34715747833251953,
0.35215532... | |
I'm giving a presentation to a Java User's Group on Groovy and I'm going to be doing some coding during the presentation to show some side-by-side Java/Groovy. I really like the GroovyConsole as it's simple and I can resize the text easily.
I'm wondering if there is anything similar for Java? I know I could just use Eclipse but I'd rather have a smaller app to use without having to customize a view. What's the community got?
Screen shot of GroovyConsole:

[DrJava](http://www.drjava.org/) is your best bet. It also has an [Eclipse plugin](http://www.drjava.org/eclipse.shtml) to use the interactions pane like GroovyConsole. | [
0.15820680558681488,
-0.20894935727119446,
0.5059702396392822,
0.15452033281326294,
-0.3071253001689911,
-0.08453948050737381,
0.14733947813510895,
0.17021916806697845,
-0.3907719552516937,
-0.6612043380737305,
0.22858262062072754,
0.6400782465934753,
-0.04999617859721184,
0.11816284805536... | |
Help! I have an Axis web service that is being consumed by a C# application. Everything works great, except that arrays of long values always come across as [0,0,0,0] - the right length, but the values aren't deserialized. I have tried with other primitives (ints, doubles) and the same thing happens. What do I do? I don't want to change the semantics of my service.
Here's what I ended up with. I have never found another solution out there for this, so if you have something better, by all means, contribute.
First, the long array definition in the wsdl:types area:
```
<xsd:complexType | [
0.32468101382255554,
0.026418687775731087,
0.24694103002548218,
0.02197754755616188,
-0.2521849572658539,
0.13376492261886597,
0.3844619691371918,
0.0013049037661403418,
0.03880797326564789,
-0.5110155344009399,
0.20729273557662964,
0.76552414894104,
-0.35527607798576355,
0.111983641982078... | |
name="ArrayOf_xsd_long">
<xsd:complexContent mixed="false">
<xsd:restriction base="soapenc:Array">
<xsd:attribute wsdl:arrayType="soapenc:long[]" ref="soapenc:arrayType" />
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
```
Next, we create a SoapExtensionAttribute that will perform the fix. It seems that the problem was that .NET wasn't following the multiref id to the element containing the double value. So, we process the array item, go find the value, and then insert it the value into the element:
```
[AttributeUsage(AttributeTargets.Method)]
public class LongArrayHelperAttribute : SoapExtensionAttribute
{
private int priority = 0;
public | [
0.06168406456708908,
-0.3195185363292694,
0.45390191674232483,
-0.0566941536962986,
0.026421358808875084,
0.01748599484562874,
0.21642032265663147,
-0.6335209012031555,
0.06190725043416023,
-0.29500797390937805,
-0.008695240132510662,
0.5749624371528625,
-0.35314345359802246,
0.13648022711... | |
override Type ExtensionType
{
get { return typeof (LongArrayHelper); }
}
public override int Priority
{
get { return priority; }
set { priority = value; }
}
}
public class LongArrayHelper : SoapExtension
{
private static ILog log = LogManager.GetLogger(typeof (LongArrayHelper));
public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute)
{
return | [
-0.09018442034721375,
-0.6348010897636414,
0.42948389053344727,
0.09710585325956345,
0.2796390652656555,
0.32553979754447937,
-0.014439010992646217,
-0.3016296327114105,
0.03306642174720764,
-0.3432384431362152,
-0.16695360839366913,
0.5300979018211365,
-0.3433411121368408,
0.2347283363342... | |
null;
}
public override object GetInitializer(Type serviceType)
{
return null;
}
public override void Initialize(object initializer)
{
}
private Stream originalStream;
private Stream newStream;
public override void ProcessMessage(SoapMessage m)
{
switch (m.Stage)
{
case SoapMessageStage.AfterSerialize: | [
0.44406357407569885,
-0.40951329469680786,
0.47065553069114685,
-0.2162853330373764,
0.3506019413471222,
0.20223812758922577,
0.5772275328636169,
-0.1279955953359604,
0.06221660599112511,
-0.798572301864624,
-0.38641923666000366,
0.5050857663154602,
-0.2115650773048401,
0.43037542700767517... | |
newStream.Position = 0; //need to reset stream
CopyStream(newStream, originalStream);
break;
case SoapMessageStage.BeforeDeserialize:
XmlWriterSettings settings = new XmlWriterSettings(); | [
0.18118692934513092,
-0.22457188367843628,
0.5319889187812805,
-0.06065870076417923,
0.2579093873500824,
0.0015612669521942735,
0.44451647996902466,
-0.0014766018139198422,
-0.08261765539646149,
-0.7892702221870422,
-0.1786801964044571,
0.43017879128456116,
-0.32790306210517883,
0.35389536... | |
settings.Indent = false;
settings.NewLineOnAttributes = false;
settings.NewLineHandling = NewLineHandling.None;
settings.NewLineChars = "";
XmlWriter writer = XmlWriter.Create(newStream, settings);
XmlDocument xmlDocument = new | [
0.08717101067304611,
-0.29575443267822266,
0.8176456093788147,
-0.044826481491327286,
0.3824624717235565,
0.1084708571434021,
0.1858939677476883,
-0.23341262340545654,
-0.1914360374212265,
-0.7087888121604919,
-0.3572365641593933,
0.48796552419662476,
-0.08934441208839417,
0.21204788982868... | |
XmlDocument();
xmlDocument.Load(originalStream);
List<XmlElement> longArrayItems = new List<XmlElement>();
Dictionary<string, XmlElement> multiRefs = new Dictionary<string, XmlElement>();
FindImportantNodes(xmlDocument.DocumentElement, longArrayItems, multiRefs);
FixLongArrays(longArrayItems, multiRefs); | [
-0.1667453795671463,
-0.4580354690551758,
0.5927040576934814,
-0.09696788340806961,
0.1197923943400383,
0.32927456498146057,
-0.1165815144777298,
-0.2905714511871338,
-0.21741178631782532,
-0.48484647274017334,
-0.39616066217422485,
0.5222912430763245,
-0.43467333912849426,
0.2135979682207... | |
xmlDocument.Save(writer);
newStream.Position = 0;
break;
}
}
private static void FindImportantNodes(XmlElement element, List<XmlElement> longArrayItems, | [
-0.10993923246860504,
-0.264242023229599,
0.4267174303531647,
-0.10048772394657135,
0.36201557517051697,
0.01854705438017845,
0.05298681929707527,
-0.21695160865783691,
0.023345617577433586,
-0.538788914680481,
-0.32829856872558594,
0.3646596074104309,
-0.3251647651195526,
0.32207494974136... | |
Dictionary<string, XmlElement> multiRefs)
{
string val = element.GetAttribute("soapenc:arrayType");
if (val != null && val.Contains(":long["))
{
longArrayItems.Add(element);
}
if (element.Name == "multiRef")
{
multiRefs[element.GetAttribute("id")] = element; | [
-0.02143128030002117,
-0.2960897982120514,
0.5642367601394653,
-0.2801942527294159,
-0.016069401055574417,
0.3050416111946106,
0.3751389980316162,
-0.631393551826477,
0.17212173342704773,
-0.3710491359233856,
-0.29428908228874207,
0.6151382327079773,
-0.3532751500606537,
0.1916529983282089... | |
}
foreach (XmlNode node in element.ChildNodes)
{
XmlElement child = node as XmlElement;
if (child != null)
{
FindImportantNodes(child, longArrayItems, multiRefs); | [
-0.3338416814804077,
-0.28506094217300415,
0.32685577869415283,
-0.13853499293327332,
0.4616073668003082,
0.234315425157547,
-0.03476628288626671,
-0.29520297050476074,
0.06792598962783813,
-0.5468490123748779,
-0.3020186722278595,
0.1578160673379898,
-0.2258066087961197,
0.429190546274185... | |
}
}
}
private static void FixLongArrays(List<XmlElement> longArrayItems, Dictionary<string, XmlElement> multiRefs)
{
foreach (XmlElement element in longArrayItems)
{
foreach (XmlNode node in element.ChildNodes)
{
XmlElement child = node as XmlElement; | [
-0.20451150834560394,
-0.2912457287311554,
0.4699815809726715,
-0.15267454087734222,
0.4039546549320221,
0.4300772249698639,
-0.17578813433647156,
-0.17811624705791473,
0.014970233663916588,
-0.3096422851085663,
-0.22617757320404053,
0.32439103722572327,
-0.30043724179267883,
0.21678116917... | |
if (child != null)
{
string href = child.GetAttribute("href");
if (href == null || href.Length == 0) | [
-0.4256375730037689,
-0.06227404251694679,
0.32802096009254456,
-0.26921987533569336,
0.3940902054309845,
0.3797758221626282,
0.5038101077079773,
-0.3926016688346863,
0.1790982037782669,
-0.2855294942855835,
-0.5464468002319336,
0.409540057182312,
-0.1064920574426651,
0.220320463180542,
... | |
{
continue;
}
if (href.StartsWith("#"))
{ | [
0.032820798456668854,
-0.0950348824262619,
0.38768818974494934,
-0.2250581681728363,
0.8256158232688904,
-0.07414984703063965,
0.6426731944084167,
0.0031412672251462936,
0.008371882140636444,
-0.15551400184631348,
-0.7604516744613647,
0.5951588749885559,
-0.03385284170508385,
0.42807880043... | |
href = href.Remove(0, 1);
}
XmlElement multiRef = multiRefs[href];
if (multiRef == null) | [
0.14641501009464264,
-0.12450550496578217,
0.5493006706237793,
-0.033576060086488724,
-0.18016627430915833,
0.23500801622867584,
0.1492813676595688,
-0.6260049343109131,
-0.24906550347805023,
-0.4524685740470886,
-0.45200905203819275,
0.27875861525535583,
-0.5632500052452087,
0.33170598745... | |
{
continue;
}
child.RemoveAttribute("href");
child.InnerXml = multiRef.InnerXml; | [
-0.19640351831912994,
0.03360636532306671,
0.4035550057888031,
-0.2969314754009247,
0.5395932197570801,
0.47271814942359924,
0.6961245536804199,
-0.3131713271141052,
-0.21026483178138733,
-0.4184246361255646,
-0.4554069936275482,
0.3121219873428345,
-0.38163232803344727,
0.5416883230209351... | |
if (log.IsDebugEnabled)
{
log.Debug("Replaced multiRef id '" + href + "' with value: " + multiRef.InnerXml);
}
} | [
-0.28877344727516174,
-0.1943744719028473,
0.3719410300254822,
-0.11912468075752258,
0.3233458697795868,
-0.012511452659964561,
0.14379650354385376,
-0.3046027719974518,
-0.1496782749891281,
-0.38566067814826965,
-0.3807106912136078,
0.6336565613746643,
-0.37302884459495544,
0.169669196009... | |
}
}
}
public override Stream ChainStream(Stream s)
{
originalStream = s;
newStream = new MemoryStream();
return newStream;
}
private static void CopyStream(Stream from, Stream to)
{
TextReader reader = new StreamReader(from); | [
0.14943215250968933,
-0.29477667808532715,
0.6775170564651489,
-0.1810722053050995,
0.2557610869407654,
0.1343453824520111,
0.2658444046974182,
-0.054982978850603104,
-0.06330034136772156,
-0.7162850499153137,
-0.4989701211452484,
0.7293838262557983,
-0.40332961082458496,
0.527316868305206... | |
TextWriter writer = new StreamWriter(to);
writer.WriteLine(reader.ReadToEnd());
writer.Flush();
}
}
```
Finally, we tag all methods in the Reference.cs file that will be deserializing a long array with our attribute:
```
[SoapRpcMethod("", RequestNamespace="http://some.service.provider",
ResponseNamespace="http://some.service.provider")]
[return : SoapElement("getFooReturn")]
[LongArrayHelper]
public Foo getFoo()
{
object[] results = Invoke("getFoo", new object[0]);
return | [
0.10079747438430786,
-0.020010748878121376,
1.0207866430282593,
-0.28846436738967896,
0.1294066607952118,
0.17147290706634521,
0.46844184398651123,
-0.5315946936607361,
0.11328219622373581,
-0.47958827018737793,
-0.023121114820241928,
0.7865810394287109,
-0.21223784983158112,
0.01679668389... | |
((Foo) (results[0]));
}
```
This fix is long-specific, but it could probably be generalized to handle any primitive type having this problem. | [
-0.019091930240392685,
0.015506523661315441,
0.17895960807800293,
-0.31447964906692505,
0.1602030247449875,
-0.4390074908733368,
0.2728740870952606,
-0.03301011770963669,
0.09368517249822617,
-0.06025256589055061,
-0.34843215346336365,
0.6924834847450256,
-0.4885324537754059,
0.23696227371... | |
I am creating a small modal form that is used in Winforms application. It is basically a progress bar of sorts. But I would like the user to be able to click anywhere in the form and drag it to move it around on the desktop while it is still being displayed.
How can I implement this behavior?
[Microsoft KB Article 320687](http://support.microsoft.com/kb/320687 "KB Article 320687") has a detailed answer to this question.
Basically, you override the WndProc method to return HTCAPTION to the WM\_NCHITTEST message when the point being tested is in the client area of the form -- which is, in effect, | [
0.40343615412712097,
0.057255927473306656,
0.605962336063385,
-0.006218313239514828,
0.05160592123866081,
-0.38340848684310913,
0.2174982875585556,
-0.23571588099002838,
0.010461660102009773,
-0.6369155049324036,
-0.1715930700302124,
0.5275083780288696,
-0.2409036010503769,
0.2011597007513... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.