text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
return '%s(%s) at %s' % (self.type, self.val, self.pos)
class LexerError(Exception):
""" Lexer error exception.
pos:
Position in the input line where the error occurred.
"""
def __init__(self, pos):
self.pos = pos
class Lexer(object):
""" A simple regex-based lexer/tokeniz... | [
-0.4032824635505676,
-0.1424643099308014,
0.13238108158111572,
-0.1127549558877945,
-0.10168622434139252,
0.3454110324382782,
0.1999213844537735,
-0.07480677962303162,
0.0024585621431469917,
-0.24733524024486542,
-0.301613986492157,
0.5991766452789307,
-0.2152552753686905,
0.04331663623452... | |
def __init__(self, rules, skip_whitespace=True):
""" Create a lexer.
rules:
A list of rules. Each rule is a `regex, type`
pair, where `regex` is the regular expression used
to recognize the token and `type` is the type | [
0.11048775166273117,
-0.17036861181259155,
0.06929223984479904,
0.21432733535766602,
-0.10077174752950668,
0.061286479234695435,
0.2453899383544922,
-0.48051735758781433,
-0.12019447237253189,
-0.2119361311197281,
-0.3627845048904419,
0.39076343178749084,
-0.4540696144104004,
-0.0872252732... | |
of the token to return when it's recognized.
skip_whitespace:
If True, whitespace (\s+) will be skipped and not
reported by the lexer. Otherwise, you have to
specify your rules | [
0.04788079857826233,
-0.14680983126163483,
0.03538031876087189,
-0.14719919860363007,
0.17122741043567657,
-0.07437366247177124,
0.26550018787384033,
-0.24880072474479675,
-0.5266221761703491,
-0.32557412981987,
-0.3385498523712158,
0.2248159497976303,
-0.5488051176071167,
-0.0908157974481... | |
for whitespace, or it will be
flagged as an error.
"""
self.rules = []
for regex, type in rules:
self.rules.append((re.compile(regex), type))
self.skip_whitespace = skip_whitespace
self.re_ws_skip = re.compile('\S')
def input(self, buf): | [
-0.14922094345092773,
-0.041181616485118866,
0.18187832832336426,
-0.3189263343811035,
0.22760477662086487,
0.25334247946739197,
0.39158913493156433,
-0.5148426294326782,
-0.5625029802322388,
-0.5120028853416443,
-0.32718878984451294,
0.14813487231731415,
-0.7082108855247498,
-0.3489856719... | |
""" Initialize the lexer with a buffer as input.
"""
self.buf = buf
self.pos = 0
def token(self):
""" Return the next token (a Token object) found in the
input buffer. None is returned if the end of the
buffer was reached. | [
-0.3429463803768158,
-0.15891778469085693,
0.4508501887321472,
-0.29651159048080444,
-0.10482342541217804,
0.19387748837471008,
0.11328518390655518,
-0.2791157066822052,
0.03398456424474716,
-0.39810407161712646,
-0.3787841796875,
0.4253847301006317,
-0.26675882935523987,
-0.03746185824275... | |
In case of a lexing error (the current chunk of the
buffer matches no rule), a LexerError is raised with
the position of the error.
"""
if self.pos >= len(self.buf):
return None
else: | [
-0.15706445276737213,
-0.08013944327831268,
0.4032686650753021,
-0.21905915439128876,
0.07271964102983475,
0.6394641995429993,
-0.017338287085294724,
-0.12829609215259552,
-0.1153634786605835,
-0.2121971845626831,
-0.4676637649536133,
0.6100171804428101,
-0.03678746521472931,
-0.0988381803... | |
if self.skip_whitespace:
m = self.re_ws_skip.search(self.buf[self.pos:])
if m:
self.pos += m.start()
else: | [
-0.4554320275783539,
-0.03504212573170662,
0.24024784564971924,
-0.40101513266563416,
0.336181640625,
0.28546983003616333,
0.25105205178260803,
-0.323250949382782,
-0.6513452529907227,
-0.4922720491886139,
-0.32331955432891846,
0.15546207129955292,
-0.41393500566482544,
-0.0290312785655260... | |
return None
for token_regex, token_type in self.rules:
m = token_regex.match(self.buf[self.pos:])
if m:
value = self.buf[self.pos + m.start():self.pos + m.end()] | [
-0.5519943833351135,
-0.024479996412992477,
0.2968901991844177,
-0.2821445167064667,
0.06516403704881668,
0.20522692799568176,
0.27571049332618713,
-0.3961062431335449,
-0.33442366123199463,
-0.2968541383743286,
-0.37867653369903564,
0.39501428604125977,
-0.34650135040283203,
0.00705102412... | |
tok = Token(token_type, value, self.pos)
self.pos += m.end()
return tok
# if we're here, no rule matched
raise LexerError(self.pos)
def tokens(self):
""" Returns an iterator to the tokens found in | [
0.038237858563661575,
-0.18204748630523682,
0.4985947012901306,
-0.009830256924033165,
0.12936992943286896,
0.17899440228939056,
0.18917523324489594,
-0.45324230194091797,
-0.09804761409759521,
-0.2911163568496704,
-0.23478825390338898,
0.4051796495914459,
-0.05637727677822113,
-0.01898386... | |
the buffer.
"""
while 1:
tok = self.token()
if tok is None: break
yield tok
if __name__ == '__main__':
rules = [
('\d+', 'NUMBER'),
('[a-zA-Z_]\w+', | [
-0.5074173212051392,
-0.016351891681551933,
0.1385953575372696,
-0.26346030831336975,
0.07274924963712692,
0.04856083542108536,
0.4594617784023285,
-0.24442021548748016,
-0.09860207885503769,
-0.2523898780345917,
-0.34761396050453186,
0.2672508656978607,
-0.12857303023338318,
0.14276240766... | |
'IDENTIFIER'),
('\+', 'PLUS'),
('\-', 'MINUS'),
('\*', 'MULTIPLY'),
('\/', 'DIVIDE'),
('\(', | [
0.16995014250278473,
-0.09251675009727478,
0.29753243923187256,
0.2117765098810196,
0.1608472615480423,
0.49679073691368103,
-0.09092073142528534,
-0.12405606359243393,
0.04816030338406563,
-0.5973997116088867,
-0.5354815721511841,
0.04587430879473686,
-0.40374526381492615,
0.1100762411952... | |
'LP'),
('\)', 'RP'),
('=', 'EQUALS'),
]
lx = Lexer(rules, skip_whitespace=True)
lx.input('erw = _abc + 12*(R4-623902) ')
try:
for tok in lx.tokens(): | [
-0.13424533605575562,
-0.24378538131713867,
0.1789325624704361,
-0.3351009786128998,
0.1778504103422165,
0.42613208293914795,
0.03207193687558174,
-0.38553115725517273,
-0.13313886523246765,
-0.3873329162597656,
-0.2586020231246948,
0.29442644119262695,
-0.40939319133758545,
-0.27749460935... | |
print tok
except LexerError, err:
print 'LexerError at position', err.pos
```
It works just fine, but I'm a bit worried that it's too inefficient. Are there any regex tricks that will allow me to write it in a more efficient / elegant way ?
Specifically, is there a way to avoid looping over all the rege... | [
0.029401304200291634,
-0.11913833022117615,
0.29660287499427795,
0.10253936052322388,
-0.06008045747876167,
0.22654187679290771,
-0.17741963267326355,
0.028131840750575066,
0.06608378142118454,
-0.5230392217636108,
0.03323713317513466,
0.42521557211875916,
-0.2767506241798401,
-0.242195814... | |
Some care should be taken to ensure the preference of tokens (for example to avoid matching a keyword as an identifier). | [
0.16428157687187195,
0.08180595189332962,
-0.2233790159225464,
0.24974578619003296,
0.10075822472572327,
-0.1729455590248108,
0.10207676142454147,
-0.13535286486148834,
-0.2536977231502533,
-0.4680655002593994,
-0.4511834383010864,
0.05399804562330246,
0.0820842906832695,
-0.37990662455558... | |
I need to create a multi-dimensional (nested) hashtable/dictionary so that I can use syntax like
```
val = myHash("Key").("key")
```
I know I need to use Generics but I can't figure out the correct syntax using VB in ASP.NET 2.0, there are plenty of c# examples on the net but they aren't helping much.
Cheers!
OK, ... | [
0.29895398020744324,
0.4772503674030304,
0.32953551411628723,
-0.1699015349149704,
-0.2650604248046875,
-0.2763361930847168,
0.32305264472961426,
-0.06014479324221611,
-0.1082712709903717,
-0.6946420073509216,
-0.09605249762535095,
0.757793128490448,
-0.10753978043794632,
0.330119520425796... | |
I have a form with a default OK button, and a Cancel button. I have a treeview with nodes that can be edited, i.e. you can double-click them or press F2 to open another form.
Now, I've never liked that F2 shortcut, and now that I'm enabling treeview label edition, it's even worse. My first reaction when testing the fo... | [
0.13027256727218628,
-0.06008001044392586,
0.47167298197746277,
-0.18046686053276062,
0.08230195939540863,
-0.1307898461818695,
0.30136433243751526,
0.14268366992473602,
-0.099516861140728,
-0.5946011543273926,
-0.048529233783483505,
0.4765452444553375,
-0.2382412701845169,
-0.026052499189... | |
should an application use to "edit the selected item"?
Absolutely no. The Enter key is often used to fire the default button but equally often not. For example, Enter generally means new line in a multiline textbox.
Enter sounds like a good bet in this scenario. F2 tends to mean "Edit" in Windows.
However, if this is... | [
0.16971519589424133,
-0.061963554471731186,
0.3268297016620636,
0.08174669742584229,
-0.007177179679274559,
-0.249090313911438,
0.3370087742805481,
-0.014810124412178993,
-0.17092391848564148,
-0.5817846059799194,
-0.3928484618663788,
0.6465168595314026,
-0.3637846112251282,
-0.07216513901... | |
For example, if I have an echo statement, there's no guarantee that the browser might display it right away, might display a few dozen echo statements at once, and might wait until the entire page is done before displaying anything.
Is there a way to have each echo appear in a browser as it is executed?
You can use [`... | [
0.3861054480075836,
-0.34511879086494446,
0.15633714199066162,
-0.2959343492984772,
-0.08648455888032913,
-0.04645881429314613,
0.5099409222602844,
-0.4196571409702301,
-0.24611809849739075,
-0.4864857494831085,
0.002633608877658844,
0.4299684166908264,
-0.41117119789123535,
-0.11552581191... | |
I am developing, a simple SharePoint Sequential Workflow which should be bound to a document library. When associating the little workflow to a document library, I checked these options
* Allow this workflow to be manually
started by an authenticated user
with Edit Items Permissions.
* Start
this workflow when a new ... | [
0.5424726009368896,
0.016767624765634537,
0.34231171011924744,
0.10258287936449051,
0.04269033670425415,
-0.29075711965560913,
0.264484703540802,
0.0002630045637488365,
-0.2741383910179138,
-0.9638438820838928,
-0.06668023765087128,
0.4386179447174072,
-0.17085333168506622,
0.3661038279533... | |
expected.
Even when copying a new Item into the library with help of the Copy.asmx Webservice, the workflow starts normally.
But **now** I want to update the item **via the SharePoint WebService Lists.asmx**.
My [CAML](http://en.wikipedia.org/wiki/Collaborative_Application_Markup_Language) goes here:
```
<Method ID... | [
0.10930391401052475,
0.1028984859585762,
0.42880362272262573,
0.10116615891456604,
-0.01776457391679287,
-0.3474264144897461,
0.32596564292907715,
-0.05681968107819557,
-0.4104514718055725,
-0.7284452319145203,
-0.017876839265227318,
0.3160240352153778,
-0.16358956694602966,
0.341582566499... | |
0x1D60 Windows SharePoint Services General 6875 Critical Error loading and running event receiver Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver in Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c. Additional information is below... | [
0.19549879431724548,
0.12263866513967514,
0.20256780087947845,
0.0207911878824234,
-0.09465472400188446,
-0.14282944798469543,
0.5468607544898987,
0.1525970995426178,
-0.15625441074371338,
-0.5841809511184692,
-0.31417781114578247,
0.39363333582878113,
-0.4186234176158905,
0.17881001532077... | |
developments on this topic.
**Finally, we got through the support services processes at Microsoft and got a solution!**
First, Microsoft stated this to be a bug. It is a minor bug, because there is a good workaround, so it may take some longer time, until this bug will be fixed (the support technician said something w... | [
0.19421319663524628,
0.04842587932944298,
0.5376686453819275,
0.13857577741146088,
0.25240954756736755,
-0.37343379855155945,
-0.0017260622698813677,
0.03528536856174469,
-0.09068228304386139,
-0.6625749468803406,
-0.03810325264930725,
0.5948619842529297,
-0.14317235350608826,
0.1382449716... | |
second line. Strange, all other SharePoint commands are working with the ID, but not the Workflow Manager. The Workflow Manager works with the "fully qualified" document name. So, because we had no clue and didn't entered any fully qualified document name, the Workflow Manager defaults to the name of the current docume... | [
0.05650012195110321,
-0.03648412600159645,
0.6783086657524109,
0.2122277170419693,
0.15526503324508667,
-0.27173951268196106,
0.23887106776237488,
0.033479634672403336,
-0.027833309024572372,
-0.6932883858680725,
-0.2169630527496338,
0.5494067072868347,
-0.31835952401161194,
0.399300992488... | |
the fully qualified document name to the Workflow Manager, which - now totally happy - starts the workflow of the item.
Be careful, you have to include the full absolute server path, omitting your server name (found for example in ServerRelativePath property of your SPItem).
Full working CAML Query:
```
<Method ID=... | [
-0.08624568581581116,
0.050811946392059326,
0.866808295249939,
0.23001758754253387,
0.05727805569767952,
-0.48075127601623535,
0.34097713232040405,
-0.03682779148221016,
-0.0903782919049263,
-0.45231178402900696,
-0.4653622806072235,
0.5828250050544739,
0.1008649617433548,
-0.0097677474841... | |
month I hope this article on stackoverflow will help developers in the same situation.
Thanks for reading! | [
0.04637102782726288,
-0.1526884138584137,
0.46772661805152893,
0.4989832043647766,
-0.19700632989406586,
-0.31032633781433105,
0.26343947649002075,
0.5993440747261047,
-0.5681650638580322,
-0.24702729284763336,
-0.11171449720859528,
-0.24521730840206146,
0.3934227228164673,
0.1567271351814... | |
I just came across an interesting situation in JavaScript. I have a class with a method that defines several objects using object-literal notation. Inside those objects, the `this` pointer is being used. From the behavior of the program, I have deduced that the `this` pointer is referring to the class on which the meth... | [
0.3001103401184082,
0.2022930532693863,
-0.17453350126743317,
0.03434482589364052,
0.02451918087899685,
-0.16488829255104065,
0.10351686924695969,
0.09309021383523941,
-0.1460409164428711,
-0.5989670157432556,
0.09421198070049286,
0.4197193682193756,
-0.355972558259964,
0.30207258462905884... | |
"the spec says so" (for instance, is it a consequence of some broader design decision/philosophy)? Pared-down code example:
```
// inside class definition, itself an object literal, we have this function:
onRender: function() {
this.menuItems = this.menuItems.concat([
{
text: 'Group by Module'... | [
0.3269006907939911,
-0.2834208905696869,
0.419473260641098,
-0.18289180099964142,
0.3591648042201996,
-0.058968063443899155,
-0.035396646708250046,
-0.31138941645622253,
-0.08780967444181442,
-0.3139711618423462,
-0.3750208020210266,
0.6855961680412292,
-0.4200899004936218,
-0.032707463949... | |
text: 'Group by Status',
rptletdiv: this
}]);
// etc
}
```
Cannibalized from another post of mine, here's more than you ever wanted to know about *this*.
Before I start, here's the most important thing to keep in mind about Javascript, and to repeat to yourself when it doesn't make sense. Java... | [
0.08951011300086975,
0.07244528084993362,
-0.18281365931034088,
-0.0008803254459053278,
-0.2806604206562042,
-0.17205528914928436,
0.46900424361228943,
0.13424637913703918,
-0.2867289185523987,
-0.6240187883377075,
-0.17699627578258514,
0.15725116431713104,
-0.25761663913726807,
0.01043617... | |
objects, but it can sometimes be helpful to think of them as separate things)
The *this* variable is attached to functions. Whenever you invoke a function, *this* is given a certain value, depending on how you invoke the function. This is often called the invocation pattern.
There are four ways to invoke functions in... | [
0.1752825379371643,
0.035595424473285675,
0.20734383165836334,
-0.10815228521823883,
-0.23032565414905548,
-0.053608015179634094,
0.2526942491531372,
-0.3478224575519562,
0.019230917096138,
-0.3025701344013214,
-0.23307254910469055,
0.498574823141098,
-0.5599551796913147,
0.106377325952053... | |
object the function/method is a part of. In this example, this will be bound to foo.
As A Function
-------------
If you have a stand alone function, the *this* variable will be bound to the "global" object, almost always the *window* object in the context of a browser.
```
var foo = function(){
alert(this);
}
... | [
-0.04301087558269501,
-0.20653976500034332,
0.30362024903297424,
0.16152922809123993,
-0.18755963444709778,
-0.39089882373809814,
0.4189464747905731,
-0.024228865280747414,
-0.17004700005054474,
-0.33995291590690613,
-0.2021346092224121,
0.7160835266113281,
-0.6307353377342224,
0.135774984... | |
problem by doing something like, um, this
```
var foo = {};
foo.someMethod = function (){
var that=this;
function bar(){
alert(that);
}
}
```
You define a variable *that* which points to *this*. Closure (a topic all it's own) keeps *that* around, so if you call bar as a callback, it still has a r... | [
-0.30669721961021423,
-0.06099355220794678,
0.36141377687454224,
-0.1301146149635315,
-0.06088687479496002,
-0.28797775506973267,
0.3412030041217804,
-0.009792270138859749,
-0.37713822722435,
-0.3789891004562378,
-0.30365315079689026,
0.7971264719963074,
-0.663698673248291,
0.2452365010976... | |
(TestObject) this also **may be what you're doing and is what's tripping you up**.
You invoke a function as a Constructor with the new keyword.
```
function Foo(){
this.confusing = 'hell yeah';
}
var myObject = new Foo();
```
When invoked as a constructor, a new Object will be created, and *this* will be bound ... | [
0.48060739040374756,
0.01648552529513836,
-0.09198270738124847,
0.034614406526088715,
-0.09323162585496902,
-0.4421716332435608,
0.710713803768158,
-0.15684013068675995,
-0.05985020846128464,
-0.41025128960609436,
-0.06028370186686516,
0.636050820350647,
-0.4191558063030243,
0.098775982856... | |
as a way to create something similar to classes.
With the Apply Method
---------------------
Finally, every function has a method (yes, functions are objects in Javascript) named "apply". Apply lets you determine what the value of *this* will be, and also lets you pass in an array of arguments. Here's a useless examp... | [
0.3348347246646881,
0.22101029753684998,
0.5687481760978699,
-0.39873799681663513,
0.15123215317726135,
-0.061976075172424316,
0.4142478108406067,
-0.5931232571601868,
-0.10965249687433243,
-0.5433000922203064,
-0.18724125623703003,
0.7533367276191711,
-0.9618721604347229,
0.11527772247791... | |
I need to be able to load the entire contents of a text file and load it into a variable for further processing.
How can I do that?
---
Here's what I did thanks to Roman Odaisky's answer.
```
SetLocal EnableDelayedExpansion
set content=
for /F "delims=" %%i in (test.txt) do set content=!content! %%i
echo %content... | [
0.3143945634365082,
0.1852927803993225,
0.6272899508476257,
0.05192152410745621,
0.13717730343341827,
-0.11662682145833969,
0.3462543189525604,
-0.35391226410865784,
0.13437800109386444,
-0.5132494568824768,
-0.10734714567661285,
0.5910227298736572,
-0.24476896226406097,
-0.059451863169670... | |
at <http://www.rsdn.ru/article/winshell/batanyca.xml>. If you don’t know Russian, you still could make some use of the code snippets provided. | [
0.5002517104148865,
0.09115452319383621,
-0.06793077290058136,
0.13636916875839233,
0.009902719408273697,
-0.4917824864387512,
0.19204658269882202,
0.24805593490600586,
-0.32583263516426086,
-0.19281618297100067,
-0.4723759591579437,
0.20619432628154755,
0.2534219026565552,
0.1233979016542... | |
We have some very large data files (5 gig to 1TB) where we need quick read/write access. Since we have a fixed record size it seems like some form of ISAM would be the way to go. But would be happy to hear other suggestions.
Ideally the solution would have an Apache or LGPL style license but we will pay if we have to... | [
0.5409497618675232,
0.06166446581482887,
0.28206712007522583,
0.35759833455085754,
0.11580326408147812,
-0.5693512558937073,
0.36107349395751953,
-0.2971176207065582,
-0.3889322876930237,
-0.4470173418521881,
-0.19629833102226257,
0.46037065982818604,
-0.1725997030735016,
-0.01012099999934... | |
Intrinsic compression facilities
Portable to \*nix platforms
C# API or Java API
Thanks,
Terence
Give [Berkeley DB](http://www.oracle.com/technology/products/berkeley-db/index.html) a try. Opinions vary, but it's scalable, stable (if you use all necessary layers) and AFAIK runs well on x64 windows. Also portable... | [
0.2239077091217041,
0.19354009628295898,
-0.03895394504070282,
0.12721842527389526,
-0.38422027230262756,
-0.06704522669315338,
0.11927369982004166,
-0.22103005647659302,
-0.28821220993995667,
-0.6842823624610901,
0.12748436629772186,
0.6494675278663635,
-0.295213520526886,
-0.185388699173... | |
Let's say I have code like this:
```
$dbh = new PDO("blahblah");
$stmt = $dbh->prepare('SELECT * FROM users where username = :username');
$stmt->execute( array(':username' => $_REQUEST['username']) );
```
The PDO documentation says:
> The parameters to prepared statements don't need to be quoted; the driver handle... | [
0.3693488836288452,
0.23303696513175964,
0.1198931485414505,
-0.23487333953380585,
-0.3280450701713562,
-0.028751669451594353,
0.31956636905670166,
-0.36920827627182007,
0.06619153171777725,
-0.7017204165458679,
-0.04427902773022652,
0.7436484098434448,
-0.20361915230751038,
-0.21411719918... | |
enough if used properly.
---
I'm adapting [this answer](https://stackoverflow.com/a/12118602/338665) to talk about PDO...
The long answer isn't so easy. It's based off an attack [demonstrated here](http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string).
The Attack
==========
So, let's start ... | [
0.11327267438173294,
-0.022108955308794975,
0.43208569288253784,
-0.21286101639270782,
-0.18681414425373077,
0.06051656976342201,
0.40302830934524536,
-0.4507356584072113,
-0.3680965304374695,
-0.7814086079597473,
-0.20320594310760498,
0.7625450491905212,
-0.41190674901008606,
-0.103178866... | |
character whose final byte is an ASCII `\` i.e. `0x5c`. As it turns out, there are 5 such encodings supported in MySQL 5.6 by default: `big5`, `cp932`, `gb2312`, `gbk` and `sjis`. We'll select `gbk` here.
Now, it's very important to note the use of `SET NAMES` here. This sets the character set **ON THE SERVER**. There... | [
-0.06633997708559036,
0.21676421165466309,
0.45737460255622864,
-0.060183681547641754,
-0.09243413060903549,
0.3553617000579834,
0.03133563697338104,
0.3396134674549103,
0.024137422442436218,
-0.4767150282859802,
-0.08584205061197281,
0.217949777841568,
-0.22512570023536682,
0.026214333251... | |
**and** `gbk`, `0x27` on its own is a literal `'` character.
We have chosen this payload because, if we called `addslashes()` on it, we'd insert an ASCII `\` i.e. `0x5c`, before the `'` character. So we'd wind up with `0xbf5c27`, which in `gbk` is a two character sequence: `0xbf5c` followed by `0x27`. Or in other word... | [
0.1839877814054489,
0.39801695942878723,
0.1821715235710144,
-0.19377613067626953,
-0.2655491232872009,
-0.0218957532197237,
0.19043505191802979,
-0.09569694846868515,
-0.1683291792869568,
-0.34245720505714417,
-0.23704937100410461,
0.26084503531455994,
-0.22601735591888428,
0.092041291296... | |
the query string, calling `mysql_real_escape_string()` (the MySQL C API function) on each bound string value.
The C API call to `mysql_real_escape_string()` differs from `addslashes()` in that it knows the connection character set. So it can perform the escaping properly for the character set that the server is expect... | [
-0.37508824467658997,
-0.024975420907139778,
0.5449662208557129,
0.06209786608815193,
0.18563051521778107,
0.1189054399728775,
0.24592357873916626,
-0.14160378277301788,
-0.25624772906303406,
-0.4026932418346405,
-0.37280476093292236,
0.5707889199256897,
-0.6511035561561584,
0.301100760698... | |
our "escaped" content! In fact, if we were to look at `$var` in the `gbk` character set, we'd see:
```
縗' OR 1=1 /*
```
Which is exactly what the attack requires.
4. **The Query**
This part is just a formality, but here's the rendered query:
```sql
SELECT * FROM test WHERE name = '縗' OR 1=1 /*' LIMIT 1
```
Congra... | [
-0.03235931694507599,
0.06810358911752701,
0.10827884823083878,
0.10842983424663544,
-0.06499294191598892,
-0.15502771735191345,
0.4374077022075653,
-0.46608421206474304,
-0.13942065834999084,
-0.27780643105506897,
-0.22036044299602509,
0.6855331659317017,
-0.4961533546447754,
0.0308433566... | |
be aware that PDO will silently [fallback](https://github.com/php/php-src/blob/master/ext/pdo_mysql/mysql_driver.c#L210) to emulating statements that MySQL can't prepare natively: those that it can are [listed](http://dev.mysql.com/doc/en/sql-syntax-prepared-statements.html) in the manual, but beware to select the appr... | [
-0.039193544536828995,
-0.000573020544834435,
0.5009267926216125,
-0.1453263908624649,
0.06009112671017647,
-0.06331463903188705,
0.2861591577529907,
0.015553644858300686,
-0.17396220564842224,
-0.639621913433075,
-0.2124902904033661,
0.6545647382736206,
-0.44440963864326477,
0.13388739526... | |
using a MySQL release since 2006. If you're using an earlier MySQL release, then a [bug](http://bugs.mysql.com/bug.php?id=8378) in `mysql_real_escape_string()` meant that invalid multibyte characters such as those in our payload were treated as single bytes for escaping purposes *even if the client had been correctly i... | [
-0.4283311069011688,
0.042930927127599716,
0.24344325065612793,
-0.04684443026781082,
-0.009008477441966534,
0.10423595458269119,
0.7144268155097961,
-0.10971929877996445,
-0.5180566310882568,
-0.4947620630264282,
-0.35739076137542725,
0.5448024272918701,
-0.7276622653007507,
0.19705708324... | |
so you could elect to use that instead—but it has only been available since MySQL 5.5.3. An alternative is [`utf8`](http://dev.mysql.com/doc/en/charset-unicode-utf8.html), which is also *not vulnerable* and can support the whole of the Unicode [Basic Multilingual Plane](http://en.wikipedia.org/wiki/Plane_(Unicode)#Basi... | [
-0.5405161380767822,
-0.03364856541156769,
0.35056930780410767,
-0.010161717422306538,
0.04654708132147789,
0.2055506706237793,
0.48422926664352417,
-0.19645144045352936,
-0.23868153989315033,
-0.5419676303863525,
-0.39894187450408936,
0.3448587656021118,
-0.29787012934684753,
0.0266134254... | |
invalid. However, see [@eggyal's answer](https://stackoverflow.com/a/23277864/623041) for a different vulnerability that can arise from using this SQL mode (albeit not with PDO).
Safe Examples
=============
The following examples are safe:
```
mysql_query('SET NAMES utf8');
$var = mysql_real_escape_string("\xbf\x27 ... | [
-0.05183300003409386,
0.22786210477352142,
0.1295222043991089,
0.030304094776511192,
0.08253050595521927,
0.005714579951018095,
0.5428785681724548,
-0.4489904046058655,
-0.13330453634262085,
-0.5201470851898193,
-0.3242647051811218,
0.46961501240730286,
-0.43015772104263306,
0.359008133411... | |
$password);
$stmt = $pdo->prepare('SELECT * FROM test WHERE name = ? LIMIT 1');
$stmt->execute(array("\xbf\x27 OR 1=1 /*"));
```
Because we've set the character set properly.
```
$mysqli->query('SET NAMES gbk');
$stmt = $mysqli->prepare('SELECT * FROM test WHERE name = ? LIMIT 1');
$param = "\xbf\x27 OR 1=1 /*";
$st... | [
-0.08750245720148087,
0.03127949312329292,
0.35049399733543396,
-0.007049559615552425,
-0.20016935467720032,
-0.04991096258163452,
0.7713333368301392,
-0.7058973908424377,
-0.29025477170944214,
-0.4269596338272095,
-0.6129444241523743,
0.4917457103729248,
-0.24331028759479523,
-0.074411101... | |
using PDO Prepared Statements...**
Addendum
========
I've been slowly working on a patch to change the default to not emulate prepares for a future version of PHP. The problem that I'm running into is that a LOT of tests break when I do that. One problem is that emulated prepares will only throw syntax errors on exec... | [
0.4842261075973511,
0.4037013053894043,
-0.13327424228191376,
-0.027464551851153374,
-0.03137458488345146,
-0.021376123651862144,
0.5885177850723267,
-0.12416917085647583,
0.2149314284324646,
-0.6929025650024414,
0.22560429573059082,
0.42752113938331604,
-0.2811462879180908,
-0.07056681811... | |
Can anyone recommend a good XML diff and merge tool?
I like [Oxygen](http://www.oxygenxml.com/xml_diff_and_merge.html). | [
0.3675878345966339,
-0.03509145602583885,
0.14703373610973358,
0.0688813254237175,
-0.16243422031402588,
-0.4122227430343628,
-0.11428847163915634,
0.21014219522476196,
0.18661713600158691,
-0.7312609553337097,
-0.09681505709886551,
0.31262245774269104,
-0.16345688700675964,
-0.32284945249... | |
Right now, I have code that looks something like this:
```
Private Sub ShowReport(ByVal reportName As String)
Select Case reportName
Case "Security"
Me.ShowSecurityReport()
Case "Configuration"
Me.ShowConfigurationReport()
Case "RoleUsers"
Me.ShowRoleUser... | [
0.262587308883667,
0.022375568747520447,
0.5860633254051208,
-0.01979161612689495,
0.1279568374156952,
-0.2923611104488373,
0.08962671458721161,
-0.1306198686361313,
-0.11952462792396545,
-0.6672883033752441,
-0.12807536125183105,
0.575840950012207,
-0.08996382355690002,
0.0745671764016151... | |
pnlMessage.Visible = True
litMessage.Text = "The report name """ + reportName + """ is invalid."
End Select
End Sub
```
Is there any way to create code that would use my method naming conventions to simplify things? Here's some pseudocode that describes what I'm looking for:
```
Private Sub ShowRepor... | [
-0.06029755249619484,
0.07860145717859268,
0.5549409985542297,
-0.13061198592185974,
0.1846158355474472,
-0.2070445865392685,
0.4757823944091797,
-0.3071337342262268,
-0.08006127178668976,
-0.337749183177948,
-0.35469135642051697,
0.38221320509910583,
-0.4580507278442383,
0.024254478514194... | |
End Try
End Sub
```
```
Type type = GetType();
MethodInfo method = type.GetMethod("Show"+reportName+"Report");
if (method != null)
{
method.Invoke(this, null);
}
```
This is C#, should be easy enough to turn it into VB. If you need to pass parameter into the method, they can be added in the 2nd argument to Invok... | [
0.07933400571346283,
-0.17914824187755585,
0.43171191215515137,
-0.4884342551231384,
0.15431731939315796,
-0.10459638386964798,
0.6092736721038818,
-0.39388787746429443,
0.2639913558959961,
-0.1960124969482422,
-0.3077653646469116,
0.39852848649024963,
-0.5100811123847961,
0.15461644530296... | |
This code produces a FileNotFoundException, but ultimately runs without issue:
```
void ReadXml()
{
XmlSerializer serializer = new XmlSerializer(typeof(MyClass));
//...
}
```
Here is the exception:
---
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional i... | [
0.0003501978353597224,
0.0349498949944973,
0.6033778190612793,
-0.20302286744117737,
-0.01617681048810482,
-0.27889782190322876,
0.45118027925491333,
-0.19294263422489166,
-0.27791449427604675,
-0.7171438336372375,
-0.21100933849811554,
0.5201144218444824,
-0.41957128047943115,
0.254366487... | |
setting doesn't appear to do anything.**
This is how I managed to do it by modifying the MSBUILD script in my .CSPROJ file:
First, open your .CSPROJ file as a file rather than as a project. Scroll to the bottom of the file until you find this commented out code, just before the close of the Project tag:
```
<!-- To ... | [
0.37780994176864624,
0.036994121968746185,
0.6009988784790039,
-0.1213599219918251,
-0.25336602330207825,
-0.14022906124591827,
0.09146632254123688,
-0.14282764494419098,
-0.04814598336815834,
-0.8915398716926575,
0.04827544838190079,
0.4471413791179657,
-0.3096303939819336,
0.018642665818... | |
so:
```
<Target Name="AfterBuild" DependsOnTargets="AssignTargetPaths;Compile;ResolveKeySource" Inputs="$(MSBuildAllProjects);@(IntermediateAssembly)" Outputs="$(OutputPath)$(_SGenDllName)">
<!-- Delete the file because I can't figure out how to force the SGen task. -->
<Delete
Files="$(TargetDir)$(TargetNa... | [
-0.0019612389151006937,
-0.3354603052139282,
0.5962206125259399,
-0.1495656818151474,
0.22661560773849487,
0.22565986216068268,
0.19105781614780426,
-0.6120187640190125,
-0.26817047595977783,
-0.6684170961380005,
-0.24602748453617096,
0.7257137894630432,
-0.06664694845676422,
0.05916260555... | |
TaskParameter="SerializationAssembly"
ItemName="SerializationAssembly" />
</SGen>
</Target>
```
That works for me. | [
-0.24722395837306976,
-0.5343949198722839,
0.4215051233768463,
0.10719641298055649,
-0.24085654318332672,
-0.01594158075749874,
0.10629785805940628,
0.16731293499469757,
-0.336539626121521,
-0.9113569259643555,
0.1344909518957138,
0.5335227847099304,
-0.04897524416446686,
-0.09747327119112... | |
After reading the answers to the question ["Calculate Code Metrics"](https://stackoverflow.com/questions/60394/calculate-code-metrics "Calculate Code Metrics") I installed the tool [SourceMonitor](http://www.campwoodsw.com/sm20.html "SourceMonitor") and calculated some metrics.
But I have no idea how to interpret them... | [
0.07761251926422119,
-0.13636457920074463,
-0.04622622951865196,
0.20867346227169037,
-0.2542248070240021,
-0.17413419485092163,
0.3901042342185974,
-0.16733187437057495,
-0.06162341311573982,
-0.47226354479789734,
0.2698363661766052,
0.5758597254753113,
0.22110988199710846,
-0.29938173294... | |
Method" is useful for a general feel of how big each method is. More useful to me is the info on the methods with too many statements (double click on the module for finer grain detail).
Function Complexity is useful for ascertaining how nasty the code is. Truly I use this info more than anything else. This is info on... | [
0.39383724331855774,
0.0962800532579422,
0.20495711266994476,
0.45553988218307495,
-0.31955552101135254,
-0.30986088514328003,
0.49135372042655945,
-0.28399187326431274,
-0.22915984690189362,
-0.5589460134506226,
0.15541492402553558,
0.643211305141449,
-0.35853081941604614,
0.2069417983293... | |
I've gone through just about every property I can think of, but haven't found a simple way to hide the header on a winform UltraCombo control from Infragistics.
Headers make sense when I have multiple visible columns and whatnot, but sometimes it would be nice to hide it.
To give a simple example, let's say I have a ... | [
0.4306725859642029,
-0.365500807762146,
0.2854127287864685,
0.14521071314811707,
0.0675404742360115,
-0.1280384063720703,
0.21355918049812317,
-0.09489437937736511,
-0.08330146223306656,
-0.6359974145889282,
-0.018241072073578835,
0.4894591271877289,
-0.22478525340557098,
0.110179133713245... | |
caption for the column is and then the choices. I'd like it to just show "Yes" and "No" only.
It's a minor aesthetic issue that probably just bothers me and isn't even noticed by the users, but I'd still really like to know if there's a way around this default behavior.
**RESOLUTION:** As @Craig suggested, *ColHeader... | [
0.18659456074237823,
-0.12436140328645706,
0.555306077003479,
-0.09126913547515869,
0.18668292462825775,
-0.11789841949939728,
0.1529371291399002,
-0.23679512739181519,
-0.2787570357322693,
-0.6297494173049927,
0.05137024074792862,
0.30160051584243774,
-0.18435420095920563,
0.0765616968274... | |
Does anyone have some numbers on this? I am just looking for a percentage, a summary will be better.
Standards compliance: How does the implementation stack up to the standard language specification?
For those still unclear: I place emphasis on **current**. The IronPython link provided below has info that was last ed... | [
0.4507521688938141,
0.2785594165325165,
0.06602966040372849,
-0.14296945929527283,
-0.44204482436180115,
-0.09626466780900955,
0.6065186858177185,
-0.2431890219449997,
-0.4218536913394928,
-0.45569998025894165,
-0.11165954917669296,
0.35106945037841797,
-0.01919543743133545,
-0.00406643375... | |
with Ruby and we're passing the core specs at a 71% rate (12026 / 16793 expectations for RubySpec core)." | [
0.3253035545349121,
-0.10589803010225296,
0.34162914752960205,
0.09839124232530594,
0.11474119126796722,
-0.03529931232333183,
0.7841693758964539,
0.044093646109104156,
-0.09769017994403839,
-0.33708301186561584,
-0.1420588195323944,
0.47248053550720215,
0.15763847529888153,
-0.10447116196... | |
I'm familiar with some of the basics, but what I would like to know more about is when and why error handling (including throwing exceptions) should be used in PHP, especially on a live site or web app. Is it something that can be overused and if so, what does overuse look like? Are there cases where it shouldn't be us... | [
0.5163189768791199,
0.4337485134601593,
-0.07427427917718887,
0.24096626043319702,
-0.05065031722187996,
-0.5463076233863831,
0.33067062497138977,
-0.012225753627717495,
-0.23808099329471588,
-0.38812878727912903,
0.40640562772750854,
0.46299076080322266,
-0.07094379514455795,
-0.281072676... | |
way, as Jeff "Coding Horror" Atwood suggests, you'll know when your users are experiencing trouble with your app (instead of "asking them what's wrong").
To do this, I recommend the following type of infrastructure:
* Create a "crash" table in your database and a set of wrapper classes for reporting errors. I'd rec... | [
0.404085248708725,
0.33559101819992065,
-0.30625712871551514,
0.4533481001853943,
0.07951634377241135,
-0.2605067491531372,
0.5017359256744385,
0.14661718904972076,
-0.3579406440258026,
-0.7057744264602661,
0.018959378823637962,
0.6182665824890137,
-0.2292167991399765,
-0.1757647842168808,... | |
done right.
Extra credit: sometimes, your crashes will be database-level crashes: i.e. DB server down, etc. If that's the case, your error logging infrastructure (above) will fail (you can't log the crash to the DB because the log tries to write to the DB). In that case, I would write failover logic in your Crash wrap... | [
0.3451853394508362,
0.4262637197971344,
0.15704847872257233,
0.33041566610336304,
0.20051585137844086,
-0.2893475890159607,
0.5046561360359192,
-0.08280075341463089,
-0.08616156876087189,
-0.39517101645469666,
-0.04412509873509407,
0.7702193856239319,
0.021763810887932777,
0.06367600709199... | |
That difference comes from the fact that all apps start as flaky/crashing all the time, but those developers that know about all issues with their app have a chance to actually fix it. | [
0.3549843728542328,
0.3055240213871002,
0.14384962618350983,
0.26553693413734436,
0.1955229789018631,
-0.221585214138031,
0.3556733727455139,
0.417880654335022,
-0.06636713445186615,
-0.2096049189567566,
-0.24328525364398956,
0.07100126892328262,
-0.1574302315711975,
-0.05804448574781418,
... | |
I have an game application I have written for Windows Mobile and I want to have a timer associated with the puzzle. If the program loses focus for any reason (call comes in, user switches programs, user hits the Windows button) then I want a pop up dialog box to cover the puzzle and the timer to stop. When the user clo... | [
0.30871230363845825,
0.2776341140270233,
0.3311316967010498,
-0.05275731906294823,
0.11227007955312729,
-0.21310067176818848,
0.23310840129852295,
-0.09759558737277985,
-0.41059765219688416,
-0.8044584393501282,
-0.012845407240092754,
0.32707449793815613,
-0.08375418186187744,
0.1130827516... | |
Every indication I have, based on my experience in embedded computing is that doing something like this would require expensive equipment to get access to the platform (ICE debuggers, JTAG probes, I2C programmers, etc, etc), but I've always wondered if some ambitious hacker out there has found a way to load native code... | [
0.47130289673805237,
0.05268039554357529,
-0.2070988267660141,
0.19411595165729523,
0.21902984380722046,
-0.2726798355579376,
0.47813957929611206,
0.40436646342277527,
-0.3328644633293152,
-0.19267059862613678,
0.008260301314294338,
0.22348842024803162,
-0.030128424987196922,
-0.2261730432... | |
Blackberries were programmable in C++ but I think that RIM ran up against the problems of trying to implement a secure platform in the C/C++ compile to native paradigm.
The devices do have JTAG ports, but unless one could get hands on the RIM code as a place to start the problem is enormous.
I also have to wonder h... | [
-0.05817608907818794,
-0.12431515008211136,
0.14030113816261292,
0.25302210450172424,
-0.24265111982822418,
0.43327364325523376,
0.09906996786594391,
0.0854199081659317,
0.0256374329328537,
-0.050185732543468475,
0.5292608141899109,
0.2580789029598236,
0.09456600248813629,
-0.1175465881824... | |
held computing platform I suspect there are many more likely candidates available. | [
0.2772560715675354,
-0.0630236491560936,
0.2743722200393677,
0.6116982698440552,
-0.11228764802217484,
0.0179396104067564,
-0.47667890787124634,
0.05059037730097771,
-0.31076866388320923,
-0.07090332359075546,
-0.11966697871685028,
0.19378280639648438,
0.2637025713920593,
0.113166697323322... | |
I have a JSP that allows users to dynamically create additional form fields to create multiple objects. Perhaps I want to allow users to be able to submit as many line items as they want when submitting an invoice form.
How do I create a Struts 2 Action that will be able to take in an `ArrayList` populated with object... | [
0.299466997385025,
-0.11257431656122208,
0.26624926924705505,
-0.11672450602054596,
-0.2688469886779785,
0.30181846022605896,
-0.0021469329949468374,
-0.3214396834373474,
-0.19435296952724457,
-0.1598830670118332,
0.31304290890693665,
0.35008740425109863,
-0.5117905735969543,
-0.3373289406... | |
secure platform in the C/C++ compile to native paradigm.
The devices do have JTAG ports, but unless one could get hands on the RIM code as a place to start the problem is enormous.
I also have to wonder how useful a Blackberry with a replacement FOSS operating system would be, since it would not likely have the pro... | [
-0.08954644203186035,
0.08638940006494522,
0.299349308013916,
0.4023568332195282,
0.2217208296060562,
-0.2943703532218933,
0.02263701520860195,
0.0488172248005867,
-0.07605022937059402,
-0.5869296789169312,
0.03422568738460541,
0.5919977426528931,
-0.07896120846271515,
-0.16492219269275665... | |
What do you think is a good IDE for learning SmallTalk? I'll only be using it as a hobby, so it has to be free.
I think [Squeak](http://www.squeak.org/) is the way to go. It has an entire smalltalk environment and is constantly updated. Its what I used for learning and is actually even a cool app in itself. | [
0.2026413232088089,
-0.17591975629329681,
-0.21056969463825226,
0.3857848346233368,
-0.022834546864032745,
-0.4336475729942322,
0.11579255014657974,
0.5429508686065674,
-0.34528306126594543,
-0.33264002203941345,
0.11515628546476364,
0.3686876595020294,
-0.05045872926712036,
0.097002401947... | |
This
```
SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE '%some_value%';
```
is slower than this
```
SELECT * FROM SOME_TABLE WHERE SOME_FIELD = 'some_value';
```
but what about this?
```
SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE 'some_value';
```
My testing indicates the second and third examples are exac... | [
0.17545193433761597,
0.02295888401567936,
-0.050033241510391235,
-0.0004927425761707127,
-0.2671334743499756,
-0.3799464702606201,
0.19213756918907166,
-0.3126780092716217,
0.05299216881394386,
-0.5171629786491394,
-0.14255204796791077,
0.5677558183670044,
-0.3106606602668762,
0.1200593858... | |
execution time, so it will make an estimation of the cardinality of the result based on heuristics and come up with an appropriate plan that either may or may not be suitable for various values of :b, such as '%A','%', 'A' etc.
Similar issues can apply with an equality predicate but the range of cardinalities that mig... | [
0.06061200797557831,
-0.13318248093128204,
0.2118370682001114,
0.12309490144252777,
-0.22926370799541473,
0.26469486951828003,
0.5919234156608582,
-0.07519389688968658,
0.04056822508573532,
-0.527188241481781,
0.10505098104476929,
0.5898532867431641,
-0.18177670240402222,
-0.21325117349624... | |
I have two controllers which share most of their code (but must be, nonetheless, different controllers). The obvious solution (to me, at least) is to create a class, and make the two controllers inherit from it. The thing is... where to put it? Now I have it in app\_controller.php, but it's kind of messy there.
In cake... | [
0.21760393679141998,
-0.2526213824748993,
0.4046914875507355,
0.15375593304634094,
0.0005870191962458193,
0.031600575894117355,
-0.3061639070510864,
-0.07727836817502975,
-0.10057134181261063,
-0.7197872996330261,
0.1416904777288437,
0.2820616066455841,
-0.39307722449302673,
0.286113321781... | |
{
function yourMethod($param) {
// logic here.......
return $param;
}
}
?>
```
Then, in your controller classes, you would add:
```
var $components = array('Util');
```
Then you call the methods like:
```
$this->Util->yourMethod($yourparam);
```
More Info:
[Documentation](http://book.c... | [
-0.010187214240431786,
-0.4652079939842224,
0.32321637868881226,
0.2970677614212036,
-0.1056864932179451,
0.08640029281377792,
-0.0712461769580841,
-0.5356343388557434,
-0.43838709592819214,
-0.4358859658241272,
-0.13366065919399261,
0.5413137674331665,
-0.39409375190734863,
-0.04180561751... | |
What I have now (which successfully loads the plug-in) is this:
```
Assembly myDLL = Assembly.LoadFrom("my.dll");
IMyClass myPluginObject = myDLL.CreateInstance("MyCorp.IMyClass") as IMyClass;
```
This only works for a class that has a constructor with no arguments. How do I pass in an argument to a constructor?
You... | [
0.04036392271518707,
0.03021971508860588,
0.4887632131576538,
0.007083026692271233,
-0.012750281020998955,
-0.13192622363567352,
0.11847234517335892,
-0.2553699016571045,
-0.07867569476366043,
-0.9523293972015381,
-0.02150440588593483,
0.4810801148414612,
-0.26011601090431213,
0.3602712750... | |
interface, instead of relying on constructors. That way you can just demand that the plugin class implement your interface, instead of "hoping" that it accepts the accepted parameters in the constructor.
```
using System;
using Host;
namespace Client
{
public class MyClass : IMyInterface
{
public int ... | [
-0.12154427170753479,
-0.15239442884922028,
0.4823165833950043,
-0.055532727390527725,
-0.16138461232185364,
0.16768179833889008,
0.32006484270095825,
-0.08082438260316849,
-0.04538436979055405,
-0.9282727241516113,
0.08835776895284653,
0.7139065861701965,
-0.7395439147949219,
0.3057489097... | |
_id = id;
_name = name;
}
public string GetOutput()
{
return String.Format("{0} - {1}", _id, _name);
}
}
}
namespace Host
{
public interface IMyInterface
{
string GetOutput(); | [
-0.20879550278186798,
-0.11717517673969269,
0.3931657671928406,
-0.1663610190153122,
-0.05937822535634041,
0.19681116938591003,
0.2958131730556488,
-0.07441361993551254,
0.1521357297897339,
-1.0039318799972534,
-0.24403423070907593,
0.697479784488678,
-0.6002041697502136,
0.381902277469635... | |
}
}
using System;
using System.Reflection;
namespace Host
{
internal class Program
{
private static void Main()
{
//These two would be read in some configuration
const string dllName = "Client.dll";
const string className = "Client.MyClass";
try | [
0.01824786514043808,
-0.33234652876853943,
0.28333768248558044,
-0.14377450942993164,
0.1533004641532898,
0.2623680830001831,
0.2748944163322449,
0.1341000646352768,
-0.22728319466114044,
-0.7001614570617676,
-0.04706447571516037,
0.5944473743438721,
-0.47336894273757935,
0.684268355369567... | |
{
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
Type classType = pluginAssembly.GetType(className);
var plugin = (IMyInterface) Activator.CreateInstance(classType, | [
-0.0018269605934619904,
-0.3433091342449188,
0.3298376798629761,
-0.2948342263698578,
0.11079695075750351,
0.31358787417411804,
0.49031832814216614,
-0.5483956336975098,
-0.06374552100896835,
-0.7064713835716248,
-0.2060956358909607,
0.4857644736766815,
-0.7585289478302002,
0.3270884454250... | |
42, "Adams");
if (plugin == null)
throw new ApplicationException("Plugin not correctly configured");
Console.WriteLine(plugin.GetOutput()); | [
-0.3412264883518219,
0.022518377751111984,
0.46309030055999756,
-0.40200135111808777,
0.6341448426246643,
0.2109287679195404,
0.5215285420417786,
-0.28489306569099426,
0.21299755573272705,
-0.7252268195152283,
-0.6812515258789062,
0.43958452343940735,
-0.40405014157295227,
0.18457147479057... | |
}
catch (Exception e)
{
Console.Error.WriteLine(e.ToString());
}
}
}
}
``` | [
0.010151216760277748,
-0.0724729597568512,
0.11506136506795883,
-0.20107443630695343,
0.3437156677246094,
-0.3176783323287964,
0.25500333309173584,
-0.1989630162715912,
0.033447131514549255,
-0.2602919340133667,
-0.3482397198677063,
0.5543116331100464,
-0.3752583861351013,
0.11623015254735... | |
Okay, this is just a crazy idea I have. Stack Overflow looks very structured and integrable into development applications. So would it be possible, even useful, to have a Stack Overflow plugin for, say, Eclipse?
Which features of Stack Overflow would you like to have directly integrated into your IDE so you can use i... | [
0.35208263993263245,
0.08785301446914673,
-0.20868034660816193,
0.19804474711418152,
-0.027932429686188698,
-0.32259973883628845,
-0.10740683972835541,
-0.08475064486265182,
-0.24049463868141174,
-0.4782255291938782,
0.1889430284500122,
0.511136531829834,
-0.48967498540878296,
-0.035097736... | |
where something like this is annoying, but others may be very helpful.
Following up on Josh's answer. This VS Macro will search StackOverflow for highlighted text in the Visual Studio IDE. Just highlight and press Alt+F1
```
Public Sub SearchStackOverflowForSelectedText()
Dim s As String = ActiveWindowSelection().... | [
-0.05460461974143982,
-0.2140188366174698,
0.7052786946296692,
-0.13728000223636627,
-0.15381701290607452,
-0.05733814463019371,
0.36903199553489685,
-0.42596229910850525,
-0.2754371166229248,
-0.6010125875473022,
-0.36445873975753784,
0.614104688167572,
-0.1751064509153366,
0.068320915102... | |
Return OutputWindowSelection()
End If
If DTE.ActiveWindow.ObjectKind = "{57312C73-6202-49E9-B1E1-40EA1A6DC1F6}" Then
Return HTMLEditorSelection()
End If
Return SelectionText(DTE.ActiveWindow.Selection)
End Function
Private Function HTMLEditorSelection() As String
Dim hw As HTMLWindow = Acti... | [
-0.30904871225357056,
-0.37426847219467163,
0.7991976141929626,
-0.1934904009103775,
-0.19407673180103302,
0.29801440238952637,
0.24269331991672516,
-0.26946771144866943,
-0.177222341299057,
-0.2884787917137146,
-0.5871303081512451,
0.6151542663574219,
-0.480665385723114,
0.271543979644775... | |
Function
Private Function SelectionText(ByVal sel As EnvDTE.TextSelection) As String
If sel Is Nothing Then
Return ""
End If
If sel.Text.Length = 0 Then
SelectWord(sel)
End If
If sel.Text.Length <= 2 Then
Return ""
End If
Return sel.Text
End Function
Private Sub Sel... | [
-0.4028365910053253,
-0.6861321330070496,
0.695026695728302,
-0.3982468247413635,
-0.2389863282442093,
0.13225215673446655,
0.16546782851219177,
-0.2601345181465149,
0.0665479376912117,
-0.2767176032066345,
-0.710249125957489,
0.43516284227371216,
-0.3405473828315735,
0.12172871828079224,
... | |
Dim pt As EnvDTE.EditPoint = sel.ActivePoint.CreateEditPoint()
sel.WordLeft(True, 1)
line = sel.TextRanges.Item(1).StartPoint.Line
leftPos = sel.TextRanges.Item(1).StartPoint.LineCharOffset
pt.MoveToLineAndOffset(line, leftPos)
sel.MoveToPoint(pt)
sel.WordRight(True, 1)
End Sub
```
To install... | [
0.35590970516204834,
-0.5077050924301147,
1.1546722650527954,
-0.06878355890512466,
0.13179127871990204,
0.04661019518971443,
0.3351464867591858,
-0.33418428897857666,
-0.11828117817640305,
-0.5340232253074646,
-0.31043368577957153,
0.6712377667427063,
-0.34099555015563965,
-0.001333748456... | |
the Show Commands Containing textbox. The SearchGoogleForSelectedText macro should show up
8. click in the Press Shortcut Keys textbox, then press ALT+F1
9. click the Assign button
10. click OK
This is all taken from Jeff Atwood's [Google Search VS Macro](https://blog.codinghorror.com/google-search-vsnet-macro/) post,... | [
0.23003797233104706,
-0.0275494996458292,
0.2464219033718109,
-0.08430614322423935,
-0.06443091481924057,
-0.08761182427406311,
0.14297838509082794,
-0.1057809442281723,
-0.1389254480600357,
-0.519163966178894,
-0.24382486939430237,
0.4374375641345978,
-0.6519419550895691,
-0.1088268831372... | |
It should be hands-on, complete, targeted to programmers and detailed on layout techniques!
Check out www.css-tricks.com. They have excellent screen casts.
Another place to check out is the various web design podcasts. Go to iTunes and search the podcasts and you will probably find a few to check out. | [
0.7072869539260864,
0.0636429488658905,
0.02329328842461109,
0.38516926765441895,
0.25977978110313416,
-0.3560127317905426,
0.23519544303417206,
0.4943757951259613,
-0.1881328523159027,
-0.6834384799003601,
0.15273790061473846,
0.6002056002616882,
0.30773869156837463,
-0.27550238370895386,... | |
**Summary:** C#/.NET is supposed to be garbage collected. C# has a destructor, used to clean resources. What happen when an object A is garbage collected the same line I try to clone one of its variable members? Apparently, on multiprocessors, sometimes, the garbage collector wins...
**The problem**
Today, on a train... | [
0.40206530690193176,
0.013596171513199806,
-0.1401003897190094,
0.1371033489704132,
-0.2623646557331085,
-0.1602754145860672,
0.41032978892326355,
0.1731654405593872,
-0.41573378443717957,
-0.460051566362381,
-0.0632108673453331,
0.541516900062561,
-0.3037489950656891,
0.1387760490179062,
... | |
2005 documentation, will be posted as an "answer" to avoid making a very very large questions, but the essential are below:
The following class has a "Hash" property which will return a cloned copy of an internal array. At is construction, the first item of the array has a value of 2. In the destructor, its value is s... | [
-0.20061327517032623,
0.21721114218235016,
0.1680629849433899,
-0.1202910766005516,
-0.1544075459241867,
-0.24224168062210083,
0.45942163467407227,
-0.14086709916591644,
-0.2415122240781784,
-0.42790862917900085,
-0.3415910601615906,
0.2656462490558624,
-0.23995165526866913,
0.407947301864... | |
Example
{
private int nValue;
public int N { get { return nValue; } }
// The Hash property is slower because it clones an array. When
// KeepAlive is not used, the finalizer sometimes runs before
// the Hash property value is read.
private byte[] hashValue;
public byte[] Hash { get { retu... | [
0.019525378942489624,
-0.20969031751155853,
0.02299370989203453,
-0.4808691143989563,
0.13422894477844238,
0.05157143622636795,
0.24763251841068268,
-0.4909348487854004,
-0.19139130413532257,
-0.5834939479827881,
-0.17633944749832153,
0.5058140158653259,
-0.4961944818496704,
0.140778928995... | |
hashValue = new byte[20];
hashValue[0] = 2;
}
~Example()
{
nValue = 0;
if (hashValue != null)
{
Array.Clear(hashValue, 0, hashValue.Length);
}
}
}
```
But nothing is so simple...
The code using this class is wokring inside a thread, and of | [
-0.12532110512256622,
-0.2511835992336273,
0.4046567976474762,
-0.3429434895515442,
0.021893775090575218,
-0.1602504998445511,
0.3904604911804199,
-0.2859214246273041,
-0.22180111706256866,
-0.5776636004447937,
-0.045988332480192184,
0.3979438841342926,
-0.3603787124156952,
0.4335957467556... | |
course, for the test, the app is heavily multithreaded:
```
public static void Main(string[] args)
{
Thread t = new Thread(new ThreadStart(ThreadProc));
t.Start();
t.Join();
}
private static void ThreadProc()
{
// running is a boolean which is always true until
// the user press ENTER
while (r... | [
0.20145650207996368,
0.23883472383022308,
0.4123450219631195,
-0.3135698437690735,
0.3570733666419983,
0.1033080443739891,
0.4549810290336609,
-0.22507423162460327,
-0.23661503195762634,
-0.28807127475738525,
-0.22719618678092957,
0.7757129073143005,
-0.4797666668891907,
0.3138670921325683... | |
call to the Hash
// property completes, the hashValue array might be
// cleared before the property value is read. The
// following test detects that.
if (res[0] != 2)
{
// Oops... The finalizer of ex was launched before
// the Hash method/property completed
}
}
```
Once eve... | [
0.06525194644927979,
0.07566386461257935,
0.5474257469177246,
-0.28720930218696594,
0.13705888390541077,
-0.19640271365642548,
0.40646272897720337,
-0.3880503177642822,
-0.22089004516601562,
-0.13777866959571838,
-0.17588268220424652,
0.7120261788368225,
-0.16919313371181488,
0.40726670622... | |
not anymore referenced in the remaning code of the function, and this time, it is faster than the "Hash" get method. So what we have in the end is a clone of a zero-ed byte array, instead of having the right one (with the 1st item at 2).
My guess is that there is inlining of the code, which essentially replaces the li... | [
0.4250645339488983,
-0.02729710564017296,
0.4945659041404724,
-0.003960207104682922,
0.1488378942012787,
-0.05330692604184151,
0.18848039209842682,
-0.08972682803869247,
-0.2709253430366516,
-0.31722965836524963,
0.13184186816215515,
0.4996103346347809,
-0.20842979848384857,
0.598184406757... | |
// but not res2
byte[] res = (byte[])res2.Clone();
```
If we supposed Hash2 is a simple accessor coded like:
```
// Hash2 code:
public byte[] Hash2 { get { return (byte[])hashValue; } }
```
So, the question is: **Is this supposed to work that way in C#/.NET, or could this be considered as a bug of either the c... | [
0.3324826657772064,
0.3619663715362549,
0.17046454548835754,
-0.07699083536863327,
-0.1781858205795288,
-0.1663694977760315,
0.31297680735588074,
-0.18754452466964722,
-0.4472610056400299,
-0.2532012462615967,
-0.0777529701590538,
0.6307994723320007,
-0.3078429698944092,
0.2235405445098877... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.