text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
I'm doing something like the following:
```
SELECT * FROM table WHERE user='$user';
$myrow = fetchRow() // previously I inserted a pass to the db using base64_encode ex: WRM2gt3R=
$somepass = base64_encode($_POST['password']);
if($myrow[1] != $somepass) echo 'error';
else echo 'welcome';
```
Im always getting erro... | [
0.37444254755973816,
0.26942870020866394,
0.23087646067142487,
-0.3066239655017853,
-0.19558557868003845,
-0.056572068482637405,
0.6751274466514587,
-0.44823965430259705,
-0.05079282447695732,
-0.6562078595161438,
-0.006924362853169441,
0.4216117858886719,
-0.20644620060920715,
0.211052507... | |
I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).
**Setup Info:** This is via a SELinux system hosted by WebFaction. It is behind Apache, and connections are over SSL.... | [
0.36936572194099426,
0.02105606719851494,
0.2851499915122986,
0.03817420080304146,
-0.2824144661426544,
-0.5964443683624268,
0.37815678119659424,
0.1656637191772461,
-0.2703703045845032,
-0.5828421115875244,
-0.10024163126945496,
0.7944117784500122,
-0.11185295879840851,
0.0634391158819198... | |
running in something like `mod_python`, which keeps the Python runtime in memory. Otherwise, every HTTP request will cause Python to run, import all the modules, and then finally handle the request. Using `mod_python` (or FastCGI, whichever you prefer) will eliminate that loading and skip straight to the good stuff.
A... | [
0.2920324206352234,
-0.21885916590690613,
0.28628066182136536,
0.10479280352592468,
-0.16005536913871765,
-0.2679841220378876,
0.38854438066482544,
0.2445652335882187,
-0.35359227657318115,
-0.610241174697876,
0.0020271255634725094,
0.5913211703300476,
-0.615932047367096,
0.089060410857200... | |
I have a file with fields separated by pipe characters and I want to print only the second field. This attempt fails:
```
$ cat file | awk -F| '{print $2}'
awk: syntax error near line 1
awk: bailing out near line 1
bash: {print $2}: command not found
```
Is there a way to do this?
The key point here is that the pipe... | [
0.2908512055873871,
0.05948938429355621,
0.19899576902389526,
-0.2799217700958252,
0.2433745414018631,
0.021675778552889824,
0.5686156153678894,
-0.2806517481803894,
0.10226970165967941,
-0.5756441950798035,
-0.10760568082332611,
0.5765788555145264,
-0.41266706585884094,
0.2032179683446884... | |
the original problem which involved filtering `file` before selecting and printing the fields. A pass through `grep` was used and the result piped into awk for field selection. That accounts for the wholly unnecessary `cat file` that appears in the question (it replaces the `grep <pattern> file`).
Fine, that will work... | [
0.059861693531274796,
-0.4227844774723053,
0.36692503094673157,
0.10757875442504883,
-0.29242774844169617,
0.15197253227233887,
0.22999069094657898,
-0.27924031019210815,
0.16478906571865082,
-0.5219032764434814,
-0.13125982880592346,
0.4188266396522522,
-0.5249251127243042,
-0.20223864912... | |
lost-looking `{next;}` is a default action skipping to the next line in the input. It does not seem to be necessary, but I have this habit from long ago... | [
0.09126156568527222,
-0.22782808542251587,
0.12883366644382477,
-0.008482635021209717,
0.29616624116897583,
-0.18088890612125397,
-0.04342072457075119,
0.689214825630188,
-0.4208819568157196,
-0.442837655544281,
-0.2989503741264343,
0.20480020344257355,
-0.2396830916404724,
0.3004038631916... | |
I have been asked to setup a course leaflet system for a college. For whatever reason in the past their current system is not linked to their actual course file, they wish to close this link so course leaflets are related to actual course codes. Unfortunately their course file is a ms access database linked to many of ... | [
0.8432795405387878,
0.42766109108924866,
0.18220770359039307,
0.29389968514442444,
0.2652551233768463,
-0.3180612027645111,
-0.17594978213310242,
0.1716655194759369,
-0.12243515998125076,
-0.3054485321044922,
0.14662767946720123,
-0.05891052260994911,
0.1604185849428177,
0.4303434193134308... | |
work out what courses they have without a leaflet, I would not like to add ad hoc queries to the access database to do this.
What is the best way to do this in C#, I think LINQ can do it but have not learnt it yet, should I learn it for this project or is there an easier way?
I thought about a linked server to the ms... | [
0.3944534659385681,
0.25679871439933777,
0.2668411433696747,
0.4282569885253906,
0.027180813252925873,
-0.3885040581226349,
0.1792353242635727,
0.2488355189561844,
-0.07967109978199005,
-0.4708463251590729,
0.1927943080663681,
0.4313044548034668,
0.14597788453102112,
-0.0635305866599083,
... | |
course file change? Fifty times a day? Once a month?
What about creating the appropriate tables in the SQL Server database? Then every so often (as often as necessary to stay reasonably current), clear those tables out and repopulate them from the Access database. You could set this to run every morning at 3 a.m. or w... | [
0.5196154117584229,
-0.08858343213796616,
0.6543676853179932,
0.17350666224956512,
0.43198612332344055,
0.02494693361222744,
-0.17306029796600342,
0.11388091742992401,
-0.49308091402053833,
-0.37493574619293213,
0.11537573486566544,
0.4245399236679077,
0.06212999299168587,
0.12191314250230... | |
Does anyone know how to initiate a POST request in a Grails applications using javascript. Specifically, I would like to be able to POST when a the selected item in a drop-down box is changed.
I've tried using jQuery and the $.post() method. It successfully calls my controller action, but I'm not sure how to get the p... | [
0.3398090600967407,
0.023206036537885666,
0.2317586988210678,
0.04009959474205971,
-0.23668299615383148,
-0.2155168205499649,
0.3082807958126068,
0.05742010101675987,
-0.2436559647321701,
-0.7369449138641357,
-0.09863296896219254,
0.25679299235343933,
-0.1665966510772705,
0.117662236094474... | |
$(document).ready( function() {
$("#ownerId").change(function() {
$.post("/holidayCards/clientContact/ownerSelected", {ownerId: this.value});
});
});
```
Find the form object in the DOM you are looking for and cal .submit() on it. Do you have more than one form or multiples on your page? | [
0.47943738102912903,
-0.00016606329882051796,
0.8699206113815308,
-0.1979658156633377,
0.34261977672576904,
-0.2069760113954544,
0.2424132376909256,
-0.1960115134716034,
-0.22373495995998383,
-0.48200544714927673,
-0.3623312711715698,
0.3765343725681305,
-0.19696591794490814,
0.13683654367... | |
I recently ran into a problem that I thought boost::lambda or boost::phoenix could help be solve, but I was not able to get the syntax right and so I did it another way. What I wanted to do was remove all the elements in "strings" that were less than a certain length and not in another container.
This is my first try:... | [
-0.03768865391612053,
-0.22483360767364502,
0.39120492339134216,
-0.24247825145721436,
0.05634051933884621,
0.0073149739764630795,
0.46027302742004395,
-0.5570187568664551,
-0.4373041093349457,
-0.3615456819534302,
-0.12309122830629349,
0.5333325266838074,
-0.6585584282875061,
-0.046857502... | |
return cont.find(s) == cont.end() && s.length() < 24;
}
};
lines.erase(std::remove_if( lines.begin(), lines.end(), boost::bind<bool>(Discard(), old_samples, _1)), lines.end());
```
You need boost::labmda::bind to lambda-ify function calls, for example the length < 24 part becomes:
```
bind(&string::length, _1) <... | [
-0.09281239658594131,
-0.1500144898891449,
0.7465729117393494,
-0.22983703017234802,
0.1912466585636139,
-0.03517552465200424,
0.336498498916626,
-0.41186007857322693,
0.058980029076337814,
-0.5089908242225647,
-0.37202420830726624,
0.6552736759185791,
-0.40556037425994873,
0.0387278348207... | |
strings.erase(
remove_if(strings.begin(), strings.end(),
bind(&string::length, _1) < 24 &&
bind(findFn, boost::ref(others), _1) == others.end()
), strings.end());
copy(strings.begin(), strings.end(), ostream_iterator<string>(cout, ", "));
return 0;
}
``` | [
0.06357500702142715,
0.04875735566020012,
0.5278047919273376,
-0.40818560123443604,
0.5342100262641907,
0.13180828094482422,
0.35641753673553467,
-0.22080126404762268,
-0.1696152240037918,
-0.4989038407802582,
-0.3642517328262329,
0.6844801902770996,
-0.5074307322502136,
0.2897643446922302... | |
I really like Entity Framework, but there are some key pieces that are a challenge to me. Can anyone tell me how to filter an EntityDataSource on an Association column? EF hides the FK values and instead has an Association property. Given an Entity, Person, with a PersonType association, I would have expected something... | [
0.07747277617454529,
0.007081577088683844,
-0.1452806293964386,
-0.0678572878241539,
-0.21694397926330566,
-0.29146265983581543,
0.2570993900299072,
-0.1841534972190857,
-0.0649058148264885,
-0.5232769250869751,
0.13098250329494476,
0.37171801924705505,
-0.4474983811378479,
0.2270464301109... | |
method, such as:
```
entities.it.Include("PersonType").Where(a => a.PersonType.PersonTypeID = '1');
``` | [
0.10717886686325073,
-0.005738008301705122,
-0.3738779127597809,
0.04795466363430023,
0.06888647377490997,
-0.19209323823451996,
0.35791918635368347,
-0.26644134521484375,
0.12002772092819214,
-0.3596540689468384,
-0.2749427258968353,
0.29903092980384827,
-0.49135681986808777,
0.1668928563... | |
I was wondering if there is some way to name or rename a property on an Anonymous type to include a space in the property name. For example:
```
var resultSet = from customer in customerList
select new
{
FirstName = customer.firstName;
};
```
In this example I would like FirstName to be "First Na... | [
0.020090829581022263,
0.041934315115213394,
0.1967889666557312,
-0.07390616089105606,
0.2809648811817169,
-0.29269587993621826,
-0.18321160972118378,
-0.07174023240804672,
-0.1879071742296219,
-0.7473037838935852,
-0.12059750407934189,
0.35343053936958313,
-0.042886991053819656,
0.59642684... | |
one little shortcoming of the column names being a little less than user friendly (FirstName instead of First Name).
What about doing something like this:
```
var resultSet = from customer in customerList
select new
{
Value = customer.firstName, | [
0.06359908729791641,
-0.15820226073265076,
0.4147244989871979,
-0.09472392499446869,
0.014443249441683292,
-0.15391524136066437,
0.016644561663269997,
-0.20741991698741913,
-0.27199095487594604,
-0.5563673377037048,
-0.04504934325814247,
0.4758414030075073,
-0.07940758764743805,
0.33280372... | |
Title = "First Name"
};
```
Then in your user control use Value as the contents and Title as the column name. | [
-0.324990838766098,
0.33771756291389465,
0.38397416472435,
-0.1401088535785675,
-0.035617128014564514,
-0.20811638236045837,
-0.2474469542503357,
0.10726717114448547,
0.06248776987195015,
-0.4407661557197571,
-0.34294652938842773,
0.4317973256111145,
-0.18955108523368835,
0.573619246482849... | |
I just read the Wikipedia article on [mock objects](http://en.wikipedia.org/wiki/Mock_object), but I'm still not entirely clear on their purpose. It appears they are objects that are created by a test framework when the actual object would be too complex or unpredictable (you know 100% sure what the values of the mock ... | [
0.4653795659542084,
0.3520508110523224,
-0.21073944866657257,
0.3385755121707916,
-0.02898712456226349,
0.060129158198833466,
0.3862658143043518,
0.1291591376066208,
-0.24660877883434296,
-0.24200750887393951,
0.03924506902694702,
0.2938143312931061,
0.09756949543952942,
-0.064299352467060... | |
knew exactly what they were so we could test the interactions between multiple event objects, various subsystems, and the user interface. I'm guessing these are mock objects, but I don't know why you wouldn't do this because without the objects of known values, you can't test a system.
A mock object is not just an obje... | [
0.5885101556777954,
0.3760679364204407,
-0.005963101051747799,
0.6104511022567749,
-0.18238188326358795,
0.10543136298656464,
0.3946119546890259,
0.03851277008652687,
-0.1511668860912323,
-0.3509920537471771,
0.2987407445907593,
0.3476742208003998,
-0.32558467984199524,
0.2870398759841919,... | |
you to create these objects on the fly and in essence allow you to say something like: Make me an object with a method foo that takes an int and returns a bool. When I pass 0, it should return true. Then you can test the code that uses foo(), to make sure it reacts appropriately.
Martin Fowler has a great article on m... | [
0.8019798398017883,
0.50893235206604,
0.3499285876750946,
-0.09780748188495636,
-0.19735263288021088,
0.3437041938304901,
0.6542596817016602,
-0.08947569876909256,
-0.15990063548088074,
-0.2798805832862854,
0.42943722009658813,
0.6305521130561829,
-0.5812433362007141,
0.3117876648902893,
... | |
I'm just trying to get a general idea of what views are used for in RDBMSes. That is to say, I know what a view is and how to make one. I also know what I've used them for in the past.
But I want to make sure I have a thorough understanding of what a view is useful for and what a view shouldn't be useful for. More spe... | [
0.46535050868988037,
0.23154912889003754,
-0.1501631736755371,
0.1528077870607376,
-0.17374147474765778,
-0.013775494880974293,
-0.03850381821393967,
-0.021551989018917084,
-0.1419091373682022,
-0.4421037435531616,
0.1037624403834343,
0.6026729345321655,
-0.3619042634963989,
-0.12016411870... | |
lieu of something like a table-valued function or vice versa?
4. Are there any circumstances that a view might be useful that aren't apparent at first glance?
(And for the record, some of these questions are intentionally naive. This is partly a concept check.)
*1) What is a view useful for?*
> **IOPO** In One Place... | [
0.20837059617042542,
0.006235014647245407,
0.2648404836654663,
0.1737906038761139,
-0.07298755645751953,
0.07576733082532883,
0.09876463562250137,
-0.1269533783197403,
-0.011425865814089775,
-0.4968331754207611,
-0.17600469291210175,
0.7432091236114502,
-0.06496022641658783,
-0.43786746263... | |
handcuffing referencing physical dependencies). In fact, I think it's *good practice*1 to offer only abstracted access to your underlying data (using views & table-valued functions), including views such as
>
> `CREATE VIEW AS
> SELECT * FROM tblData`
>
> 1I hafta admit there's a good deal of "Do as... | [
0.12093152850866318,
-0.17998576164245605,
0.4904746413230896,
0.07104571163654327,
-0.16643299162387848,
-0.10119074583053589,
0.17848189175128937,
-0.382028728723526,
-0.10793963074684143,
-0.5891261696815491,
0.12851040065288544,
0.7563673853874207,
-0.03994403034448624,
-0.137087732553... | |
concern (e.g. SQL 2000). I'm no expert, but I haven't worried about it in a while. (Nor can I think of where I'm presently using view joins.)
>
> Another situation where a view might be overkill is when the view is only referenced from one calling location and a derived table could be used instead. Just like an an... | [
0.15773780643939972,
0.16338792443275452,
0.35287538170814514,
-0.06230911612510681,
-0.10294083505868912,
-0.19278044998645782,
0.07739342004060745,
-0.1251242607831955,
-0.47261500358581543,
-0.6382175087928772,
0.27999162673950195,
0.5367699861526489,
-0.43600767850875854,
0.13262842595... | |
view in lieu of something like a table-valued function or vice versa?*
> (Aside from performance reasons) A table-valued function is functionally equivalent to a parameterized view. In fact, a common simple table-valued function use case is simply to add a WHERE clause filter to an already existing view in a single o... | [
0.03230447322130203,
0.18097954988479614,
0.2930886149406433,
0.1856352835893631,
-0.35802996158599854,
0.09053540229797363,
0.13520635664463043,
0.012836402282118797,
-0.2261824905872345,
-0.43424925208091736,
-0.3078966438770294,
0.6085461378097534,
-0.23454433679580688,
-0.3027866780757... | |
I'm working on a table of links within a site using iframes. I'm wondering if there's any way to code a link to go to two simultaneous destinations within two different target frames? I've been reading all afternoon and can't find anything close to what I want to do. Basically I want one link to present a photo in one ... | [
0.6132528781890869,
0.22861239314079285,
0.2803690731525421,
0.0050671580247581005,
-0.10341526567935944,
-0.053378138691186905,
0.10070536285638809,
0.15175099670886993,
-0.2975977957248688,
-0.8006830215454102,
0.18153385818004608,
0.11363184452056885,
-0.5027859210968018,
0.158796042203... | |
document.getElementById('iframe1').src = "page.ext?id=" + id;
document.getElementById('iframe2').src = "other_page.ext?id=" + id;
}
```
But of course, you probably shouldn't be using iframes anyways... | [
-0.1843036562204361,
0.3704273998737335,
0.5312743186950684,
-0.3000088334083557,
0.1208263412117958,
-0.17188136279582977,
0.25635820627212524,
-0.08608303964138031,
-0.36064285039901733,
-0.7808060050010681,
-0.24274738132953644,
0.1107487827539444,
-0.3984040319919586,
0.161960154771804... | |
I'm starting to develop a web application in PHP that I hope will become incredibly popular and make me famous and rich. :-)
If that time comes, my decision whether to parse the API's data as XML with SimpleXML or to use json\_decode could make a difference in the app's scalability.
Does anyone know which of these ap... | [
0.5076555013656616,
0.2453388124704361,
0.41533413529396057,
0.08439133316278458,
-0.11424582451581955,
-0.08959294110536575,
0.2914501130580902,
0.19081899523735046,
-0.29767894744873047,
-0.7129240036010742,
0.09135671705007553,
0.4865167438983917,
-0.16501249372959137,
-0.06977120041847... | |
conclusion is that I will go with SimpleXML for the time being because of its support for XPath expressions.
```
<?php
$xml = file_get_contents('sample.xml');
$json = file_get_contents('sample.js');
$iters = 1000;
// simplexml_load_string
$start_xml = microtime(true);
for ($i = 0; $i < $iters; ++$i) {
$obj = s... | [
-0.339957594871521,
-0.06680383533239365,
0.9096255302429199,
-0.263040155172348,
-0.07741492986679077,
0.1041521206498146,
0.13355104625225067,
-0.4431179463863373,
-0.2237403243780136,
-0.573769211769104,
-0.42072683572769165,
0.41268226504325867,
-0.11343691498041153,
-0.117557600140571... | |
the biggest performance issue you find yourself dealing with as your site grows in popularity. Use whichever format you're more comfortable with.
Alternatively, if you know how you'll be structuring your data, you could try making an XML-formatted version and a JSON-formatted version and just run it against your setu... | [
0.38254573941230774,
-0.0567244254052639,
-0.0005986956530250609,
0.43449634313583374,
-0.21821404993534088,
-0.31767919659614563,
0.025091592222452164,
0.2185882031917572,
-0.26134616136550903,
-0.6852914690971375,
-0.24296404421329498,
0.6788385510444641,
0.10175422579050064,
-0.13152155... | |
In Perl, I can type:
```
$|++;
```
and anything printed to STDOUT will be automatically fflush()ed.
Is there an equivalent in C? In other words, is there some way I can tell stdio to automatically fflush stdout after every printf(), the way it automatically flushes stderr?
Try `setvbuf(stdout, NULL, _IONBF, 0)`. It... | [
0.12114861607551575,
-0.0629754513502121,
0.6022635698318481,
-0.2915484607219696,
-0.33608943223953247,
-0.031162288039922714,
0.23808234930038452,
-0.15083791315555573,
-0.09710700064897537,
-0.4149712920188904,
-0.25749072432518005,
0.8356440663337708,
-0.5231525301933289,
-0.1334529519... | |
In C# is there any real difference (other than syntax) under the hood between:
```
myButton.Click += new EventHandler(myMemberMethod);
```
and
```
myButton.Click += myMemberMethod;
```
?
The second method is a shortcut to the first one, it was introduced in C# 2.0
See also [this thread](https://stackoverflow.com... | [
0.1575641930103302,
-0.22096745669841766,
0.3771459758281708,
-0.12550245225429535,
-0.08233622461557388,
-0.3054560124874115,
-0.10590516775846481,
-0.1595933586359024,
-0.4120419919490814,
-0.22407004237174988,
-0.17558737099170685,
0.7120689749717712,
-0.5165432691574097,
-0.10245913267... | |
Does anyone know the bare minimum files required for Ext JS 2.2? I know the ExtJS site has a feature to ["build"](http://extjs.com/products/extjs/build/) a small version of ExtJS (ext.js) as a replacement for ext-all.js but that's for minimizing the size of ExtJS on the client. I'm interested in minimizing what's on th... | [
0.380362868309021,
-0.016447046771645546,
0.31874099373817444,
0.023947101086378098,
-0.23699556291103363,
-0.22489841282367706,
0.28553709387779236,
-0.20639032125473022,
0.01714150235056877,
-0.8584024906158447,
-0.285576730966568,
0.7384207844734192,
-0.47223716974258423,
-0.24833148717... | |
link explains the include order
[What is the proper include order for my JavaScript files?](http://extjs.com/learn/Ext_Getting_Started#What_is_the_proper_include_order_for_my_JavaScript_files.3F)
This is the minimum include set
```
<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css">
<scr... | [
0.0995582789182663,
0.21671608090400696,
0.5002524256706238,
-0.2318258136510849,
-0.037892475724220276,
-0.30884018540382385,
0.24991567432880402,
-0.538323700428009,
-0.03809018060564995,
-0.6165462136268616,
-0.31201663613319397,
0.573802649974823,
-0.3488513231277466,
-0.09806372970342... | |
What is the most efficient way to do this?
Real answer: Depends on what kind of hexadecimal color value you are looking for (e.g. 565, 555, 888, 8888, etc), the amount of alpha bits, the actual color distribution (rgb vs bgr...) and a ton of other variables.
Here's a generic algorithm for most RGB values using C++ tem... | [
-0.22459682822227478,
0.1721363216638565,
0.37393373250961304,
0.07630079984664917,
-0.01046258956193924,
0.4252811074256897,
0.05886787921190262,
-0.7649527788162231,
-0.2390674203634262,
-0.5042272806167603,
-0.32715654373168945,
0.3420912027359009,
-0.49660494923591614,
0.06642419099807... | |
|
(((b << T::kBlueShift) >> (8 - T::kBlueBits)) & T::kBlueMask);
}
```
Here's a sample color struct for 565 (the standard format for 16 bit colors):
```
template<>
struct ColorMasks<565> {
enum {
highBits = 0xF7DEF7DE,
lowBits = 0x08210821,
qhighBits = 0xE79CE79C,
qlowBits = 0x1863... | [
0.09714523702859879,
-0.10152212530374527,
0.33849477767944336,
-0.06836140155792236,
0.2158353477716446,
0.3966599404811859,
0.04496890306472778,
-0.5437964797019958,
-0.2233211249113083,
-0.40395358204841614,
-0.4323776066303253,
0.3836963176727295,
-0.08835738152265549,
0.20298115909099... | |
kBlueBits = 5,
kAlphaShift = kRedBits+kGreenBits+kBlueBits,
kRedShift = kGreenBits+kBlueBits,
kGreenShift = kBlueBits,
kBlueShift = 0,
kAlphaMask = ((1 << kAlphaBits) - 1) << kAlphaShift,
kRedMask = ((1 << kRedBits) - 1) << kRedShift,
kGreenMask = ((1 << kGreenBits) - 1) << kGreenSh... | [
-0.38541147112846375,
0.14654281735420227,
0.3359794318675995,
-0.09525441378355026,
-0.1446651816368103,
0.6342008113861084,
-0.12269493192434311,
-0.33679717779159546,
-0.38247501850128174,
-0.08733528852462769,
-0.8075684905052185,
0.017462678253650665,
-0.33128929138183594,
0.213693752... | |
Just out of curiosity, is there a name for the kind of navigation I've been working on?
It looks like this:
`<<first <previous 1 2 3 4 5 [...] 20 next> last>>`
i.e. navigation where you've got *x* pages, but you don't want to show *x* links, you want to limit the amount of space taken up, so you show *y* links at a ... | [
-0.014812178909778595,
0.15947797894477844,
0.7617744207382202,
0.3111080229282379,
-0.14439240097999573,
0.04474176838994026,
-0.18975967168807983,
-0.01110135205090046,
-0.2770588994026184,
-0.649988055229187,
-0.1537921279668808,
0.15181218087673187,
-0.29576367139816284,
0.027023337781... | |
clear up this question. I hereby declare that it has no official name.
I also hereby make up the name 'elided pagination' for it. | [
0.3328310251235962,
0.29397591948509216,
0.10698667913675308,
0.22443753480911255,
0.1065690666437149,
-0.14878849685192108,
0.062186259776353836,
0.639868438243866,
0.15680816769599915,
-0.21814005076885223,
-0.05381280183792114,
0.05970583111047745,
-0.039138514548540115,
0.2859710156917... | |
The following Perl statements behave identically on Unixish machines. Do they behave differently on Windows? If yes, is it because of the magic \n?
```
split m/\015\012/ms, $http_msg;
split m/\015\012/s, $http_msg;
```
I got a [failure](http://www.nntp.perl.org/group/perl.cpan.testers/2008/10/msg2450019.html) on... | [
-0.11001340299844742,
0.306194007396698,
0.4137876629829407,
-0.14809295535087585,
-0.10498046875,
0.2548655867576599,
0.4028659164905548,
-0.11506681144237518,
-0.24726325273513794,
-0.08729153126478195,
0.05377284809947014,
0.6328322887420654,
-0.26942363381385803,
0.25413233041763306,
... | |
the string.
Your regex contains no `^` nor `$`, or their synonyms.
What is possible is indeed if your input handle (socket?) works in text mode, the `\r` (`\015`) characters will have been deleted on Windows.
So, what to do? I suggest making the `\015` characters optional, and split against
```
/\015?\012/
```
No... | [
0.23912878334522247,
0.014863786287605762,
0.25597506761550903,
0.15134644508361816,
0.16080977022647858,
0.03629562258720398,
0.18837597966194153,
0.6126531362533569,
-0.17965038120746613,
-0.6064113974571228,
-0.2556856572628021,
0.9037949442863464,
-0.11749216914176941,
0.24906845390796... | |
On the Python side, I can create new numpy record arrays as follows:
```
numpy.zeros((3,), dtype=[('a', 'i4'), ('b', 'U5')])
```
How do I do the same from a C program? I suppose I have to call `PyArray_SimpleNewFromDescr(nd, dims, descr)`, but how do I construct a `PyArray_Descr` that is appropriate for passing as t... | [
0.21594934165477753,
-0.043098241090774536,
0.30068692564964294,
-0.4108692407608032,
-0.2559344470500946,
0.32318130135536194,
0.21362319588661194,
-0.6588817834854126,
-0.21197426319122314,
-0.28960803151130676,
-0.23353524506092072,
0.7097708582878113,
-0.45145824551582336,
0.1091283634... | |
op = Py_BuildValue("[(s, s), (s, s)]", "a", "i4", "b", "U5");
PyArray_DescrConverter(op, &descr);
Py_DECREF(op);
array = PyArray_SimpleNewFromDescr(2, dims, descr);
PyObject_Print(array, stdout, 0);
printf("\n");
Py_DECREF(array);
return 0;
}
```
Thanks to [Adam Rosenfield](https://... | [
-0.07721211761236191,
0.27913492918014526,
0.4001041054725647,
-0.0805889219045639,
0.13371293246746063,
0.5980280041694641,
0.31969791650772095,
-0.5239264369010925,
-0.49661996960639954,
-0.3599575459957123,
-0.5196051001548767,
0.5028541088104248,
-0.43841081857681274,
-0.03256706893444... | |
When I enable common control visual style support (InitCommonControls()) and I am using any theme other then Windows Classic Theme, buttons inside a group box appear with a black border with square corners.
Windows Classic Theme appears normal, as well as when I turn off visual styling.
I am using the following code... | [
-0.02958592027425766,
0.2939480245113373,
0.8468631505966187,
-0.28417152166366577,
0.18185482919216156,
0.2754538059234619,
0.1535932719707489,
-0.3987799286842346,
-0.027892347425222397,
-0.7449526190757751,
-0.413551926612854,
0.33518555760383606,
-0.3636002242565155,
0.2389816641807556... | |
group_box, NULL, hInstance, 0);
```
EDIT: The issue occurs with radio buttons as well
EDIT: I am not using any dialogs/resources, only CreateWindow/Ex.
I am compiling under Visual C++ 2008 Express SP1, with a generic [manifest](http://msdn.microsoft.com/en-us/library/ms997646.aspx) file
[Screenshot http://img.isp... | [
-0.09291940182447433,
0.1118907704949379,
0.17428208887577057,
-0.1517159789800644,
-0.08176610618829727,
0.18771278858184814,
-0.16749799251556396,
-0.5044112801551819,
-0.12916769087314606,
-0.41919559240341187,
-0.016852645203471184,
0.035455457866191864,
-0.5003980994224548,
0.22180318... | |
other controls easily inside it. The proper way to do this is to get the position of the groupbox client area and map it to the client area of the dialog. Everything placed in the resulting RECT will then appear inside the groupbox. Since groupboxes don't actually have a client area, it can be calculated with something... | [
-0.09490469843149185,
-0.3309515118598938,
0.6151834726333618,
0.019215235486626625,
0.12647123634815216,
0.027774998918175697,
0.02270963229238987,
-0.5790876150131226,
-0.011529249139130116,
-0.6289920806884766,
-0.1690177470445633,
0.38386815786361694,
-0.3488776385784149,
-0.3014684617... | |
HWND group = GetDlgItem(dlg, id);
RECT rc;
GetWindowRect(group, &rc);
MapWindowPoints(0, dlg, (POINT*)&rc, 2);
// Note that the top DUs should be 9 to completely avoid overlapping the
// groupbox label, but 8 is used instead for better alignment on a 4x4
// design grid.
RECT border = { 4, 8... | [
-0.184369757771492,
-0.4132204055786133,
1.043623924255371,
-0.01580146886408329,
-0.2505407929420471,
0.09572112560272217,
-0.06703667342662811,
-0.7408135533332825,
-0.2454519122838974,
-0.704986035823822,
-0.2992098927497864,
0.12782518565654755,
-0.37489888072013855,
0.0342642664909362... | |
rc.top += border.top;
rc.bottom -= border.bottom;
return rc;
}
```
Note that the same applies to Tab controls. They too are not designed to be parents and will exhibit similar behavior. | [
0.1620907038450241,
0.07881444692611694,
0.32816943526268005,
-0.04015224426984787,
0.30129748582839966,
-0.12801724672317505,
-0.08831298351287842,
-0.1353113055229187,
-0.18809980154037476,
-0.4113728702068329,
-0.12310973554849625,
0.5223775506019592,
-0.3962766230106354,
0.481315225362... | |
Is there a good way to add a .swf programatically to a panel on an asp.net page - ie: I know i could just insert the html tags:
ie:
```
<object type="application/x-shockwave-flash" data="yourflash.swf" width="" height="">
<param name="movie" value="yourflash.swf">
</object>
```
But is there an existing .net or fre... | [
0.1843220293521881,
0.08470495790243149,
0.21810971200466156,
0.20719362795352936,
-0.16727055609226227,
-0.1449262946844101,
-0.13405205309391022,
-0.15137901902198792,
-0.18384648859500885,
-0.3774608075618744,
-0.02935870550572872,
0.20236006379127502,
-0.17655909061431885,
0.1875607520... | |
of errors (including painting, keyboard navigation and message propagation). Just change the parent in the buttons' CreateWindow call from **group\_box** to **hwnd** (i.e. the dialog).
I'm guessing you used the groupbox as the parent in order to position the other controls easily inside it. The proper way to do this i... | [
-0.05428335443139076,
-0.038485243916511536,
0.48366808891296387,
-0.13330106437206268,
0.032223884016275406,
0.13186660408973694,
0.1537495106458664,
-0.3438336253166199,
-0.04428168758749962,
-0.6545349359512329,
-0.039427466690540314,
0.3762997090816498,
-0.34746959805488586,
-0.1800775... | |
area of a dialog that corresponds to the perceived
// client area of a groupbox control. An extra padding in dialog units can
// be specified (preferably in multiples of 4).
//
RECT getClientAreaInGroupBox(HWND dlg, int id, int padding = 0) {
HWND group = GetDlgItem(dlg, id);
RECT rc;
GetWindowRect(group, &... | [
-0.09077966958284378,
-0.40631207823753357,
0.7766046524047852,
-0.14258331060409546,
-0.09785684943199158,
0.2484331578016281,
0.10091225802898407,
-0.5941307544708252,
-0.1713467240333557,
-0.6234632730484009,
-0.31013432145118713,
0.18921217322349548,
-0.4014127254486084,
-0.21860378980... | |
// design grid.
RECT border = { 4, 8, 4, 4 };
OffsetRect(&border, padding, padding);
MapDialogRect(dlg, &border);
rc.left += border.left;
rc.right -= border.right;
rc.top += border.top;
rc.bottom -= border.bottom;
return rc;
}
```
Note that the same applies to Tab controls. They too a... | [
0.015705639496445656,
-0.30979666113853455,
0.6222116947174072,
0.0011358368210494518,
0.21477697789669037,
0.15985360741615295,
-0.11070233583450317,
-0.36447229981422424,
-0.09462133049964905,
-0.8091762661933899,
-0.19693797826766968,
0.4466383457183838,
-0.2315165102481842,
0.193778723... | |
I am attempting to load an activex object on the same page where my flex application resides. Is this possible? Can I have 2 object tags on one page?
As of right now the flex application loads fine but when I attempt to access the activeX control it says its null. But if I have the same activex control on its own webp... | [
0.5105899572372437,
-0.047905098646879196,
0.12386304885149002,
0.1887279450893402,
-0.10791783779859543,
-0.08464188873767853,
0.29445579648017883,
0.2157164216041565,
-0.3530372083187103,
-0.8250877857208252,
0.21489812433719635,
0.4560921788215637,
-0.478618860244751,
0.2416262477636337... | |
still referencing the old name of the ActiveX object. The other error was I had a Var with the same name of the ActiveX object inside the javascript code, that seemed to be causing it to fail, although I am not entirely sure why. Once I removed that variable the script worked fine. I had run into that same problem the ... | [
0.1623270958662033,
-0.06313816457986832,
0.12356934696435928,
-0.11661766469478607,
-0.31348732113838196,
0.19057783484458923,
0.6994931101799011,
0.09348659962415695,
-0.05637234076857567,
-0.552351713180542,
0.34733036160469055,
0.7663513422012329,
-0.25544455647468567,
0.31822973489761... | |
I'm looking for a library to save an array of colour data to a PNG file. (That's all there is to it, right? I know very little about the internals of a PNG.)
This is for use in Nintendo DS development, so something lightweight is preferable. I don't need any other fancy features like rotation, etc.
To encode any kind ... | [
0.48496198654174805,
-0.17560908198356628,
0.6098682284355164,
-0.021823657676577568,
-0.1481305956840515,
-0.08139606565237045,
-0.3808065354824066,
-0.030460812151432037,
-0.39100679755210876,
-0.49209266901016235,
0.08455926179885864,
0.728338360786438,
-0.2929534912109375,
-0.025424756... | |
platform, but it will add significant overhead, both in terms of loadtimes and footprint. | [
0.05546146258711815,
-0.13619649410247803,
0.2764380872249603,
0.36953607201576233,
0.05791334807872772,
0.14820784330368042,
-0.018263256177306175,
-0.16863900423049927,
-0.174578458070755,
-0.6372157335281372,
-0.019435692578554153,
0.08763983845710754,
0.04611978307366371,
-0.2106228023... | |
When I'm building a java object using JNI methods, in order to pass it in as a parameter to a java method I'm invoking using the JNI invocation API, how do I manage its memory?
Here's what I am working with:
I have a C object that has a destructor method that is more complex that `free()`. This C object is to be ass... | [
0.20475560426712036,
0.31649014353752136,
-0.1996283233165741,
0.10815230756998062,
0.07831909507513046,
-0.08905996382236481,
-0.04106627032160759,
-0.17414771020412445,
-0.2402212917804718,
-0.6943987011909485,
-0.04494008049368858,
0.5420684218406677,
-0.3703642785549164,
0.259424865245... | |
();
class = (*env)->FindClass (env, "my.class.name");
constructor = (*env)->GetMethodID (env, class, "<init>", "(J)V");
instance = (*env)->NewObject (env, class, constructor, (jlong) c_object);
method = (*env)->GetMethodID (env, other_class, "doSomeWork", "(Lmy.class.name)V");
(*env)->CallVoidMethod (env, other_class,... | [
0.003396688960492611,
-0.03705506771802902,
0.11369124799966812,
-0.0014012372121214867,
0.13909339904785156,
-0.17188489437103271,
0.2448107749223709,
-0.40603286027908325,
-0.09476135671138763,
-0.5567494034767151,
-0.13991260528564453,
0.6397733688354492,
-0.1456824690103531,
0.08266826... | |
to manually release, say, `class`, `constructor`, or `method` above? The JNI doc is frustratingly vague (in my judgement) on the subject of proper memory management.
There are a couple of strategies for reclaiming native resources (objects, file descriptors, etc.)
1. Invoke a JNI method during finalize() which frees t... | [
-0.17290176451206207,
-0.3753017783164978,
0.03302495926618576,
0.23351123929023743,
0.08312506228685379,
-0.34940269589424133,
0.19445432722568512,
-0.1682082712650299,
-0.31016096472740173,
-0.4245492219924927,
-0.5362152457237244,
0.7478195428848267,
0.07062532752752304,
0.0484978370368... | |
good idea.
2. Manually invoke a cleanup method. This is useful if you have a point in time where you know that the resource must be cleaned up. I used this method when I had a resource which had to be deallocated before unloading a DLL in the JNI code. In order to allow the DLL to later be reloaded, I had to be sure th... | [
0.06148722022771835,
-0.2645097076892853,
-0.12745453417301178,
-0.07762831449508667,
-0.08289416879415512,
-0.37805795669555664,
0.02603856287896633,
-0.23365284502506256,
-0.29908668994903564,
-0.6167164444923401,
-0.07579866796731949,
0.6262830495834351,
-0.302687406539917,
-0.115088775... | |
during finalize() or at the manually called cleanup method. (You probably need a canonical map of WeakReferences to track which objects needs to have their cleanup method invoked.)
3. Supposedly the **PhantomReference** can be used to solve this problem as well, but I'm not sure exactly how such a solution would work.
... | [
0.2543988525867462,
-0.28735098242759705,
0.26279476284980774,
0.15586428344249725,
-0.11037445813417435,
-0.26642104983329773,
0.2901841402053833,
-0.029108954593539238,
-0.18438833951950073,
-0.6939607262611389,
-0.019646087661385536,
0.5509176254272461,
0.07319553196430206,
0.0621104463... | |
What is a `StackOverflowError`, what causes it, and how should I deal with them?
Parameters and local variables are allocated on the **stack** (with reference types, the object lives on the **heap** and a variable in the stack references that object on the heap). The stack typically lives at the **upper** end of your a... | [
-0.16688650846481323,
-0.18894727528095245,
0.6215139627456665,
0.14755691587924957,
0.05655592307448387,
0.3033364415168762,
0.04107743129134178,
-0.15228141844272614,
-0.40388980507850647,
-0.4223017394542694,
0.16213034093379974,
0.31371626257896423,
-0.15250632166862488,
0.475001841783... | |
your address space. As you can see, there is a potential for the heap to **"collide"** with the stack (a bit like tectonic plates!!!).
The common cause for a stack overflow is a **bad recursive call**. Typically, this is caused when your recursive functions doesn't have the correct termination condition, so it ends up... | [
-0.012031624093651772,
-0.08099552989006042,
0.15859153866767883,
0.06218485161662102,
-0.06256507337093353,
-0.015221847221255302,
0.5782459378242493,
0.14913234114646912,
-0.36375442147254944,
-0.5907799601554871,
-0.26355451345443726,
0.40169447660446167,
-0.3130980134010315,
0.05323025... | |
call a function that causes the system to send another paint message. Here you've not explicitly called yourself, but the OS/VM has done it for you.
To deal with them, you'll need to examine your code. If you've got functions that call themselves then check that you've got a terminating condition. If you have, then ch... | [
0.424760103225708,
0.04042401164770126,
0.19662871956825256,
-0.31043824553489685,
0.10548156499862671,
0.1861869990825653,
0.4033706784248352,
-0.10350092500448227,
-0.3713178038597107,
-0.5451334118843079,
-0.16166462004184723,
0.8591039776802063,
-0.5418602228164673,
-0.0280754994601011... | |
valid terminating condition, thus make sure your method can handle input values requiring more recursive calls.
If you've got no obvious recursive functions then check to see if you're calling any library functions that **indirectly** will cause your function to be called (like the implicit case above). | [
0.0063608861528337,
-0.17307035624980927,
0.1270371377468109,
0.15039324760437012,
0.07979980111122131,
-0.12866726517677307,
0.39176443219184875,
-0.018764536827802658,
-0.05647990480065346,
-0.20572207868099213,
-0.0630294531583786,
0.6581823825836182,
-0.39977335929870605,
0.21975965797... | |
I just downloaded the ASP.NET MVC beta and the templates are not StyleCop compliant.
**Why is new .NET code coming from Microsoft not StyleCop compliant?**
StyleCop checks conformance to the Microsoft Framework Design Guidelines.
The guidelines are *enforced* only on the code that makes up the .NET Framework proper... | [
0.7606685757637024,
0.021609749644994736,
0.4310750663280487,
-0.019392065703868866,
-0.045568279922008514,
-0.5352242588996887,
0.3886718153953552,
-0.21260403096675873,
0.023295680060982704,
-0.6388088464736938,
-0.1472986936569214,
0.37476080656051636,
-0.0825902447104454,
-0.3128392100... | |
I should point out several important facts:
* Not even the people who *wrote* the
guidelines agree on all of them.
* You probably aren't writing a
framework for release into the wild.
* The guidelines are a work in progress, and StyleCop lags behind them. | [
0.8439491987228394,
0.186003640294075,
0.0741821825504303,
0.16798514127731323,
-0.1512998640537262,
-0.5059062242507935,
0.43185141682624817,
0.14674828946590424,
-0.24535593390464783,
-0.4861886501312256,
0.2181682288646698,
0.42950624227523804,
0.029082003980875015,
-0.20996364951133728... | |
In my Java development I have had great benefit from the [Jad/JadClipse](http://en.wikipedia.org/wiki/JAD_%28JAva_Decompiler%29) decompiler. It made it possible to *know* why a third-party library failed rather than the usual guesswork.
I am looking for a similar setup for C# and Visual Studio. That is, a setup where ... | [
0.1672365367412567,
0.11090493947267532,
-0.04150134325027466,
-0.25564584136009216,
-0.32265496253967285,
-0.14822129905223846,
0.4660674035549164,
0.034368861466646194,
-0.20948463678359985,
-0.7986990809440613,
0.03302278742194176,
0.44574010372161865,
-0.3621571660041809,
-0.0597989670... | |
be a bonus if it was.
It should support Visual Studio 2008 or Visual Studio 2005 and .NET 2 and 3(.5).
Here is a good article about [Reflector and how to integrate Reflector into Visual Studio](http://en.csharp-online.net/Visual_Studio_Hacks%E2%80%94Hack_64:_Examine_the_Innards_of_Assemblies).
> Of particular interes... | [
0.5183283686637878,
0.019595183432102203,
0.6038613319396973,
0.0656467154622078,
-0.3437333106994629,
-0.10887739062309265,
-0.1430075466632843,
-0.13959568738937378,
0.004421577788889408,
-0.7349066138267517,
0.37829598784446716,
0.4921351373195648,
-0.2704961895942688,
-0.07511352747678... | |
version of the Reflector.VisualStudio Add-In from
> <http://www.testdriven.NET/reflector>. The download contains a number of
> files that need to be placed in the same directory as Reflector.exe.
> To install the add-in, drop to the command line and run:
>
>
>
> ```
> Reflector.VisualStudio.exe /install
>
> ```
... | [
0.6301186680793762,
-0.2739812135696411,
0.9458665251731873,
0.10035870224237442,
-0.36398518085479736,
-0.044830113649368286,
0.1502952128648758,
0.11778409779071808,
0.09146743267774582,
-0.8488799929618835,
-0.10400862991809845,
0.6227763891220093,
-0.3299192786216736,
0.162695229053497... | |
menu support.
>
> When you right-click
> in an open code file in Visual Studio, you’ll see a Reflector menu
> item that expands into a submenu with options to disassemble the code
> into C# or Visual Basic, display the call graph or callee graph, and
> other related choices. The context menu also includes a S... | [
-0.021559055894613266,
-0.2700016498565674,
0.5969515442848206,
0.13899660110473633,
-0.0933079943060875,
0.1259137988090515,
0.1545894891023636,
-0.02900414727628231,
0.0011554468655958772,
-0.7388908267021179,
-0.2995184361934662,
0.8238723278045654,
-0.36737802624702454,
-0.024528095498... | |
I need to ensure that any number of websites and services haven't bitten the dust. At the moment I rely on a simple 5 minute cronjob which uses curl and a file of urls to check that all the responses are correct (200 or rarely 301).
It all works on a basic level, I'm interested in more sophisticated open-source tools ... | [
0.36922234296798706,
0.23067273199558258,
0.5787551403045654,
0.3610762059688568,
-0.2932564914226532,
-0.11663378775119781,
0.44593346118927,
0.037790484726428986,
-0.23483528196811676,
-0.5840170979499817,
0.1698945313692093,
0.4749871790409088,
-0.009479274973273277,
-0.0825037732720375... | |
gives you then add [cacti](http://www.cacti.net/). If you want it all in one package you should look into [OpenNMS](http://www.opennms.org/). To get the full benefit of all of these you should be using SNMP too so you can see the details of memory, cpu, disk use as well. | [
0.3696412742137909,
-0.031159531325101852,
0.15481242537498474,
0.10761057585477829,
-0.10441045463085175,
-0.2035224586725235,
-0.3095599114894867,
0.29482969641685486,
-0.6249380111694336,
-0.8425954580307007,
-0.15766632556915283,
0.2822777032852173,
-0.34977900981903076,
-0.03301120176... | |
Can you add new statements (like `print`, `raise`, `with`) to Python's syntax?
Say, to allow..
```
mystatement "Something"
```
Or,
```
new_if True:
print "example"
```
Not so much if you *should*, but rather if it's possible (short of modifying the python interpreters code)
You may find this useful - [Python... | [
0.4364854395389557,
0.08797889947891235,
-0.03270457684993744,
-0.23169831931591034,
-0.15499278903007507,
-0.35295894742012024,
0.36463046073913574,
-0.006695727352052927,
-0.2872660458087921,
-0.22634387016296387,
-0.08020474761724472,
0.650260329246521,
-0.1738481968641281,
-0.285565465... | |
against the cutting-edge Py3k branch in the [Python Mercurial repository mirror](http://code.python.org/hg/branches/py3k/).
### The `until` statement
Some languages, like Ruby, have an `until` statement, which is the complement to `while` (`until num == 0` is equivalent to `while num != 0`). In Ruby, I can write:
``... | [
0.21159540116786957,
-0.0986771285533905,
0.07148877531290054,
-0.19347776472568512,
-0.13787837326526642,
-0.04010733217000961,
0.3512481451034546,
-0.14085741341114044,
-0.02511598914861679,
-0.1055477112531662,
-0.24621541798114777,
0.4811168909072876,
-0.0794573500752449,
-0.1215344294... | |
Python. Although I think such a statement would make some code clearer, and this article displays how easy it is to add, I completely respect Python's philosophy of minimalism. All I'm trying to do here, really, is gain some insight into the inner workings of Python.
### Modifying the grammar
Python uses a custom par... | [
0.5219932198524475,
0.11414946615695953,
0.22915737330913544,
-0.164396733045578,
-0.34838345646858215,
-0.20360614359378815,
0.35609087347984314,
0.15444383025169373,
-0.258340060710907,
-0.38920775055885315,
-0.48687535524368286,
0.8405975103378296,
-0.5721433162689209,
-0.55269420146942... | |
Python source are given relatively to the root of the source tree, which is the directory where you run configure and make to build Python.
Two modifications have to be made to the grammar file. The first is to add a definition for the `until` statement. I found where the `while` statement was defined (`while_stmt`), ... | [
0.30138447880744934,
0.08672536909580231,
-0.02485155314207077,
-0.1806465983390808,
-0.05523163452744484,
-0.17860190570354462,
0.35456186532974243,
-0.41244304180145264,
0.08175934851169586,
-0.45876604318618774,
-0.06939868628978729,
0.5069414377212524,
-0.15037935972213745,
-0.26939868... | |
a common technique I use when modifying source code I’m not familiar with: *work by similarity*. This principle won’t solve all your problems, but it can definitely ease the process. Since everything that has to be done for `while` also has to be done for `until`, it serves as a pretty good guideline.
Note that I've d... | [
0.6267659664154053,
-0.08163822442293167,
-0.09385421872138977,
-0.06542167067527771,
-0.04432593658566475,
-0.34706616401672363,
0.31880664825439453,
-0.02828202396631241,
-0.3216303288936615,
-0.355546772480011,
-0.09627338498830795,
0.5191241502761841,
-0.10733788460493088,
0.1362193375... | |
the rule for `compound_stmt` to include `until_stmt`, as you can see in the snippet above. It's right after `while_stmt`, again.
When you run `make` after modifying `Grammar/Grammar`, notice that the `pgen` program is run to re-generate `Include/graminit.h` and `Python/graminit.c`, and then several files get re-compil... | [
0.21806544065475464,
-0.22819019854068756,
0.3697614371776581,
-0.259748250246048,
0.10024503618478775,
-0.09460466355085373,
0.20875318348407745,
-0.30179572105407715,
-0.23538948595523834,
-0.5100411772727966,
-0.14265047013759613,
0.30488383769989014,
-0.4298255443572998,
-0.18597583472... | |
statement, again right below the `while`:
```
| While(expr test, stmt* body, stmt* orelse)
| Until(expr test, stmt* body)
```
If you now run `make`, notice that before compiling a bunch of files, `Parser/asdl_c.py` is run to generate C code from the AST definition file. This (like `Grammar/Grammar`) is another examp... | [
0.349118173122406,
-0.1516340970993042,
0.22200541198253632,
-0.05519689992070198,
0.12057873606681824,
0.002129839500412345,
0.39229491353034973,
-0.37424764037132263,
-0.20266176760196686,
-0.38556116819381714,
-0.2980858087539673,
0.3042961359024048,
-0.2503262758255005,
0.1397372037172... | |
the files `Include/Python-ast.h` and `Python/Python-ast.c`), we still have to write the code that converts a relevant parse-tree node into it by hand. This is done in the file `Python/ast.c`. There, a function named `ast_for_stmt` converts parse tree nodes for statements into AST nodes. Again, guided by our old friend ... | [
-0.0302993543446064,
0.1451907455921173,
0.3742924928665161,
-0.2652769386768341,
-0.045245248824357986,
-0.14302389323711395,
0.2820778787136078,
-0.3268558979034424,
-0.07374859601259232,
-0.5317956209182739,
-0.27563974261283875,
0.7804548144340515,
-0.1524592936038971,
-0.0504356697201... | |
test ':' suite */
REQ(n, until_stmt);
if (NCH(n) == 4) {
expr_ty expression;
asdl_seq *suite_seq;
expression = ast_for_expr(c, CHILD(n, 1));
if (!expression)
return NULL;
suite_seq = ast_for_suite(c, CHILD(n, 3));
if (!suite_seq) | [
0.3983706533908844,
-0.11362504214048386,
0.5839385390281677,
-0.22457067668437958,
0.6132770776748657,
0.000835537095554173,
0.548540472984314,
-0.6655129194259644,
0.32449644804000854,
-0.6569493412971497,
-0.5174852013587952,
0.31069788336753845,
-0.25212424993515015,
0.2462168931961059... | |
return NULL;
return Until(expression, suite_seq, LINENO(n), n->n_col_offset, c->c_arena);
}
PyErr_Format(PyExc_SystemError,
"wrong number of tokens for 'until' statement: %d",
NCH(n));
return NULL;
}
```
Again, this was coded while closely looking at the equivale... | [
0.0004165619320701808,
-0.3385525047779083,
0.3543798327445984,
-0.39338546991348267,
0.17957603931427002,
0.12512937188148499,
0.1886075735092163,
-0.15221136808395386,
-0.2109619826078415,
-0.252553254365921,
-0.5674139261245728,
0.2186317890882492,
-0.1512947827577591,
0.065636724233627... | |
recursively, using other AST creating functions like `ast_for_expr` for the condition expression and `ast_for_suite` for the body of the `until` statement. Finally, a new node named `Until` is returned.
Note that we access the parse-tree node `n` using some macros like `NCH` and `CHILD`. These are worth understanding ... | [
0.07203492522239685,
-0.23471641540527344,
0.32731202244758606,
-0.2022365927696228,
0.1797029823064804,
-0.04858611151576042,
0.1788148134946823,
-0.1909918338060379,
0.033947430551052094,
-0.4471065402030945,
-0.39777112007141113,
0.31714388728141785,
-0.20863015949726105,
-0.09886488318... | |
condition:
# do stuff
```
Instead of creating the `Until` node in `ast_for_until_stmt`, I could have created a `Not` node with an `While` node as a child. Since the AST compiler already knows how to handle these nodes, the next steps of the process could be skipped.
### Compiling ASTs into bytecode
The next step ... | [
0.29080986976623535,
-0.19546467065811157,
0.31545740365982056,
-0.14742226898670197,
0.5056933164596558,
-0.18453575670719147,
0.2521257698535919,
0.14856737852096558,
-0.15060663223266602,
-0.4987412393093109,
-0.22268493473529816,
0.26097941398620605,
-0.24148119986057281,
0.02601229771... | |
Following the lead of `while`, we find the function `compiler_visit_stmt`, which is responsible for compiling statements into bytecode. We add a clause for `Until`:
```
case While_kind:
return compiler_while(c, s);
case Until_kind:
return compiler_until(c, s);
```
If you wonder what `Until_kind` is, it's a c... | [
0.27737289667129517,
-0.03538363054394722,
0.3908260762691498,
-0.16970767080783844,
0.02799537032842636,
-0.13021163642406464,
-0.056472811847925186,
0.18320508301258087,
-0.1897987574338913,
-0.2821448743343353,
-0.2927981913089752,
0.20307859778404236,
-0.2812557816505432,
-0.0330376029... | |
called. When this is the case, only one option remains - C macro-fu. Indeed, a short investigation leads us to the `VISIT` macro defined in `Python/compile.c`:
```
#define VISIT(C, TYPE, V) {\
if (!compiler_visit_ ## TYPE((C), (V))) \
return 0; \
```
It's used to invoke `compiler_visit_stmt` in `compiler... | [
0.28980958461761475,
-0.15672573447227478,
0.7003653645515442,
-0.18495115637779236,
0.16622450947761536,
-0.22534941136837006,
0.22653256356716156,
-0.029773669317364693,
-0.0581066720187664,
-0.5513277053833008,
-0.37257903814315796,
0.6570305228233337,
-0.46193814277648926,
0.1282872855... | |
1;
}
loop = compiler_new_block(c);
end = compiler_new_block(c);
if (constant == -1) {
anchor = compiler_new_block(c);
if (anchor == NULL)
return 0;
}
if (loop == NULL || end == NULL)
return 0;
ADDOP_JREL(c, SETUP_LOOP, end);
compiler_use_next_block(c,... | [
0.06888148188591003,
-0.1564386636018753,
0.30932775139808655,
-0.37805986404418945,
0.2974779009819031,
-0.08203625679016113,
0.24673932790756226,
-0.38266411423683167,
-0.23758797347545624,
-0.29286110401153564,
-0.7717484831809998,
0.21535415947437286,
-0.584725558757782,
-0.14218816161... | |
loop))
return 0;
if (constant == -1) {
VISIT(c, expr, s->v.Until.test);
ADDOP_JABS(c, POP_JUMP_IF_TRUE, anchor);
}
VISIT_SEQ(c, stmt, s->v.Until.body);
ADDOP_JABS(c, JUMP_ABSOLUTE, loop);
if (constant == -1) {
compiler_use_next_block(c, anchor);
ADDOP(c, POP_... | [
0.29183274507522583,
-0.053111422806978226,
0.6337816119194031,
-0.17708641290664673,
0.214861199259758,
-0.029919886961579323,
0.42512157559394836,
-0.3414965271949768,
-0.08185136318206787,
-0.33562710881233215,
-0.8300105929374695,
0.38312262296676636,
-0.6731896996498108,
0.05591898411... | |
have a confession to make: this code wasn't written based on a deep understanding of Python bytecode. Like the rest of the article, it was done in imitation of the kin `compiler_while` function. By reading it carefully, however, keeping in mind that the Python VM is stack-based, and glancing into the documentation of t... | [
0.8541010022163391,
0.2515725791454315,
0.13983319699764252,
0.18416716158390045,
-0.11289804428815842,
-0.500848650932312,
0.638314425945282,
-0.22646477818489075,
0.04020274803042412,
-0.008029667660593987,
-0.10553307831287384,
0.6705647110939026,
0.2505842447280884,
0.37103113532066345... | |
== 0:
... print(num)
... num -= 1
...
3
2
1
```
Voila, it works! Let's see the bytecode created for the new statement by using the `dis` module as follows:
```
import dis
def myfoo(num):
until num == 0:
print(num)
num -= 1
dis.dis(myfoo)
```
Here's the result:
```
4 0 SETUP_LOO... | [
0.35671934485435486,
-0.004864060785621405,
0.45504847168922424,
-0.1398445963859558,
0.3314000070095062,
-0.06574365496635437,
0.2702963352203369,
-0.20579446852207184,
-0.2365693897008896,
-0.32711148262023926,
-0.15487231314182281,
0.9395759105682373,
-0.1329953670501709,
-0.24983729422... | |
0 (num)
6 LOAD_CONST 1 (0)
9 COMPARE_OP 2 (==)
12 POP_JUMP_IF_TRUE 38
5 | [
0.3675040900707245,
0.14310944080352783,
0.3106531500816345,
-0.09986934065818787,
-0.06708986312150955,
-0.00512658292427659,
0.2863035202026367,
-0.36599060893058777,
0.000014377452316693962,
-0.1356702595949173,
-0.03464692458510399,
0.617638111114502,
-0.19425514340400696,
0.0694000050... | |
15 LOAD_NAME 0 (print)
18 LOAD_FAST 0 (num)
21 CALL_FUNCTION 1
24 POP_TOP
6 25 LOAD_FAST | [
0.09906000643968582,
0.009977627545595169,
0.394618958234787,
-0.09068724513053894,
-0.10829516500234604,
0.01304518524557352,
0.021484971046447754,
-0.22733314335346222,
-0.3056109547615051,
-0.26564931869506836,
-0.19083864986896515,
0.6364341974258423,
-0.345256507396698,
-0.13962975144... | |
0 (num)
28 LOAD_CONST 2 (1)
31 INPLACE_SUBTRACT
32 STORE_FAST 0 (num)
35 JUMP_ABSOLUTE | [
0.02321627549827099,
-0.13178454339504242,
0.2096605747938156,
-0.1860223114490509,
0.2165241688489914,
-0.14167557656764984,
0.33634746074676514,
-0.10262763500213623,
-0.09894566237926483,
-0.0865388810634613,
-0.17239908874034882,
0.5277608633041382,
-0.24992544949054718,
-0.08087661862... | |
3
>> 38 POP_BLOCK
>> 39 LOAD_CONST 0 (None)
42 RETURN_VALUE
```
The most interesting operation is number 12: if the condition is true, we jump to after the loop. This is correct semantics for `until`. If the jump isn't executed, the loop body keeps running until it jumps back ... | [
0.4468858540058136,
0.061654262244701385,
0.09739010781049728,
-0.28739824891090393,
-0.01602679118514061,
-0.15659721195697784,
0.42782992124557495,
-0.3461665213108063,
-0.25463318824768066,
-0.3117496967315674,
-0.07950984686613083,
0.6812682151794434,
-0.30010366439819336,
-0.061926949... | |
then tried running the function (executing `myfoo(3)`) instead of showing its bytecode. The result was less than encouraging:
```
Traceback (most recent call last):
File "zy.py", line 9, in
myfoo(3)
File "zy.py", line 5, in myfoo
print(num)
SystemError: no locals when loading 'print'
```
Whoa... this can... | [
0.04094933345913887,
0.031137337908148766,
0.3130005896091461,
-0.2648444175720215,
-0.12492990493774414,
0.23473025858402252,
0.40873846411705017,
-0.04915168881416321,
-0.256920725107193,
-0.6255226731300354,
-0.3067700266838074,
0.48403334617614746,
-0.3498722016811371,
-0.1651992648839... | |
AST in a manner similar to the code generation functions. Having a symbol table for each scope helps the compiler figure out some key information, such as which variables are global and which are local to a scope.
To fix the problem, we have to modify the `symtable_visit_stmt` function in `Python/symtable.c`, adding c... | [
0.11122513562440872,
-0.2961544990539551,
0.7315544486045837,
-0.21383975446224213,
-0.17830173671245575,
0.10616311430931091,
0.5570374131202698,
-0.15151667594909668,
-0.10049165040254593,
-0.6273742318153381,
-0.5844892859458923,
0.5586395263671875,
-0.4564622640609741,
-0.2060561478137... | |
VISIT(st, expr, s->v.Until.test);
VISIT_SEQ(st, stmt, s->v.Until.body);
break;
```
**[3]**: By the way, without this code there’s a compiler warning for `Python/symtable.c`. The compiler notices that the `Until_kind` enumeration value isn’t handled in the switch statement of `symtable_visit_stmt` and complain... | [
0.32849153876304626,
0.09035789966583252,
0.7181730270385742,
-0.18276384472846985,
-0.017048602923750877,
-0.3048924207687378,
0.5646892189979553,
0.037062082439661026,
-0.13424840569496155,
-0.5472313761711121,
-0.19477511942386627,
0.6244459748268127,
-0.318116694688797,
0.0760825648903... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.