text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
Let's say I have some code like this:
```
<html>
<head><title>Title</title></head>
<body>
<?php
if (!$someCondition){
die();
}
else{
#Do something
}
?>
</body>
<html>
```
I hope the purpose of this code is straightforward. If a certain condition is met (ie can't connect to database), then the program should d... | [
0.553216814994812,
0.1027427688241005,
0.41369250416755676,
0.013079791329801083,
-0.2563038468360901,
-0.3200211226940155,
0.42891034483909607,
-0.0954522043466568,
0.044631339609622955,
-0.7403083443641663,
-0.02527565136551857,
0.28981560468673706,
-0.323346883058548,
0.0712675899267196... | |
through?
You should be separating out your header and footer into an separate files and functions. This makes the UI much easier to maintain and keeps things consistent for rendering the view. Couple that with using [Exception handling](http://us.php.net/Exceptions) and you're golden.
```
<?php
printHeader(); // outp... | [
0.4661621153354645,
-0.002393527887761593,
0.38353973627090454,
-0.01797093264758587,
-0.01621229201555252,
-0.08976514637470245,
0.4865444600582123,
-0.2923579514026642,
-0.2413613498210907,
-0.5257279276847839,
-0.0548970103263855,
0.10575291514396667,
-0.3453848958015442,
0.206242054700... | |
outputs the html footer
?>
``` | [
-0.04189975559711456,
0.3646465241909027,
0.30161646008491516,
-0.07299873977899551,
-0.05890592187643051,
0.0664585679769516,
-0.021258756518363953,
0.2059384286403656,
-0.19832345843315125,
-0.6095858812332153,
-0.3713338077068329,
0.18374672532081604,
-0.2845240533351898,
-0.18001981079... | |
how to create a good plugin engine for standalone executables created with pyInstaller, py2exe or similar tools?
I do not have experience with py2exe, but pyInstaller uses an import hook to import packages from it's compressed repository. Of course I am able to import dynamically another compressed repository created... | [
0.05168015509843826,
0.011583411134779453,
0.014621316455304623,
0.15594831109046936,
0.05291489511728287,
-0.24337728321552277,
0.05022606626152992,
-0.248992457985878,
-0.11821555346250534,
-0.4864354133605957,
-0.1504112035036087,
0.5455376505851746,
-0.5680843591690063,
-0.218562722206... | |
repository - not the one imported later (plugin package repository).
Is there an easy way to solve this problem? Maybe there exist such engine?
When compiling to exe, your going to have this issue.
The only option I can think of to allow users access with thier plugins to use any python library is to include all lib... | [
0.47125208377838135,
-0.10113450139760971,
0.07909411191940308,
0.3082875609397888,
-0.2315734624862671,
-0.2018057405948639,
0.0987023338675499,
-0.09032091498374939,
-0.1890208125114441,
-0.660778284072876,
-0.001509722089394927,
0.6649181246757507,
-0.2689158022403717,
-0.10770759731531... | |
a sample:
```
from distutils.core import setup
import py2exe
setup (name = "script2compile",
console=['script2compile.pyw'],
version = "1.4",
author = "me",
author_email="somemail@me.com",
url="myurl.com",
windows = [{
"script":"script2compile.pyw",
... | [
0.16944879293441772,
0.09520414471626282,
0.16251030564308167,
-0.210249125957489,
0.20293492078781128,
0.14181695878505707,
0.2761475145816803,
-0.007214421406388283,
-0.14453120529651642,
-0.7129278182983398,
-0.24548833072185516,
0.45633381605148315,
-0.4476551413536072,
-0.058069042861... | |
file to use for display
}],
# put packages/libraries to include in the "packages" list
options = {"py2exe":{"packages": [ "pickle",
"csv", | [
0.24860376119613647,
-0.28827863931655884,
0.02227199077606201,
0.14274968206882477,
0.2618168890476227,
0.18912023305892944,
-0.19422242045402527,
-0.16401220858097076,
-0.22276844084262848,
-0.5511162281036377,
-0.40797388553619385,
0.37258216738700867,
-0.33534765243530273,
-0.078755907... | |
"Tkconstants",
"Tkinter", | [
0.20118683576583862,
-0.22853174805641174,
0.07572006434202194,
0.3719082474708557,
-0.45122042298316956,
0.3413057327270508,
0.31732067465782166,
0.19850663840770721,
-0.0932060107588768,
-0.4682709574699402,
-0.3877146244049072,
0.5415196418762207,
-0.28018826246261597,
0.190540730953216... | |
"tkFileDialog",
"pyexpat", | [
0.2997824549674988,
0.08523333072662354,
0.22881461679935455,
0.18389974534511566,
-0.36444270610809326,
0.46191829442977905,
0.06360101699829102,
0.4897021949291229,
-0.21665208041667938,
-0.3942568302154541,
-0.601315975189209,
0.48161521553993225,
-0.29410070180892944,
0.039532762020826... | |
"xml.dom.minidom",
"win32pdh", | [
-0.11776221543550491,
-0.11050204187631607,
0.0611228421330452,
0.07460026443004608,
-0.24741104245185852,
-0.21405550837516785,
-0.08493412286043167,
-0.10953474044799805,
0.05747675895690918,
-0.3379095196723938,
-0.6037518382072449,
0.6177476644515991,
-0.3576470613479614,
0.07044427841... | |
"win32pdhutil",
"win32api",
"win32con", | [
-0.4272122085094452,
-0.5508397817611694,
0.09756406396627426,
0.20274193584918976,
-0.09801013767719269,
-0.16320674121379852,
0.0025557754561305046,
0.1388988196849823,
0.2719861567020416,
-0.7529680728912354,
-0.42085394263267517,
0.4973210096359253,
-0.5889204144477844,
-0.190778419375... | |
"subprocess",
]}}
)
import win32pdh
import win32pdhutil
import win32api
``` | [
-0.45279422402381897,
-0.06322544813156128,
0.08364060521125793,
-0.13180167973041534,
0.1107659637928009,
0.0618099644780159,
0.2902517020702362,
-0.32291561365127563,
0.18723471462726593,
-0.4926179349422455,
-0.3532325327396393,
0.5021080374717712,
-0.7587559819221497,
-0.05840329080820... | |
I'm using MBUnit Framework for unit testing and looking for a good test runner.
MbUnit's runner is fast however lacking lots of stuff such as
* You can't set execution path
* It's collapsing all trees in every run which drives me crazy
* And almost all other test runner provides so many extra quite and lovely featur... | [
0.22978061437606812,
0.07180770486593246,
-0.11725262552499771,
0.1359904259443283,
-0.1292189508676529,
-0.10363999754190445,
0.6574857831001282,
0.12464568018913269,
0.02191564440727234,
-0.8195345401763916,
0.3841902017593384,
0.6248981952667236,
-0.2179846614599228,
0.02485012821853161... | |
in another setup, it's about 6 times slower than MBUnit GUI and I've got so many test,
Test Driven .NET addon
* This is great little tool but just for testing one or unit test, doesn't provide a good or VS.NET independent GUI
I'm open to any other free test runner which works with or independent from VS 2008
I reall... | [
0.055582962930202484,
-0.29836466908454895,
0.06605606526136398,
0.27534109354019165,
-0.5975655913352966,
-0.19595366716384888,
0.32942941784858704,
-0.12151344120502472,
0.10302934795618057,
-0.6998593807220459,
0.5951107740402222,
0.8653024435043335,
-0.079036183655262,
-0.0325816906988... | |
I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail. The attachment-adding part looks like this:
```
using (MemoryStream pdfStream = new MemoryStream())
{
pdfStream.Write(pdfData, 0, pdfData.Length);
Attachment a = new Attachment(pdfStream,
string.Format("Receipt_{0}_{1}... | [
-0.2747161090373993,
-0.018017148599028587,
0.8038507103919983,
-0.0798964723944664,
-0.044874485582113266,
-0.04148692637681961,
0.4498404562473297,
-0.15751664340496063,
-0.21553276479244232,
-0.8375765085220337,
-0.22044064104557037,
0.36352479457855225,
-0.35859137773513794,
0.30659213... | |
page used System.Web.Mail.MailAttachment, which was made obsolete in .NET 2.0.
I've tried changing the TransferEncoding in the Attachment class (which replaces MailAttachment), but had no luck. Has anyone solved this on .NET 2.0?
Have you tried doing a `pdfStream.Seek(0,SeekOrigin.Begin)` before creating the attachme... | [
0.1169220432639122,
-0.16100217401981354,
0.8267495632171631,
0.0006045983172953129,
-0.0766267478466034,
-0.20415745675563812,
0.20589202642440796,
-0.02038455754518509,
-0.052661120891571045,
-0.796183168888092,
0.05360626429319382,
0.44635969400405884,
-0.5946391224861145,
0.12228953093... | |
Working to get DateTimes for any time zone.
I'm using DateTimeOffset, and a string, and an XmlElement attribute. When I do, I get the following error:
> [InvalidOperationException: 'dateTime'
> is an invalid value for the
> XmlElementAttribute.DataType property.
> dateTime cannot be converted to
> System.String.]... | [
0.05199717730283737,
-0.08328881114721298,
0.5871754288673401,
-0.10245797038078308,
0.19035819172859192,
0.18476366996765137,
0.2919088304042816,
-0.4234888255596161,
-0.2849455177783966,
-0.7151138186454773,
-0.05904560908675194,
0.579945981502533,
-0.5028594732284546,
-0.144188374280929... | |
a, Boolean repeats,
> Boolean openModel, RecursionLimiter
> limiter) +1621
>
> System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping
> accessor, FieldModel model,
> XmlAttributes a, String ns, Type
> choiceIdentifierType, Boolean rpc,
> Boolean openModel, RecursionLimiter
> limit... | [
-0.2914043366909027,
-0.12779249250888824,
0.3148822784423828,
-0.18301817774772644,
-0.064277783036232,
0.30030903220176697,
0.09513602405786514,
-0.4563671946525574,
-0.42358994483947754,
-0.4005467891693115,
-0.34074580669403076,
0.27350306510925293,
-0.3253299593925476,
0.2567673623561... | |
{
get
{
return this.creationTimeField.ToString("yyyy-MM-ddTHH:mm:sszzz");
}
set
{
DateTimeOffset.TryParse(value, out this.creationTimeField);
}
}
[System.Xml.Serialization.XmlIgnoreAttribute()]
public System.DateTimeOffset creationTime
{
g... | [
0.07124225795269012,
-0.3068070113658905,
0.5577437281608582,
0.040645942091941833,
0.21801884472370148,
0.023560157045722008,
0.1789657324552536,
-0.008218065835535526,
-0.2270747870206833,
-0.7412782311439514,
-0.48384973406791687,
0.4704785943031311,
-0.11021031439304352,
0.234936788678... | |
set {
this.creationTimeField = value;
}
}
```
Take a look at this StackOverflow question about serializing dates and UTC:
[Best practices for DateTime serialization in .Net framework 3.5/SQL Server 2008](https://stackoverflow.com/questions/65164/best-practices-for-datetime-serialization-in-net-framework-3... | [
0.2799936532974243,
-0.0544329509139061,
0.20090040564537048,
0.01823369599878788,
0.05261758714914322,
-0.49117445945739746,
-0.10222039371728897,
-0.3100741505622864,
-0.22946980595588684,
-0.3209768831729889,
-0.12930981814861298,
0.4770691990852356,
-0.2759091258049011,
-0.100961267948... | |
I have two directories in the same parent directory. Call the parent directory **base** and the children directories **alpha** and **bravo**. I want to replace **alpha** with **bravo**. The simplest method is:
```
rm -rf alpha
mv bravo alpha
```
The mv command is atomic, but the rm -rf is not. Is there a simple way ... | [
0.2233516126871109,
0.2668028771877289,
0.30517739057540894,
-0.1405489146709442,
0.10445714741945267,
-0.18656137585639954,
0.3614497184753418,
-0.544765830039978,
-0.23302294313907623,
-0.39888355135917664,
-0.19020159542560577,
0.6738165616989136,
-0.23202283680438995,
0.054596338421106... | |
critical. If not, it gives an error message. But it would be nice if there was a way to do this. :) Maybe there's some way to modify the inodes directly, or something...
You can do this if you use symlinks:
Let's say alpha is a symlink to directory alpha\_1, and you want to switch the symlink to point to alpha\_2. Her... | [
-0.09445402026176453,
0.354535311460495,
0.35175928473472595,
0.025518100708723068,
0.0009171720594167709,
-0.10304760187864304,
0.06207113340497017,
-0.20399482548236847,
-0.15123023092746735,
-0.5317769050598145,
-0.005779921542853117,
0.6275648474693298,
-0.8096302151679993,
0.271108150... | |
-rf alpha_1
```
Note that this is NOT actually a fully atomic operation, but it does happen very quickly since the "ln" command both unlinks and then immediately recreates the symlink. You can verify this behaviour with strace:
```
$ strace ln -nsf alpha_2 alpha
...
symlink("alpha_2", "alpha") = -1 EEXIS... | [
-0.08554153889417648,
-0.100637286901474,
0.6637102365493774,
-0.5098965764045715,
0.11712861061096191,
-0.2914670407772064,
0.14542129635810852,
-0.67469322681427,
-0.1338687241077423,
-0.4677525758743286,
-0.34856608510017395,
0.7974387407302856,
-0.49555662274360657,
-0.1490218937397003... | |
can repeat this procedure as desired: e.g. when you have a new version, alpha\_3:
```
$ ln -nsf alpha_3 alpha
$ rm -rf alpha_2
``` | [
0.016164032742381096,
-0.0658741369843483,
0.48498058319091797,
-0.5365748405456543,
0.36160174012184143,
-0.058606427162885666,
0.33289647102355957,
-0.14998872578144073,
-0.21683472394943237,
-0.43467751145362854,
-0.5005879402160645,
0.5275849103927612,
-0.4960686266422272,
0.1527240872... | |
In the footer of my page, I would like to add something like "last updated the xx/xx/200x" with this date being the last time a certain mySQL table has been updated.
What is the best way to do that? Is there a function to retrieve the last updated date? Should I access to the database every time I need this value?
In ... | [
0.17271843552589417,
0.046839941293001175,
0.7510218024253845,
0.02004874125123024,
-0.07534169405698776,
-0.1427234560251236,
0.10575734078884125,
0.46615660190582275,
-0.3720029294490814,
-0.8688400983810425,
0.08182206004858017,
0.2329925000667572,
0.04134441912174225,
0.379328012466430... | |
the database.
---
An alternative option would be to "touch" a particular file whenever the MySQL table is updated:
On database updates:
* Open your timestamp file in `O_RDRW` mode
* `close` it again
or alternatively
* use [`touch()`](http://us3.php.net/manual/en/function.touch.php), the PHP equivalent of the `uti... | [
0.07319708913564682,
-0.19909892976284027,
0.7884534597396851,
0.05670778453350067,
0.011307412758469582,
-0.09351442754268646,
0.11764343827962875,
0.06630168855190277,
-0.20606356859207153,
-1.0749953985214233,
-0.20310969650745392,
0.7978487014770508,
-0.04853811860084534,
0.03971419855... | |
I have a 2D image randomly and sparsely scattered with pixels.
given a point on the image, I need to find the distance to the closest pixel that is not in the background color (black).
What is the fastest way to do this?
The only method I could come up with is building a kd-tree for the pixels. but I would real... | [
0.30221956968307495,
0.13240118324756622,
0.07533783465623856,
0.16968472301959991,
-0.17252349853515625,
0.16526079177856445,
-0.13283485174179077,
-0.09459476172924042,
-0.083250492811203,
-0.895431399345398,
0.09843357652425766,
0.2873517572879791,
-0.165033757686615,
0.2627000510692596... | |
search the perimeter of a square that you keep moving out one pixel at a time from your original point (i.e. increasing the width and height by two pixels at a time). When you hit a non-black pixel, you calculate the distance (this is your first expensive calculation) and then continue searching outwards until the widt... | [
0.23739998042583466,
-0.21819232404232025,
0.35856103897094727,
-0.19851438701152802,
-0.20765194296836853,
0.10967902094125748,
0.2808317542076111,
-0.6023938655853271,
-0.3160160481929779,
-0.6677730083465576,
-0.024865422397851944,
0.2234017550945282,
-0.15944787859916687,
0.07894550263... | |
any of them are closer than your original point.
In an ideal find, you only have to make one expensive distance calculation.
**Update**: Because you're calculating pixel-to-pixel distances here (instead of arbitrary precision floating point locations), you can speed up this algorithm substantially by using a pre-calc... | [
0.05003741756081581,
0.010479802265763283,
0.4201149344444275,
0.28766995668411255,
0.03604186698794365,
0.18422959744930267,
-0.1635831594467163,
-0.3867064118385315,
-0.07469984889030457,
-0.9490607380867004,
-0.047889478504657745,
0.3150341808795929,
0.0014803584199398756,
-0.1193442568... | |
you find. This array could even be pre-calculated and embedded in your app as a resource, to spare you the initial calculation time (this is probably serious overkill).
**Update 2**: Also, there are ways to optimize searching the square perimeter. Your search should start at the four points that intersect the axes and... | [
0.24527804553508759,
-0.107596755027771,
0.750095009803772,
0.2610214054584503,
-0.15220732986927032,
0.18195867538452148,
0.28851261734962463,
-0.2100267857313156,
-0.32617348432540894,
-0.9165843725204468,
0.023357613012194633,
0.28096580505371094,
-0.1739177703857422,
-0.103300146758556... | |
the remaining points are all further from the origin.
After the first found pixel, you can further restrict the additional search area required to the minimum by using the lookup table to ensure that each searched point is closer than the found point (again starting at the axes, and stopping when the distance limit is... | [
-0.08873716741800308,
-0.2968948781490326,
0.7205594778060913,
0.1035909652709961,
0.0264141783118248,
-0.006718275602906942,
-0.02179645001888275,
-0.20756641030311584,
0.03467366471886635,
-0.7589914202690125,
-0.09402862936258316,
0.09252578020095825,
-0.09658101201057434,
0.07366860657... | |
the pixel, doing only lookups and <>comparisons. | [
-0.15883655846118927,
-0.021497998386621475,
-0.05687956139445305,
0.41654452681541443,
-0.3386665880680084,
0.33742985129356384,
-0.3392029404640198,
0.04653415456414223,
0.265506774187088,
-0.516602635383606,
-0.23981912434101105,
0.3252315819263458,
-0.3301829993724823,
-0.1336009651422... | |
I want to create a unique id but `uniqid()` is giving something like `'492607b0ee414'`. What i would like is something similar to what tinyurl gives: `'64k8ra'`. The shorter, the better. The only requirements are that it should not have an obvious order and that it should look prettier than a seemingly random sequence ... | [
0.24569649994373322,
0.033567123115062714,
0.17882026731967926,
0.07976379990577698,
-0.2478400319814682,
0.023808984085917473,
0.06583808362483978,
-0.04328928887844086,
-0.18210771679878235,
-0.7033054232597351,
0.09304753690958023,
0.23261211812496185,
-0.0808284729719162,
0.20717801153... | |
for a given length:
```
<?php
function generate_random_letters($length) {
$random = '';
for ($i = 0; $i < $length; $i++) {
$random .= chr(rand(ord('a'), ord('z')));
}
return $random;
}
```
Then you'll want to call that until it's unique, in pseudo-code depending on where you'd store that info... | [
-0.019987596198916435,
0.11424452811479568,
0.18091221153736115,
-0.10690851509571075,
-0.2583227753639221,
0.10698603838682175,
0.1532888263463974,
-0.3606038987636566,
-0.22197844088077545,
-0.32617074251174927,
-0.16671894490718842,
0.16450835764408112,
-0.20485733449459076,
0.420734286... | |
things a customer would find of bad-taste.
EDIT: I would also add this only make sense if, as you intend to use it, it's not for a big amount of items because this could get pretty slow the more collisions you get (getting an ID already in the table). Of course, you'll want an indexed table and you'll want to tweak th... | [
0.2528393864631653,
0.21715880930423737,
0.23493610322475433,
0.21741031110286713,
-0.04172631725668907,
0.4312761425971985,
-0.008510623127222061,
-0.3502635657787323,
-0.4565730690956116,
-0.7415533661842346,
-0.04119414836168289,
0.3451881408691406,
-0.25299152731895447,
-0.018488822504... | |
of letters and numbers you can use the following code:
```
$random .= rand(0, 1) ? rand(0, 9) : chr(rand(ord('a'), ord('z')));
``` | [
0.03754105791449547,
0.4139861762523651,
-0.16174644231796265,
-0.12117146700620651,
-0.08159041404724121,
0.46755775809288025,
0.001961269648745656,
-0.475810706615448,
-0.15217074751853943,
-0.2973897159099579,
0.06133083999156952,
0.27937421202659607,
-0.1335882842540741,
0.240187063813... | |
When you run `top` and see all running processes, I've always wanted to know just what everything actually means. e.g. all the various single-letter state codes for a running process (R = Running, S = Sleeping, etc...)
Where can I find this?
The [man page](https://www.man7.org/linux/man-pages/man1/top.1.html) says wha... | [
0.31395983695983887,
-0.1374649554491043,
0.40438783168792725,
0.012904212810099125,
0.41508960723876953,
-0.15833649039268494,
0.34117409586906433,
-0.10851286351680756,
-0.42331597208976746,
-0.672370433807373,
-0.34070271253585815,
0.5059660077095032,
0.06596449017524719,
-0.03356913104... | |
states, where the process is waiting for something to happen. The difference is that 'S' can be interrupted by a signal, while 'D' cannot (it is usually seen when the process is waiting for the disk).
'T' is a state where the process is stopped, usually via `SIGSTOP` or `SIGTSTP`. It can also be stopped by a debugger ... | [
0.39657750725746155,
-0.3219957649707794,
0.28385964035987854,
0.32774049043655396,
0.26237621903419495,
0.046152204275131226,
0.3269301652908325,
0.2609834372997284,
-0.4158729016780853,
-0.3512338101863861,
-0.5305221676826477,
0.20303481817245483,
-0.3600400686264038,
0.7486818432807922... | |
it on the kernel. It is waiting for its parent process to retrieve its exit code, and not much more. After its parent process is finished with it, it will disappear. | [
-0.21967367827892303,
-0.058132726699113846,
0.46047982573509216,
0.13352307677268982,
0.41050946712493896,
-0.339389443397522,
-0.046799883246421814,
0.6911429166793823,
0.036070238798856735,
-0.53626948595047,
-0.552710771560669,
0.12179572880268097,
-0.178664892911911,
0.505216181278228... | |
I've got two branches that are fully merged together.
However, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would just be easier to change to the new version in the other branch, and then reinsert my one line change after bringing it ov... | [
0.058180343359708786,
-0.17986120283603668,
0.4214300215244293,
-0.05934162437915802,
0.2626519203186035,
-0.13313910365104675,
0.18755152821540833,
0.14590975642204285,
-0.28099703788757324,
-0.864655077457428,
0.006411712616682053,
0.3308655023574829,
-0.28811851143836975,
0.153802230954... | |
you can pull files from any commit
* This works for files and directories
* Overwrites the file `myfile.txt` and `mydir`
* Wildcards don't work, but relative paths do
* Multiple paths can be specified
An alternative:
```
git show commit_id:path/to/file > path/to/file
``` | [
0.06808412075042725,
-0.4020495116710663,
0.4054381251335144,
0.17593243718147278,
0.0729575902223587,
-0.14501862227916718,
0.1828809529542923,
-0.070090152323246,
-0.3558385372161865,
-0.62398761510849,
-0.11563526839017868,
0.5850125551223755,
-0.30765393376350403,
-0.10809902101755142,... | |
I keep seeing people say that exceptions are slow, but I never see any proof. So, instead of asking if they are, I will ask how do exceptions work behind the scenes, so I can make decisions of when to use them and whether they are slow.
From what I know, exceptions are the same as doing a return bunch of times, except... | [
0.2796953022480011,
0.017743756994605064,
-0.07406777143478394,
0.230951726436615,
-0.00513302581384778,
-0.04560763016343117,
0.30637574195861816,
0.06410929560661316,
-0.5507303476333618,
-0.17745985090732574,
0.34612223505973816,
0.206304132938385,
-0.28875258564949036,
-0.2407290488481... | |
exception and a stack location, it then does returns until it gets there. I am also guessing that the only time this second stack is touched is on a throw and on each try/catch. AFAICT implementing a similar behaviour with return codes would take the same amount of time. But this is all just a guess, so I want to know ... | [
0.003888409584760666,
0.04628102481365204,
-0.14591985940933228,
0.01951782964169979,
-0.13541319966316223,
-0.23063801229000092,
0.2612607777118683,
-0.076719269156456,
-0.34491005539894104,
-0.5191380977630615,
0.07276453077793121,
0.3813212215900421,
-0.3093838393688202,
-0.096843644976... | |
~MyException() { }
};
void my_throwing_function(bool throwit)
{
if (throwit)
throw MyException();
}
void another_function();
void log(unsigned count);
void my_catching_function()
{
log(0);
try
{
log(1);
another_function();
log(2);
}
catch (const MyException& e)... | [
0.03705566003918648,
-0.028138836845755577,
0.20439861714839935,
-0.5056372880935669,
-0.14064617455005646,
0.11192584037780762,
0.46969541907310486,
-0.3250889182090759,
0.07198742777109146,
-0.4410015344619751,
-0.06487114727497101,
0.22242502868175507,
-0.2685849070549011,
0.00221517938... | |
-save-temps -c`, and looked at the generated assembly file.
```
.file "foo.cpp"
.section .text._ZN11MyExceptionD1Ev,"axG",@progbits,_ZN11MyExceptionD1Ev,comdat
.align 2
.p2align 4,,15
.weak _ZN11MyExceptionD1Ev
.type _ZN11MyExceptionD1Ev, @function
_ZN11MyExceptionD1Ev:
.LFB7:
push... | [
0.014031972736120224,
0.12697364389896393,
0.5962203145027161,
0.012084932066500187,
0.24907286465168,
0.3601878583431244,
0.5942243337631226,
-0.274769127368927,
0.0904664695262909,
-0.5802056193351746,
-0.1940910518169403,
0.8518749475479126,
-0.6268361806869507,
0.13713395595550537,
-... | |
_Unwind_Resume
.text
.align 2
.p2align 4,,15
.globl _Z20my_catching_functionv
.type _Z20my_catching_functionv, @function
_Z20my_catching_functionv:
.LFB9:
pushl %ebp
.LCFI2:
movl %esp, %ebp
.LCFI3:
pushl %ebx
.LCFI4:
subl $20, %esp
.LCFI5:
movl $0, (%esp)
.LEHB0:
c... | [
-0.3437122404575348,
-0.38894185423851013,
0.9535281658172607,
-0.043026991188526154,
0.24125993251800537,
0.3177642524242401,
0.41139793395996094,
-0.35663720965385437,
-0.5367649793624878,
-0.39706656336784363,
-0.2947414219379425,
0.7149178981781006,
-0.48489290475845337,
-0.13036157190... | |
movl $2, (%esp)
call _Z3logj
.LEHE1:
.L5:
movl $4, (%esp)
.LEHB2:
call _Z3logj
addl $20, %esp
popl %ebx
popl %ebp
ret
.L12:
subl $1, %edx
movl %eax, %ebx
je .L16
.L14:
movl %ebx, (%esp)
call | [
-0.3038610517978668,
0.3070051074028015,
0.8444992303848267,
-0.2716604769229889,
0.05140664801001549,
0.4927452504634857,
0.526147723197937,
-0.40994250774383545,
-0.24491620063781738,
-0.3513615131378174,
-0.5409193634986877,
0.8160600066184998,
-0.4295651614665985,
-0.18118566274642944,... | |
_Unwind_Resume
.LEHE2:
.L16:
.L6:
movl %eax, (%esp)
call __cxa_begin_catch
movl $3, (%esp)
.LEHB3:
call _Z3logj
.LEHE3:
call __cxa_end_catch
.p2align 4,,3
jmp .L5
.L11:
.L8:
movl %eax, %ebx
.p2align 4,,6
call __cxa_end_catch
.p2align 4,,6
jmp .L14
.LF... | [
-0.08238837122917175,
-0.08255583792924881,
0.8388737440109253,
-0.19100578129291534,
0.17309950292110443,
0.2898753881454468,
0.30489733815193176,
-0.32830315828323364,
-0.5610618591308594,
-0.37782904505729675,
-0.37080955505371094,
0.4355411231517792,
-0.360421359539032,
-0.172419175505... | |
.gcc_except_table,"a",@progbits
.align 4
.LLSDA9:
.byte 0xff
.byte 0x0
.uleb128 .LLSDATT9-.LLSDATTD9
.LLSDATTD9:
.byte 0x1
.uleb128 .LLSDACSE9-.LLSDACSB9
.LLSDACSB9:
.uleb128 .LEHB0-.LFB9
.uleb128 .LEHE0-.LEHB0
.uleb128 0x0
.uleb128 0x0
.uleb128 .LEHB1-.LFB9
.uleb12... | [
-0.3889458477497101,
0.30636993050575256,
1.1112399101257324,
-0.24349357187747955,
0.0729328915476799,
0.2603917121887207,
-0.07176408171653748,
-0.4265444278717041,
-0.41569235920906067,
-0.6711894869804382,
-0.4048539996147156,
0.40526631474494934,
-0.41879919171333313,
0.13836552202701... | |
.uleb128 .LEHB3-.LFB9
.uleb128 .LEHE3-.LEHB3
.uleb128 .L11-.LFB9
.uleb128 0x0
.LLSDACSE9:
.byte 0x1
.byte 0x0
.align 4
.long _ZTI11MyException
.LLSDATT9:
```
Surprise! There are no extra instructions at all on the normal code path. The compiler instead generated extra out-of-line fix... | [
0.016792472451925278,
0.13260191679000854,
0.1341084986925125,
-0.031054796651005745,
0.1322752684354782,
0.3732893764972687,
0.3342704474925995,
-0.40325355529785156,
-0.2822052240371704,
-0.3011680543422699,
-0.5934074521064758,
0.3940812349319458,
-0.44407153129577637,
-0.32290714979171... | |
these tables (`_ZTI11MyException` is `typeinfo for MyException`).
OK, that was not actually a surprise for me, I already knew how this compiler did it. Continuing with the assembly output:
```
.text
.align 2
.p2align 4,,15
.globl _Z20my_throwing_functionb
.type _Z20my_throwing_functionb, @function
_... | [
-0.227932870388031,
0.21699918806552887,
0.39733242988586426,
-0.1381140500307083,
-0.2566673457622528,
0.41560807824134827,
0.3961915671825409,
-0.3589027523994446,
-0.4512985050678253,
-0.6968204379081726,
-0.09574469923973083,
0.2159232348203659,
-0.15943007171154022,
-0.141910880804061... | |
movl $1, (%esp)
call __cxa_allocate_exception
movl $_ZN11MyExceptionD1Ev, 8(%esp)
movl $_ZTI11MyException, 4(%esp)
movl %eax, (%esp)
call __cxa_throw
.LFE8:
.size _Z20my_throwing_functionb, .-_Z20my_throwing_functionb
```
Here we see the code for throwing an exception. Whil... | [
-0.059022754430770874,
0.431148499250412,
0.1950085610151291,
-0.17225411534309387,
0.11318736523389816,
0.1228296086192131,
0.3722109794616699,
-0.3616200089454651,
-0.275423139333725,
-0.42314621806144714,
-0.07750169932842255,
0.666637122631073,
-0.161027193069458,
-0.10260514914989471,... | |
which must:
* Walk the stack with the help of the exception tables until it finds a handler for that exception.
* Unwind the stack until it gets to that handler.
* Actually call the handler.
Compare that with the cost of simply returning a value, and you see why exceptions should be used only for exceptional returns.... | [
0.134419247508049,
0.1322038620710373,
0.4840870499610901,
-0.09462571144104004,
0.12677589058876038,
0.1789858043193817,
0.443050354719162,
-0.46008339524269104,
-0.19702960550785065,
-0.3863341212272644,
-0.34133195877075195,
0.3467366099357605,
-0.38459131121635437,
0.07391869276762009,... | |
.long _ZTVN10__cxxabiv117__class_type_infoE+8
.long _ZTS11MyException
.weak _ZTS11MyException
.section .rodata._ZTS11MyException,"aG",@progbits,_ZTS11MyException,comdat
.type _ZTS11MyException, @object
.size _ZTS11MyException, 14
_ZTS11MyException:
.string "11MyException"
```
The ... | [
-0.048493847250938416,
0.2446676641702652,
0.6250945329666138,
-0.004135193768888712,
0.14849548041820526,
0.4553989768028259,
0.12634257972240448,
-0.25024715065956116,
-0.07527734339237213,
-0.5397881865501404,
-0.16802237927913666,
0.40940678119659424,
-0.4769410192966461,
0.45414602756... | |
.uleb128 0x6
.byte 0x0
.long __gxx_personality_v0
.byte 0x0
.byte 0xc
.uleb128 0x4
.uleb128 0x4
.byte 0x88
.uleb128 0x1
.align 4
.LECIE1:
.LSFDE3:
.long .LEFDE3-.LASFDE3
.LASFDE3:
.long .LASFDE3-.Lframe1
.long .LFB9
.long .LFE9-.LFB9
.uleb128 0x4... | [
-0.16463539004325867,
0.01945772022008896,
0.8352134227752686,
-0.09382247924804688,
-0.14581836760044098,
0.5698832869529724,
0.16797298192977905,
-0.401515930891037,
-0.33839595317840576,
-0.8777681589126587,
-0.028969455510377884,
0.3472445607185364,
-0.5055525898933411,
0.1152457222342... | |
.byte 0x4
.long .LCFI2-.LFB9
.byte 0xe
.uleb128 0x8
.byte 0x85
.uleb128 0x2
.byte 0x4
.long .LCFI3-.LCFI2
.byte 0xd
.uleb128 0x5
.byte 0x4
.long .LCFI5-.LCFI3
.byte 0x83
.uleb128 0x3
.align 4
.LEFDE3:
.LSFDE5:
.long | [
-0.27839821577072144,
0.09352133423089981,
0.5809606909751892,
-0.05819757282733917,
0.11424896866083145,
0.6213008165359497,
-0.1724315583705902,
-0.47554177045822144,
-0.322300523519516,
-0.7087559700012207,
-0.19235658645629883,
0.3243061900138855,
-0.6685017347335815,
0.000120169548608... | |
.LEFDE5-.LASFDE5
.LASFDE5:
.long .LASFDE5-.Lframe1
.long .LFB8
.long .LFE8-.LFB8
.uleb128 0x4
.long 0x0
.byte 0x4
.long .LCFI6-.LFB8
.byte 0xe
.uleb128 0x8
.byte 0x85
.uleb128 0x2
.byte 0x4
.long .LCFI7-.LCFI6
.byte 0xd
.uleb128 0x5 | [
-0.26162853837013245,
-0.04192638397216797,
0.5874911546707153,
-0.049224644899368286,
-0.18321464955806732,
0.6395984888076782,
0.06791714578866959,
-0.5943343043327332,
-0.5153695344924927,
-0.8354233503341675,
-0.2548411190509796,
0.04998510703444481,
-0.5228888392448425,
0.098028816282... | |
.align 4
.LEFDE5:
.ident "GCC: (GNU) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)"
.section .note.GNU-stack,"",@progbits
```
Even more exception handling tables, and assorted extra information.
So, the conclusion, at least for GCC on Linux: the cost is extra space (for the handlers and tables) whether or not exceptions... | [
0.2840389907360077,
0.12282750010490417,
0.2890212833881378,
0.1007549837231636,
-0.19784927368164062,
-0.2926592528820038,
0.05253400653600693,
-0.2617506682872772,
-0.2553806006908417,
-0.586956799030304,
-0.09239441156387329,
0.5952895283699036,
-0.39309731125831604,
-0.0513186752796173... | |
case you want more information, in particular what all the `__cxa_` functions do, see the original specification they came from:
* [Itanium C++ ABI](http://www.codesourcery.com/public/cxx-abi/) | [
0.36645063757896423,
0.1954605132341385,
-0.23594631254673004,
-0.10412421822547913,
0.051655106246471405,
0.13250014185905457,
0.07677232474088669,
0.1571892648935318,
-0.15432113409042358,
-0.2130952924489975,
-0.35631945729255676,
0.28552165627479553,
-0.46780914068222046,
-0.1060180440... | |
I have this .NET web app that draws a table in Page\_Load.
Then after that it handles the events, which should change the table drawn in Page\_Load.
This is very inefficient.
Is there a way to execute the code (which draws the table) after it finishes handling all events? (instead of doing it in Page\_Load)
Thank yo... | [
0.10480296611785889,
-0.02990427240729332,
0.16775809228420258,
0.1317702978849411,
-0.10110164433717728,
-0.3722754418849945,
0.07073737680912018,
0.02823198214173317,
-0.2752355933189392,
-0.9044104218482971,
-0.03631270304322243,
0.49396732449531555,
-0.1319272816181183,
0.0538158938288... | |
I am able to create and execute a DTS package that copies tables from a remote Oracle database to a local SQL server, but want to setup the connection to the Oracle database as a linked server.
The DTS package currently uses the *Microsoft OLE DB Provider for Oracle* with the following properties:
* Data Source: `SER... | [
0.13879722356796265,
0.048353053629398346,
0.3223259150981903,
-0.12357958406209946,
-0.24331103265285492,
0.07553137838840485,
0.27044951915740967,
-0.10759911686182022,
0.07179965823888779,
-0.900536298751831,
-0.12903745472431183,
0.5636574625968933,
-0.32375645637512207,
0.097660332918... | |
process:
1. Install Oracle ODBC drivers on SQL Server.
2. Create System DSN to Oracle database on SQL Server.
3. Create linked server on SQL server using System DSN.
**Step 1: Install Oracle ODBC drivers on server**
a. Download the necessary [Oracle Instant Client](http://www.oracle.com/technology/software/tech/oci/... | [
0.22762525081634521,
0.20744358003139496,
0.31204384565353394,
0.17030033469200134,
0.008652077987790108,
-0.08169490844011307,
-0.07961132377386093,
-0.3792259991168976,
-0.005617661867290735,
-0.5459747910499573,
-0.5994988083839417,
0.6425184011459351,
-0.24335084855556488,
0.0948961302... | |
(
ADDRESS = (PROTOCOL=TCP)(HOST=10.1.3.42)(PORT=1521)
)
(
CONNECT_DATA = (SERVICE_NAME=acc)
)
)
```
Note: Actual `HOST`, `PORT`, and `SERVICE_NAME` will vary based on Oracle server you are establishing a connection to. This information can often be found using the Oracle network client tools under the *... | [
0.1371898651123047,
-0.2552148997783661,
0.3005228340625763,
0.3035105764865875,
0.08843232691287994,
-0.07113857567310333,
0.20410749316215515,
0.042267557233572006,
-0.24524061381816864,
-0.5340995788574219,
-0.23711149394512177,
0.5479211807250977,
-0.22476664185523987,
0.39824917912483... | |
**`PATH`** environment variable.
e. Create a new system environment variable named **`TNS_Admin`** that has a value of [directory]
f. Execute the **`[directory]\odbc_install.exe`** utility to install the Oracle ODBC drivers.
g. It is recommended that you reboot the SQL server, but may not be necessary. Also, you may... | [
0.16391974687576294,
-0.008520427159965038,
0.4746254086494446,
-0.035068973898887634,
0.05763711407780647,
-0.16479900479316711,
0.03924983739852905,
-0.1879800409078598,
0.03380977362394333,
-1.007042646408081,
-0.3326411545276642,
0.7244707942008972,
-0.5056025981903076,
0.2067536264657... | |
drivers list, select *Oracle in instantclient {version}*. (e.g. 'Oracle in instantclient 10\_2') and then select Finish button.
d. Specify the following:
* `Data Source Name`: {System DSN Name}
* `Description`: {leave blank/empty}
* `TNS Service Name`: should have the `OracleTnsName` you defined in the **`tnsnames.or... | [
-0.07143539935350418,
0.13693559169769287,
0.4722767472267151,
0.18161459267139435,
-0.1818351447582245,
0.2684943974018097,
-0.09735136479139328,
-0.1408943384885788,
0.2101149708032608,
-0.694004237651825,
-0.17533308267593384,
0.8830306529998779,
-0.20758068561553955,
0.2325268834829330... | |
@server = '{Linked Server Name}'
,@srvproduct = '{System DSN Name}'
,@provider = 'MSDASQL'
,@datasrc = '{System DSN Name}'
EXEC sp_addlinkedsrvlogin
@rmtsrvname = '{Linked Server Name}'
,@useself = 'False'
,@locallogin = NULL
,@rmtuser = '{Oracle Use... | [
-0.012405648827552795,
-0.22507233917713165,
0.4402017593383789,
0.13494880497455597,
-0.1934768259525299,
0.08348001539707184,
0.2284083068370819,
-0.020433535799384117,
-0.4425477981567383,
-0.21952855587005615,
-0.11267315596342087,
0.35269293189048767,
-0.28713005781173706,
0.474109232... | |
,@rmtpassword = '{Oracle User Password}'
```
Note: The `{Linked Server Name}` can be anything you want to use when referencing the Oracle server, but the `{System DNS Name}` **must** match the name of the system DSN you created previously.
The `{Oracle User Name}` should be the same as the User ID used by the syst... | [
0.19234417378902435,
0.18828165531158447,
0.2319047451019287,
0.15085268020629883,
-0.21641258895397186,
-0.14308151602745056,
0.244356170296669,
-0.09387096762657166,
-0.2790539264678955,
-0.08489380031824112,
-0.18090468645095825,
0.4576002359390259,
-0.3728764057159424,
0.10701151937246... | |
server, but be aware that for very large recordsets you may receive a `ORA-01652` error message if you specify a `ORDER BY` clause in the pass-through query. Moving the `ORDER BY` clause from the pass-through query to the outer select statement solved this issue for me. | [
-0.003234919160604477,
-0.11670459806919098,
0.20981018245220184,
0.04341677576303482,
-0.13988125324249268,
-0.20127788186073303,
0.2414988875389099,
0.16310593485832214,
-0.5326430201530457,
-0.4926092028617859,
0.07598795741796494,
0.24906429648399353,
-0.38766205310821533,
0.3074913620... | |
I'm working on a puzzle game, the game engine holds a complex hierarchy of objects, from game actors to vectors to transition animations. Depending on the game state, they might add up from 10 to 1000 (in extreme cases). I've been delaying the moment until I'd have to work on the saving and loading of all that mess, as... | [
0.1685808151960373,
0.014008136466145515,
0.22807489335536957,
0.39622974395751953,
-0.006033957004547119,
0.374754399061203,
0.032638873904943466,
-0.032248854637145996,
-0.47327229380607605,
-0.6299915909767151,
0.17226888239383698,
0.21739128232002258,
-0.03608169034123421,
0.5401203632... | |
include the pointers between saved objects? And how does it behave performance-wise? Will the system have time to save all these objects on disk on app termination?
I went for NSKeyedArchiver, which does maintain references between objects. See here: [Easy way to archive interlinked objects](https://stackoverflow.com/q... | [
-0.005670302081853151,
0.0469636544585228,
0.07063435018062592,
0.14618468284606934,
0.02327084168791771,
0.009868167340755463,
0.30247634649276733,
-0.0068388432264328,
-0.5809440612792969,
-0.3840293288230896,
0.01240580528974533,
0.41287896037101746,
-0.3025572896003723,
0.0778373628854... | |
I would like to know the simplest and most effective way to open and write data to a socket in the C programming language for network programming.
You're right, using sockets in C has a difficult syntax. Later languages like Java and Python make it a snap by comparison. The best tutorial I've found for doing socket pro... | [
0.5191274285316467,
0.183024600148201,
-0.10730922967195511,
0.10725200176239014,
-0.2227150946855545,
-0.15860490500926971,
0.25367411971092224,
0.3294045627117157,
-0.3616505563259125,
-0.7928862571716309,
0.0750582367181778,
0.6662289500236511,
0.191208615899086,
0.07918728142976761,
... | |
Ok as programmers we all follow programming standards (as in W3 standards, or C++ standard, etc...), and many of us consider these standards "sacred" and also many seasoned programmers can recite their choice of standards by heart when asked about a question in their field of expertise. You can see this last case a lot... | [
1.0098090171813965,
0.47500544786453247,
0.09718002378940582,
-0.04490601271390915,
-0.40419116616249084,
-0.5633953213691711,
0.24832892417907715,
0.30572739243507385,
-0.400957316160202,
-0.264342725276947,
-0.09296035021543503,
0.8123013377189636,
0.2047155201435089,
0.1346157044172287,... | |
personal modus-operandi recently has been to read the upcoming standards that will affect me, and if I have concerns I don't rant, I mail the consortium explaining my concerns and suggestions. Many times I get positive responses, other times I get well explained reasoning why it can't be done, and of course other times... | [
0.8810995817184448,
0.12488744407892227,
0.23515819013118744,
-0.021495921537280083,
-0.535673201084137,
-0.2427739053964615,
0.5624696612358093,
0.24763011932373047,
-0.2632642984390259,
-0.38458681106567383,
0.18038257956504822,
0.4316830635070801,
0.16390439867973328,
0.2065124809741974... | |
standards committees (C#, CLI), I personally appreciated public input on the standard. We, in fact, released interim draft standards a couple of times and got some public eyes on them before they were officially ratified.
It's all about getting a fresh pair of eyes -- the folks working on the standards can sometimes b... | [
0.894108772277832,
0.389734148979187,
0.2112758606672287,
0.1171892061829567,
-0.2286715805530548,
-0.4571882486343384,
0.01857091300189495,
0.009297553449869156,
-0.3686179220676422,
-0.24616363644599915,
0.2532484531402588,
0.4038185179233551,
0.23653006553649902,
-0.01365519780665636,
... | |
```
class Ball:
a = []
def __init__(self):
pass
def add(self,thing):
self.a.append(thing)
def size(self):
print len(self.a)
for i in range(3):
foo = Ball()
foo.add(1)
foo.add(2)
foo.size()
```
I would expect a return of :
```
2
2
2
```
But I get :
```
2
4
6
```
Why is this? I've f... | [
-0.1930381804704666,
-0.018192654475569725,
0.12915945053100586,
-0.2630005180835724,
-0.41156312823295593,
0.21413499116897583,
0.24230322241783142,
-0.3036213219165802,
-0.16627147793769836,
-0.4584773778915405,
-0.0879681333899498,
0.581688642501831,
-0.5350386500358582,
-0.019952034577... | |
a=[] and placing it into the **init** block means that it's a data attribute instead. (And, I couldn't access it then with foo.a, which I shouldn't do anyhow.) It seems like the class attributes act like static attributes of the class, they're shared by all instances.
Whoa.
One question though : CodeCompletion suck... | [
0.1688804030418396,
-0.05002764239907265,
-0.18404985964298248,
-0.23407712578773499,
-0.26477909088134766,
-0.09647176414728165,
0.43516311049461365,
-0.0902525782585144,
-0.22837886214256287,
-0.2011144459247589,
0.20013217628002167,
0.554648220539093,
-0.4823739528656006,
0.070264294743... | |
I was thinking along the lines of using `typeid()` but I don't know how to ask if that type is a subclass of another class (which, by the way, is abstract)
You really shouldn't. If your program needs to know what class an object is, that usually indicates a design flaw. See if you can get the behavior you want using vi... | [
0.3683531880378723,
-0.09166480600833893,
-0.11441970616579056,
-0.2140337973833084,
0.1169988289475441,
-0.051768843084573746,
0.4152919054031372,
0.047930218279361725,
-0.32414335012435913,
-0.45312991738319397,
-0.16074582934379578,
0.7178235054016113,
-0.6149089932441711,
0.16090255975... | |
*/) /* do X */
else /* do Y */
}
```
If this is what you have, then try to do something like this:
```
class Base
{
virtual void bar() = 0;
};
class A : public Base
{
void bar() {/* do X */}
};
class B : public Base
{
void bar() {/* do Y */}
};
void foo(Base *p)
{
p->bar();
}
```
**Edit:** Since the d... | [
0.4101070463657379,
0.19730791449546814,
0.31637030839920044,
-0.0987088531255722,
0.18831270933151245,
-0.07524898648262024,
0.10139317810535431,
-0.27068784832954407,
-0.10407578200101852,
-0.4822786748409271,
-0.08628977835178375,
0.4839977025985718,
-0.47617071866989136,
0.314542949199... | |
then it violates [Liskov substitution principle](https://en.wikipedia.org/wiki/Liskov_substitution_principle). [Uncle Bob](http://www.objectmentor.com/omTeam/martin_r.html) calls this an "[anathema to Object Oriented Design](http://www.objectmentor.com/resources/articles/lsp.pdf)". | [
0.3548632860183716,
0.36810460686683655,
0.36339864134788513,
-0.3856632709503174,
0.18481001257896423,
-0.25771716237068176,
0.36933791637420654,
-0.15114165842533112,
-0.03320794180035591,
-0.03717827796936035,
-0.33291783928871155,
0.19859431684017181,
-0.41584113240242004,
0.6146990656... | |
I'm trying to convert a Web Site to the Web Application project model and I'm running into compile errors that do not seem to be covered by the guidance I found at [Converting a Web Site Project to a Web Application Project](http://msdn.microsoft.com/en-us/library/aa983476.aspx).
The issue is that standard ASP.NET con... | [
0.0448482371866703,
0.09323976188898087,
0.21038676798343658,
0.17616070806980133,
0.1576424390077591,
-0.010340508073568344,
0.28550076484680176,
0.12562546133995056,
-0.02463327907025814,
-0.7906554341316223,
-0.023716982454061508,
0.4026573896408081,
-0.04690099507570267,
-0.01890713348... | |
in the page's code behind file as properties.
Unfortunately, we have a lot of webforms that utilize the TabContainer, and converting all the references to child controls from simple property refences to FindControl calls will be quite burdensome.
While researching the problem I found a reference to a property called ... | [
0.3476646840572357,
-0.09540984779596329,
0.042104773223400116,
0.48550060391426086,
-0.17154715955257416,
-0.048132818192243576,
0.46951356530189514,
-0.23325331509113312,
-0.26575201749801636,
-0.5228309631347656,
0.05250775068998337,
0.0037331869825720787,
-0.395126610994339,
0.36528351... | |
behavior you want using virtual functions. Also, more information about what you are trying to do would help.
I am assuming you have a situation like this:
```
class Base;
class A : public Base {...};
class B : public Base {...};
void foo(Base *p)
{
if(/* p is A */) /* do X */
else /* do Y */
}
```
If this is ... | [
-0.08110206574201584,
-0.2781672775745392,
0.06960052251815796,
-0.14461086690425873,
0.07207296043634415,
-0.02069977857172489,
0.5102642178535461,
-0.1408023238182068,
-0.5681505799293518,
-0.532299816608429,
-0.0685749277472496,
0.9308057427406311,
-0.6894024014472961,
0.086959145963191... | |
Since the debate about this answer still goes on after so many years, I thought I should throw in some references. If you have a pointer or reference to a base class, and your code needs to know the derived class of the object, then it violates [Liskov substitution principle](https://en.wikipedia.org/wiki/Liskov_substi... | [
0.31987154483795166,
0.40364062786102295,
0.11021032929420471,
-0.22683961689472198,
0.1712738424539566,
-0.37405455112457275,
0.5144272446632385,
-0.21632863581180573,
-0.21873021125793457,
0.06451820582151413,
-0.06688831001520157,
0.2683793902397156,
-0.4274301528930664,
0.7178857922554... | |
I am using my own custom authentication with IIS, and I want the server on *every* page load (no matter what type of file) to first check the Application variable to see if the user is authenticated and authorized to see the site. In global.asax this could be:
```
void Application_Start(Object Sender, EventArgs e)
{
... | [
-0.009570829570293427,
0.03503536805510521,
0.42191407084465027,
-0.3779619336128235,
-0.05720071867108345,
-0.15170545876026154,
0.40979763865470886,
-0.0020755664445459843,
-0.35714656114578247,
-0.6709702610969543,
-0.11180068552494049,
0.3023551404476166,
-0.4151531159877777,
0.2497620... | |
customizable at directory level, then this wouldn't be a problem. But since there is only one global.asax per *server* I cannot implement this solution.
What alternatives are there to global.asax? or can global.asax be different somehow for each directory?
HttpModules are an alternative to global.asax
================... | [
-0.025587931275367737,
-0.41046571731567383,
0.3771496117115021,
-0.14604704082012177,
-0.0019136377377435565,
0.020292026922106743,
0.22397111356258392,
-0.0324380025267601,
-0.6734634041786194,
-0.721764862537384,
-0.05118294060230255,
0.16031430661678314,
-0.41675734519958496,
0.0135654... | |
gets to the actual page code itself. This happens regardless of what kind of request it is:
```
"page.aspx" "page.html"
| |
( | module 1 | )
( | module 2 | )
( | module 3 | )
V V
(handler 1) (handler 2)
```
((a much better picture and description can be found at | [
-0.03096039779484272,
-0.23059532046318054,
0.8528841137886047,
0.09094344824552536,
0.16478334367275238,
-0.32598811388015747,
0.4448319673538208,
-0.26473313570022583,
-0.2438860386610031,
-0.763392984867096,
-0.37738800048828125,
0.2032317817211151,
-0.31521955132484436,
-0.150118991732... | |
<https://www.codeguru.com/csharp/.net/net_asp/article.php/c19389/HTTP-Handlers-and-HTTP-Modules-in-ASPNET.htm> ))
So then all you need to do is define your code as a module instead of in global.asax . If the user isn't authenticated, then: `response.redirect("login.aspx")` will stop control from ever reaching the hand... | [
0.053960006684064865,
-0.33760586380958557,
0.11701253801584244,
0.021063145250082016,
0.14752161502838135,
-0.27333804965019226,
0.5346944332122803,
-0.019590307027101517,
-0.4851073920726776,
-0.6786618232727051,
-0.3459559977054596,
0.27369314432144165,
-0.5302841663360596,
0.0015678647... | |
I am trying to add a `UIButton` at runtime however it is not visible. What am I doing wrong?
```
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
btn.frame = CGRectMake(0, 0, 100, 25);
b... | [
0.3180427849292755,
-0.21065323054790497,
0.7876275777816772,
-0.3381211459636688,
0.045974165201187134,
0.3173366189002991,
0.6721271276473999,
-0.4668178856372833,
0.020169468596577644,
-0.6285579800605774,
-0.3608490228652954,
0.5222684741020203,
-0.2689553499221802,
-0.0332708172500133... | |
btn.center = self.center;
[self addSubview:btn];
}
return self;
}
```
First, make sure the initWithFrame: method is being called. If your view is in a Nib, initWithCoder: is being called instead.
Second, is the button the only subview (from your code it looks like it is, but you never know). The butto... | [
0.21045705676078796,
-0.33982983231544495,
0.6635636687278748,
-0.14412744343280792,
-0.1991203874349594,
0.1531677395105362,
0.24427810311317444,
-0.22125688195228577,
-0.22899508476257324,
-0.8499473929405212,
-0.11206213384866714,
0.5271432399749756,
-0.11563822627067566,
-0.09760868549... | |
the button won't show because it will get clipped by the view's bounds. | [
0.313528835773468,
-0.25166603922843933,
0.816680908203125,
0.13230741024017334,
0.5432426929473877,
-0.10109531879425049,
0.346082866191864,
-0.29997462034225464,
-0.20370075106620789,
-0.18807777762413025,
0.09636695683002472,
0.374294638633728,
-0.25436562299728394,
-0.39656132459640503... | |
So, I'm working on some network programming in C, and it would seem that I am missing a bunch of standard C/C++ header files. For example, `sys/socket.h` is not there. A few otheres are missing too like `netdb.h`, and `unistd.h`. Is there a pack I need to install to get these on windows?
Thanks
All these headers are f... | [
0.5641307234764099,
0.26141247153282166,
-0.1540404111146927,
0.19025404751300812,
-0.1408339887857437,
-0.43230944871902466,
0.1280425786972046,
0.26853272318840027,
-0.19917696714401245,
-0.7981839776039124,
0.01571737229824066,
0.540144681930542,
-0.3205386996269226,
0.25644588470458984... | |
I've connected to a MySQL database using Perl DBI. I would like to find out which database I'm connected to.
I don't think I can use:
```
$dbh->{Name}
```
because I call [`USE new_database`](http://dev.mysql.com/doc/refman/5.0/en/use.html) and `$dbh->{Name}` only reports the database that I initially connected to.
... | [
0.5469657778739929,
0.17871128022670746,
0.30147215723991394,
0.008337344042956829,
-0.13979487121105194,
-0.25321274995803833,
0.26380372047424316,
-0.24586327373981476,
-0.21645070612430573,
-0.650783896446228,
0.09709370136260986,
0.3827967941761017,
-0.3341507911682129,
0.6301550269126... | |
I am developing an online examination using servlets/jsp.I need to add a count down (hh/mm/ss) timer to the questions page that would end the exam and redirects to results page.
I am done with all the other functionalities except the timer one.
Can someone provide some help on this.
Thanks
Have you tried a JavaScrip... | [
0.2919631600379944,
-0.14302115142345428,
0.3954094648361206,
0.18588778376579285,
0.06046045944094658,
-0.05007617175579071,
0.213388592004776,
-0.15806548297405243,
-0.24864250421524048,
-0.8402532339096069,
0.39978185296058655,
0.27316728234291077,
-0.01445308793336153,
0.03246508538722... | |
Is it possible to declare an instance of a generic without knowing the type at design-time?
Example:
```
Int i = 1;
List<typeof(i)> list = new List<typeof(i)>();
```
where the type of i could be anything, instead of having to do:
```
List<int> list = new List<int();
```
If you don't know the type at compile-time,... | [
0.21774445474147797,
-0.014848820865154266,
0.16153930127620697,
-0.08371675759553909,
-0.38722318410873413,
-0.1505080610513687,
0.4280209541320801,
-0.23735010623931885,
-0.022818075492978096,
-0.4911635220050812,
0.13412554562091827,
0.35810139775276184,
-0.5492519736289978,
0.217174515... | |
use normal generics after that. For example:
```
object x = GetObjectFromSomewhere();
// I want to create a List<?> containing the existing
// object, but strongly typed to the "right" type depending
// on the type of the value of x
MethodInfo method = GetType().GetMethod("BuildListHelper");
method = method.MakeGeneri... | [
0.2368370145559311,
-0.23636406660079956,
0.28286635875701904,
-0.19269442558288574,
-0.13164730370044708,
-0.23236608505249023,
0.33631253242492676,
-0.42745018005371094,
-0.147321417927742,
-0.6047366261482239,
-0.03227511793375015,
0.5538538694381714,
-0.6499831676483154,
0.374478250741... | |
Not always though - I've used something like the above on a few occasions, where the type system just doesn't quite let me express everything I need to statically.
EDIT: Note that although I'm calling Type.GetMethod in the code above, if you were going to execute it a lot you'd probably want to just call it once - aft... | [
0.23741230368614197,
-0.18509218096733093,
0.07432127743959427,
0.10858553647994995,
-0.2829761207103729,
-0.16262368857860565,
0.4763934314250946,
0.31928110122680664,
-0.3657491207122803,
-0.36226704716682434,
0.13163015246391296,
0.4044855237007141,
-0.3762871325016022,
0.05305774882435... | |
the GetMethod call in sample code - you'd need to specify the appropriate binding flags otherwise. | [
0.560255229473114,
-0.04998631775379181,
0.1755697876214981,
0.27486661076545715,
-0.13345812261104584,
-0.37672388553619385,
-0.0038610491901636124,
-0.3529491722583771,
0.06813910603523254,
-0.18235984444618225,
-0.13975787162780762,
0.49141064286231995,
-0.25464916229248047,
-0.01572733... | |
I have this line of JavaScript and the behavior I am seeing is that the `selectedLi` instantly disappears without "sliding up". This is not the behavior that I expected.
What should I be doing so that the `selectedLi` slides up before it is removed?
```
selectedLi.slideUp("normal").remove();
```
Might be able to fix... | [
-0.04957907646894455,
-0.22132644057273865,
0.44188642501831055,
-0.08306978642940521,
0.14656779170036316,
-0.119455985724926,
0.053600504994392395,
0.028494464233517647,
-0.2004384845495224,
-0.6538569927215576,
-0.27923229336738586,
0.4970497488975525,
-0.6910025477409363,
0.25448480248... | |
I think my eclipse's ctrl+clicking links might benefit greatly...
**Edit:** I'm using eclipse PDT.
**Edit 2:** I'm very happy with the solution of putting docblocks before functions (and variables) with an @return or @var statement, I've just updated the documentation of my app and now eclipse is showing me what func... | [
0.2760673463344574,
-0.2507592439651489,
0.500363826751709,
0.09296993911266327,
-0.2887248992919922,
-0.16665619611740112,
-0.019722096621990204,
-0.13157790899276733,
-0.18650971353054047,
-0.944719135761261,
-0.043771304190158844,
0.9457844495773315,
-0.24960124492645264,
-0.15785877406... | |
I was of the opinion that virtualization doesnt work in the super class constructor as per the design of OOP. For example, consider the following C# code.
```
using System;
namespace Problem
{
public class BaseClass
{
public BaseClass()
{
Console.WriteLine("Hello, World!");
... | [
-0.11035240441560745,
-0.2467917650938034,
0.21524663269519806,
0.04828751087188721,
0.2696547508239746,
-0.05061497539281845,
0.24501699209213257,
0.3479517698287964,
-0.11424433439970016,
-0.6103699207305908,
-0.08074653148651123,
0.546949028968811,
-0.2683262228965759,
0.323347389698028... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.