text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void UpdateLabelButton_Click(object sender, EventArgs e)
{
SomeClass updater = new SomeClass();
updater.OnLabelUpdate += new SomeClass.UpdateLabel(updater_OnLabelUpdate);
updater.Process();
}
... | [
0.03719126805663109,
-0.42005839943885803,
0.6138477921485901,
-0.31845349073410034,
-0.05467812716960907,
-0.13313159346580505,
0.35460248589515686,
-0.38285666704177856,
-0.08866105228662491,
-0.5410926938056946,
-0.5969626307487488,
0.4385063946247101,
-0.5249634981155396,
0.14274144172... | |
I just have a general .NET inquiry:
Suppose I have a large (memory size) Class
```
public class BigClass
{
...
}
```
If I add an item to an ItemControl such as a ListBox or Datagrid like this
```
BigClass b = new BigClass();
ListBox1.Items.Add(b);
```
How is the resource usage in doing something like this? Is th... | [
0.056946322321891785,
-0.012537829577922821,
0.22513514757156372,
-0.03279068320989609,
-0.06764505058526993,
-0.19914238154888153,
0.19044649600982666,
0.03936833515763283,
-0.28733116388320923,
-0.6904857158660889,
-0.05775057524442673,
0.41382771730422974,
-0.4077194631099701,
0.3466462... | |
I am new to programming. I'm studying Computer Science, and programming is probably going to be a career I'm going to pursue. Next semester we're going to have a large project where we are going to program Graphical User Interface (GUI) applications and we're allowed to pick our own language and platform.
I have to sa... | [
0.7853338718414307,
0.3964705467224121,
-0.08014780282974243,
-0.0347595289349556,
-0.12639714777469635,
-0.21755065023899078,
-0.05794529989361763,
0.4444205164909363,
-0.13121776282787323,
-0.7975323796272278,
0.22651205956935883,
0.6182852983474731,
0.16628414392471313,
0.04074740037322... | |
and .NET is a great choice, especially if you want a language that is a lot like Java.
For starters, download [Visual Studio Express](http://www.microsoft.com/Express/) (free), and you'll be able to create Windows Apps with C# and .NET. GUIs are as easy to create as Dragging controls on to a form.
You can also use C#... | [
0.5790429711341858,
0.06688234210014343,
-0.14102280139923096,
0.02824912779033184,
-0.3176124095916748,
-0.166691854596138,
-0.13823893666267395,
0.21962986886501312,
-0.2927855849266052,
-0.7042051553726196,
-0.22629882395267487,
0.8087166547775269,
-0.2911899983882904,
-0.06562539935112... | |
I am having problems getting the values of a dropdownlist from the FIndControl function.
Here is the code I am trying to use:
```
currentCategoryID = Convert.ToInt32(((DropDownList)r.FindControl("DDLCategories")));
```
The value of the currentCategoryID in the database is an "int"
When I execute the above code I g... | [
-0.09697726368904114,
0.1847563534975052,
0.6204177737236023,
-0.17765270173549652,
0.12837816774845123,
-0.15254457294940948,
0.5088179707527161,
-0.06724216043949127,
-0.025002170354127884,
-0.789923369884491,
0.019777072593569756,
0.6321776509284973,
-0.21888260543346405,
0.323918372392... | |
You should drill down further into the control to retrieve the value before you convert it. For example,
```
currentCategoryID = Convert.ToInt32(((DropDownList)r.FindControl("DDLCategories")).SelectedItem.Value);
``` | [
-0.2205217182636261,
-0.4156515300273895,
0.4663805663585663,
-0.13032563030719757,
0.5785229802131653,
-0.13617122173309326,
0.24154983460903168,
-0.3364659547805786,
-0.08159011602401733,
-0.5869840979576111,
-0.04762953519821167,
0.6341856718063354,
-0.12525297701358795,
0.3251692652702... | |
I have a DataGrid and an Expander like so:
```
<StackPanel>
<my:DataGrid Name="dataGrid1" AutoGenerateColumns="False" ItemsSource="{Binding}">...</my:DataGrid>
<Expander Header="{Binding ElementName=dataGrid1, Path=SelectedItem.Name, StringFormat=Details of {0}}">...</Expander>
</StackPanel>
```
The binding is fine... | [
-0.1336366832256317,
-0.029832905158400536,
0.2972140908241272,
-0.0941457524895668,
0.03959571570158005,
-0.1947455108165741,
0.019263960421085358,
-0.4492766261100769,
-0.05314900726079941,
-0.8902812004089355,
0.19400382041931152,
0.5408297777175903,
-0.25088971853256226,
0.174509778618... | |
meant to be used with string format binding, but rather to specify the format to use when binding to an object that implements `IFormattable`.
Given that, I couldn't get string formatting to work directly in the binding expression, either, so that might just be a bug. You should try notifying Microsoft and maybe they'... | [
0.23103460669517517,
-0.10036022216081619,
0.258738249540329,
-0.017114870250225067,
-0.0747307762503624,
-0.6050716638565063,
-0.05948762968182564,
0.06344160437583923,
-0.21752533316612244,
-0.5296743512153625,
-0.15469111502170563,
0.5799172520637512,
-0.42576247453689575,
0.06558922678... | |
I have two questions concerning the `sleep()` function in PHP:
1. Does the sleep time affect the maximum execution time limit of my PHP scripts? Sometimes, PHP shows the message "maximum execution time of 30 seconds exceeded". Will this message appear if I use `sleep(31)`?
2. Are there any risks when using the `sleep(... | [
0.38145196437835693,
0.001601789495907724,
0.24409353733062744,
-0.24460557103157043,
0.053383879363536835,
-0.08777062594890594,
0.48756682872772217,
-0.14736759662628174,
-0.23317520320415497,
-0.7398545742034912,
-0.022852567955851555,
0.7731021642684937,
-0.27830660343170166,
-0.251434... | |
Item is a simple model class.
ItemComponent is a view for an Item which just draws simple rectangles in a given spot. A bunch of ItemComponent instances are put into a parent component that is added to the JFrame of the application (just a simple shell right now).
The view has two different display styles. I want to... | [
0.24880339205265045,
-0.3110246956348419,
0.5604146122932434,
0.08050773292779922,
-0.17351354658603668,
0.23464760184288025,
0.04251730814576149,
0.048995550721883774,
-0.36591219902038574,
-0.7246301174163818,
0.116047203540802,
0.3724008798599243,
-0.2108410894870758,
0.3149963915348053... | |
wrong?
I'm not a Swing programmer and cobbled this together from examples, so I expect it may be something trivial here I don't understand.
```
public class ItemComponent extends JComponent implements ItemView {
private static final Color COLOR_FILL_NORMAL = new Color(0x008080ff);
private static final Color ... | [
0.08196219801902771,
-0.0847950130701065,
0.5527179837226868,
-0.2525275647640228,
0.291492760181427,
0.3528220057487488,
0.3512924611568451,
-0.3130265474319458,
-0.23625345528125763,
-0.37813350558280945,
-0.4331759810447693,
0.5597123503684998,
-0.5008798241615295,
0.21807044744491577,
... | |
this.item = item;
this.rect = new RoundRectangle2D.Double(0, 0, 0, 0, 5, 5);
item.setView(this);
}
public void setState(State state) {
this.state = state;
}
public void update() {
System.out.println("ItemComponent.update");
setLocation(item.getLeft(), 1);
... | [
0.012721027247607708,
-0.3927430212497711,
0.6689302325248718,
-0.30111217498779297,
0.20314475893974304,
0.2888675332069397,
0.465989887714386,
-0.5027651786804199,
-0.3191860020160675,
-0.5347283482551575,
-0.623464822769165,
0.47865381836891174,
-0.4827781617641449,
0.2316717952489853,
... | |
repaint();
//paintImmediately(getBounds());
}
@Override
public void addNotify() {
update();
}
@Override
public void paint(Graphics g) {
System.out.println("paint");
Graphics2D g2 = (Graphics2D)g;
g2.setComposite(AlphaComposite.getInstance(AlphaComposit... | [
0.08521822094917297,
-0.335798442363739,
0.6826215386390686,
-0.3352644741535187,
0.037219468504190445,
0.3883776366710663,
0.714752197265625,
-0.5148932337760925,
-0.16283392906188965,
-0.7616081833839417,
-0.5064159035682678,
0.6990174651145935,
-0.4304380416870117,
0.07959479838609695,
... | |
System.out.println("draw normal");
g2.setPaint(COLOR_FILL_NORMAL); // light blue
g2.fill(rect);
g2.setPaint(COLOR_OUTLINE);
g2.draw(rect);
}
else if (state == State.TARGET) {
System.out.println("draw target"); | [
-0.09279034286737442,
-0.5039725303649902,
0.44040653109550476,
-0.40192440152168274,
0.2384081929922104,
0.2845410406589508,
0.15002362430095673,
0.03305913135409355,
0.07427119463682175,
-0.6632874011993408,
-0.4587096571922302,
0.41124141216278076,
-0.5533276200294495,
0.192035838961601... | |
g2.setPaint(COLOR_FILL_TARGET);
g2.fill(rect);
float[] dashPattern = { 8, 5 };
g2.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, dashPattern, 0));
g.setColor(COLOR_OUTLINE);
g2.draw(rect);
}
}
}
```
---
**Hint:**... | [
-0.017703382298350334,
-0.46678200364112854,
0.7663193345069885,
-0.19480589032173157,
0.22370192408561707,
0.11235012114048004,
0.33081862330436707,
-0.4274815320968628,
-0.06441910564899445,
-0.604110836982727,
-0.3958846926689148,
0.5829921364784241,
-0.3589972257614136,
-0.217349112033... | |
and it's returning false. It makes sure that getPeer() != null.
So my component has no peer? What's up with that? It's been added to a container which itself is added to the rest of the app. And it gets painted once, so I know it's visible.
My apologies to people who looked at this already. I trimmed down the code a ... | [
0.6455875039100647,
0.11996401846408844,
0.49150940775871277,
-0.16775472462177277,
0.15507206320762634,
-0.020261630415916443,
0.6277362704277039,
-0.040499523282051086,
-0.18081124126911163,
-0.6605802774429321,
0.10346245765686035,
0.4600052833557129,
-0.4011794924736023,
-0.02962441928... | |
this, or at least you need to call super.addNotify(), or a whole bunch of important initialization doesn't happen.
Changing it to this fixed the problem:
```
@Override
public void addNotify() {
super.addNotify();
update();
}
``` | [
0.23169095814228058,
-0.3200520873069763,
0.3549292981624603,
-0.2597653269767761,
0.12246336042881012,
-0.1911841183900833,
0.3623209595680237,
-0.16447322070598602,
-0.2839088439941406,
-0.5058857798576355,
-0.1757483035326004,
0.6906261444091797,
-0.7256481051445007,
0.05544446036219597... | |
I'm currently maintaining some old code for a company. As it would happen, the current app I'm modifying uses an older version of the in-house library (we'll call this Lib1.dll). They also have a new version of the library called Lib2.dll that improves upon the previous library in many ways.
Unfortunately, Lib2 is not... | [
0.3591000735759735,
0.4400131404399872,
0.13588805496692657,
0.048179540783166885,
-0.027096260339021683,
0.07047296315431595,
0.3103787302970886,
0.0230488833039999,
-0.1396079808473587,
-0.8696597814559937,
0.09616255015134811,
0.3651667833328247,
-0.33651143312454224,
0.5691266059875488... | |
they using the same namespace).
Basically, I need something like:
```
Imports Lib1:Product.Common.Class
```
I'm using VB.NET 1.1.
I found a blog entry that has a solution in C#, not sure of the solution in VB.NET.
[Extern alias walkthrough](https://learn.microsoft.com/en-us/archive/blogs/ansonh/extern-alias-walkth... | [
0.16512621939182281,
0.1857200413942337,
0.21985848248004913,
-0.069660484790802,
-0.04645280912518501,
-0.20749957859516144,
0.2918234169483185,
-0.007850193418562412,
-0.1692967414855957,
-0.7600072026252747,
-0.05951401963829994,
0.657339870929718,
-0.2530837655067444,
0.085105501115322... | |
I'm trying to find the name of the file I'm editing inside of Vim. So I can use it to map `F5` to compile this file. Would of course be great if I could recognize the file format, and choose compiler accordingly, but really not necessary. If I find the name of the file, I could do that myself. But I really can't find a... | [
0.8243080973625183,
0.24378496408462524,
0.2230357527732849,
0.0640542134642601,
0.34478864073753357,
-0.1495056003332138,
0.04292658343911171,
0.18528568744659424,
-0.16169017553329468,
-0.6762137413024902,
0.05016428977251053,
0.5830702781677246,
-0.008774860762059689,
0.3463605940341949... | |
simple makefile.
> I'm trying to find the name of the file I'm editing inside of vim.
For the current buffer this will give you name of the file,
```
echo "You're editing " bufname("%")
```
(just put it in some file.vim, and source it ":so %". But I don't think this is what you need.
> So I can use it to map `F5` ... | [
0.4951764941215515,
0.09087233990430832,
0.3565470278263092,
-0.08646959066390991,
0.2605048716068268,
0.07908669859170914,
0.11478163301944733,
-0.22362938523292542,
-0.03958594799041748,
-0.6111159324645996,
0.278188019990921,
0.40885305404663086,
-0.4052061140537262,
0.13770036399364471... | |
really can't find any way to get the name of the file I'm editing.
You could do several things. If vim recognizes the filetype you're editing, you could map `F5` to your compiler command and put that command in its specific ftplugin directory, so it will be valid only for that filetype. For example, you put
```
nmap ... | [
0.33606961369514465,
0.24599164724349976,
0.2840989828109741,
0.040769606828689575,
0.03857295215129852,
-0.10551593452692032,
0.04974577948451042,
0.15291434526443481,
-0.42170876264572144,
-0.6667734384536743,
-0.026070065796375275,
0.5077266693115234,
-0.38225415349006653,
0.29116740822... | |
going to compile fortran with cpp compiler, you put `fortrancompiler %` in that case.
That is one option. You could also try according to extension set autocmd commands in your `.vimrc` so it recognizes the filetype according to extension of the file. This is all standard usage of vim, nothing uncommon. Now, I'm not s... | [
0.4687427282333374,
0.14325198531150818,
0.10109110176563263,
0.09473122656345367,
0.08388104289770126,
-0.432649701833725,
0.41881510615348816,
0.19161416590213776,
-0.28763648867607117,
-0.5423844456672668,
0.061851490288972855,
0.73299241065979,
-0.23410910367965698,
-0.1091866493225097... | |
for small scripts/testing programs, I really don't want to first have to write a simple makefile.
Yes, that seems like overkill. Personally (when I'm on Windows), I find simple batch file much easier to write for most things except big projects. If the program is in one or two files, I just compile it using some oneli... | [
0.43492022156715393,
-0.03996198996901512,
-0.0937068983912468,
-0.11579403281211853,
-0.0741565078496933,
-0.09555737674236298,
-0.022712048143148422,
0.20352567732334137,
-0.2435162216424942,
-0.788752555847168,
0.07452653348445892,
0.39947080612182617,
0.029178999364376068,
0.0968618839... | |
I need to detect which view is in front (currently visible). How can I do this?
Here is a what I would like to do:
```
if ( ! <<methodToTellIfViewAIsInFront>>) {
[viewA prepareToDisplay];
[window bringSubviewToFront: viewA];
}
```
UIView's don't necessarily have a concept of being in front. UIWindows can be key ... | [
0.15736091136932373,
-0.2176215946674347,
0.6262617707252502,
0.09927739948034286,
-0.21416445076465607,
-0.059753261506557465,
0.15316545963287354,
-0.15815645456314087,
0.04697270318865776,
-0.7000362873077393,
-0.12818269431591034,
0.547577440738678,
0.2305353283882141,
0.07194572687149... | |
some translucent view. Likewise a view at the front may not be visible at all if its opacity value or hidden flags are modified.
I think what you want to do is check the subviews NSArray of your superview or UIWindow and check that. I can't remember which is the front, but it is either the first or last object.
Subvi... | [
0.3059687316417694,
-0.25902071595191956,
0.5541204810142517,
0.25775623321533203,
-0.2626646161079407,
0.2018423080444336,
0.03976430743932724,
0.2504952847957611,
-0.13311776518821716,
-0.641692042350769,
-0.10455331206321716,
0.4054276943206787,
-0.12435626238584518,
0.0822894498705864,... | |
**What are the principles and patterns that go into writing effective XSLT?**
When I say "effective" I mean that it is
1. Well-structured and readable
2. Simple, concise
3. Efficient (i.e. has good performance)
In short, I'm looking for the best practices for XSLT.
I've already seen [the question regarding efficien... | [
0.4757068157196045,
0.419953852891922,
0.30141937732696533,
-0.2245330959558487,
-0.1663919985294342,
-0.16033048927783966,
0.6060137748718262,
-0.4359692335128784,
0.11691082268953323,
-0.7503893971443176,
-0.1297767460346222,
0.8850147724151611,
-0.223546102643013,
-0.5712800621986389,
... | |
saying it again. I find that `for-each` is often a sign of the developer trying to employ traditional programming techniques in a declarative language.
2. **Underutilizing XPath.** A lot of bad XSLT I've seen exists purely because the developer didn't understand predicates, axis specifiers, `position()`, and `current()... | [
0.5381069183349609,
0.0557732954621315,
0.17499734461307526,
0.04804334416985512,
-0.6311886310577393,
-0.16840270161628723,
0.8018431067466736,
-0.23422236740589142,
-0.023844730108976364,
-0.33239904046058655,
-0.11336608976125717,
0.8097555637359619,
-0.34290212392807007,
0.154021903872... | |
parsing outside of XSLT and either add the parsed results to the XML or pass the parsed results as an argument to the transform. I've seen some remarkably unmaintainable XSLT implementing business logic that would be trivial to implement in C# or Python.
The biggest problem that I'm running into in my own XSLT world (... | [
0.33866992592811584,
0.09473079442977905,
0.26910924911499023,
0.22389811277389526,
-0.3206559717655182,
-0.21657203137874603,
0.44381657242774963,
-0.06823255121707916,
0.07979852706193924,
-0.4400264620780945,
-0.16005495190620422,
0.8135675191879272,
-0.5364185571670532,
-0.099640227854... | |
`<xsl:template match="SomeField[contains(., "some value")]>` is alive or dead, because it's contingent on something that metadata can't tell you. | [
0.4623590111732483,
-0.040475163608789444,
0.25228655338287354,
0.15996310114860535,
0.4223725199699402,
-0.8118906617164612,
0.12877222895622253,
0.027749957516789436,
0.002446274273097515,
-0.2113800197839737,
-0.47771239280700684,
0.20922860503196716,
-0.36779075860977173,
0.21516442298... | |
I have the following sql (a simplification of the real problem):
```
SELECT *
FROM t
WHERE myname LIKE '%{$input}%';
```
How do I escape the $input?
I can't use the quoteInto (unless I miss something).
As
```
$sql=$DB->quoteInto("SELECT *
FROM t
WHERE myname LIKE '%?%... | [
0.10460301488637924,
0.24519455432891846,
0.3532353341579437,
-0.11576858162879944,
0.09182494133710861,
0.021223034709692,
0.46121469140052795,
-0.2739427387714386,
0.03276526555418968,
-0.5707541704177856,
-0.08141189813613892,
0.5455228090286255,
-0.35224467515945435,
0.2263263165950775... | |
FROM t
WHERE myname LIKE ?",'%'.$input.'%');
```
Will give me something on the lines:
```
SELECT *
FROM t
WHERE myname LIKE '\%my input\%';
```
The last option is works out well for me i've not experienced it escaping '%'. So `$db->quote('%'.$_GET['query'].'%')` outputs `%queryvalue%` | [
0.16553428769111633,
-0.028999637812376022,
0.5572330951690674,
-0.10970249772071838,
0.0246130283921957,
0.18734613060951233,
0.31197288632392883,
0.02554525062441826,
0.31180039048194885,
-0.5434476137161255,
-0.27222520112991333,
0.6926025748252869,
-0.1219770535826683,
0.20645236968994... | |
I have an AJAX chat system that I'm working on and so far I have it working. One thing I want to do is have it so when the user name is displayed on screen, it is a unique color (like in an AIM window). How would I generate a random color to assign to the user's name for the particular session they are logged in for?
... | [
0.5405339598655701,
-0.060352955013513565,
-0.08714532107114792,
-0.0006267749122343957,
-0.07957445085048676,
-0.07987087965011597,
0.14455640316009521,
0.4987773001194,
-0.23053283989429474,
-0.8171427845954895,
0.4464028775691986,
0.40481895208358765,
-0.13116124272346497,
0.07359132915... | |
assigned.
**EDIT** Thanks, I guess a predefined list would be the easiest way. If I have this list in a config file and I assign a color when the user logs in, how should I go about making sure that no two logged in users have the same color?
I think you're going to be better off randomly picking from a list of pregen... | [
0.5813599824905396,
-0.12551580369472504,
-0.05713733285665512,
0.3093971610069275,
-0.0398065447807312,
0.08668774366378784,
0.1236257553100586,
0.06971022486686707,
-0.5824679732322693,
-0.7022550702095032,
0.062135353684425354,
0.4238269031047821,
-0.3699781000614166,
-0.176278397440910... | |
systems do is to just assign colors locally on the users machine using Javascript. Usually it's not that important that different users see the same colors for other people. I don't care if the colors on my screen are the same as they are on some other user's screen, as long as all the colors on my screen are unique. I... | [
0.45181989669799805,
0.03833184391260147,
0.22208547592163086,
0.10961257666349411,
0.16240164637565613,
0.06245161220431328,
0.27383309602737427,
0.5255714058876038,
-0.1368146538734436,
-0.9125590324401855,
0.15081728994846344,
0.1713617593050003,
-0.4768305718898773,
0.15032406151294708... | |
I am using sqlite in my C# project. MoMA complains about the DLLs and i am unsure what to do on the mac/linux side. What are things i generally need to do when porting external DLLs?
You could use the SQLite assembly that's shipped with Mono - it's derived from the one you are probably using now.
See <http://mono-proj... | [
0.7970211505889893,
0.33676671981811523,
0.0005429355660453439,
-0.10030268132686615,
-0.18949200212955475,
-0.14687679708003998,
0.09034520387649536,
0.12417664378881454,
-0.35035866498947144,
-0.4857786297798157,
0.31209468841552734,
0.6985155344009399,
-0.31583771109580994,
0.2830061912... | |
I have gotten mixed up in the past with regards to file paths (relative, physical, etc.). With my following project structure:
```
Solution MySolution
- MyProject
-MiniApp Folder
-MiniApp.aspx
-Default.aspx
-Default2.aspx
```
Please provide examples on redirection (**ex. Response.Redirect("~/Default.as... | [
0.011397244408726692,
-0.06059027463197708,
0.8489750027656555,
0.13104195892810822,
0.2079799622297287,
0.11720766872167587,
0.6725193858146667,
-0.13941322267055511,
-0.26847732067108154,
-0.881884753704071,
-0.1208624318242073,
0.3819964826107025,
-0.2689165472984314,
0.2952930927276611... | |
Have a huge mysql table with like 300,000 records and wanted to page the records in PHP (not the point here though) with a query in this manner:
```
SELECT * FROM `table` LIMIT 250000, 100
```
It could be majorly slow in the latter part of the records, especially when near the end of the table (LIMIT start very lar... | [
0.08230997622013092,
0.19798322021961212,
0.15177401900291443,
0.40346816182136536,
-0.08216865360736847,
-0.16716493666172028,
0.2569962739944458,
0.14138507843017578,
-0.5318097472190857,
-0.5450360774993896,
0.46144866943359375,
0.241421177983284,
0.06719029694795609,
0.1306422054767608... | |
otherwise it's doing a full table scan. You can look at the execution plan to verify this or force the issue by using an `ORDER BY` clause (on an indexed column). Here is [more information](http://forums.mysql.com/read.php?24,24830,24830).
Your table isn't that large at 300k rows. There are performance issues with get... | [
0.14269977807998657,
0.14720232784748077,
0.41024982929229736,
0.03884182125329971,
0.1080782413482666,
0.1759663075208664,
0.17527204751968384,
-0.1713135689496994,
-0.4953409731388092,
-0.6665748357772827,
0.14939209818840027,
0.3795451521873474,
-0.11172079294919968,
0.13158388435840607... | |
frequently deleting rows but I tend to find that older data tends to change less so you could somewhat optimize it by using `LIMIT` for the first 100,000 rows and the surrogate paging column beyond that. | [
-0.03787074610590935,
-0.05726444348692894,
0.3036344647407532,
0.18648017942905426,
-0.01252585556358099,
0.01148898433893919,
0.09971185028553009,
-0.14717257022857666,
-0.45132187008857727,
-0.6536124348640442,
0.008076841942965984,
0.12451326847076416,
-0.10873571038246155,
0.250241041... | |
I have class with a forwarding method `foo`:
```
void foo( Concrete c, String s ) { c.bar( s ); }
```
I wish to test whether `foo` does, in fact, forward. Unfortunately for me, `Concrete` is a class in a third-party library, and is a concrete type, not an interface. Thus I must use `ClassImposteriser` in JMock to mo... | [
0.2159009575843811,
0.5477990508079529,
0.304550439119339,
-0.4994148015975952,
-0.34244248270988464,
0.37301161885261536,
0.44424715638160706,
-0.4017995595932007,
0.07500877976417542,
-0.269425630569458,
0.13064026832580566,
0.4477071762084961,
-0.3970952332019806,
0.28787609934806824,
... | |
// expectations
context.checking(new Expectations() {{
oneOf (c).bar(s); // exception gets thrown from here
}});
new ClassUnderTest.foo( c, s );
context.assertIsSatisfied();
```
}
Unfortunately, `Concrete.bar` in turn calls a method that throws. That method is final, so I can't override it. Further, e... | [
0.2544821798801422,
0.12213011085987091,
0.17427708208560944,
-0.28325748443603516,
-0.03712286800146103,
0.06253347545862198,
0.3456324338912964,
-0.43045932054519653,
-0.0647643432021141,
-0.5956798791885376,
0.01682763360440731,
0.6487572193145752,
-0.032305218279361725,
0.1740575432777... | |
class in the third-party library to correctly set up `Concrete`.
It's not clear from the question text if Concrete.bar() is final or if Concrete.somethingElse() is final and called from Concrete.bar().
If Concrete.bar() **is not final**, create a hand-written stub for Concrete like this:
```
public class ConcreteStub... | [
0.46237578988075256,
-0.013140023685991764,
0.21106798946857452,
-0.40822726488113403,
-0.04108169302344322,
0.0337175577878952,
0.44710633158683777,
-0.4648771286010742,
0.06635566800832748,
-0.3461954891681671,
-0.2754998505115509,
0.5397382378578186,
-0.2995186746120453,
0.1562247723340... | |
your use of Concrete is simple enough, I would consider wrapping Concrete in an interface ([Adapter Pattern](http://en.wikipedia.org/wiki/Adapter_pattern)) that you can then mock out easier.
Benefits to the Adapter Pattern solution: Possibly clarify behavior by naming interface after your project's use of Concrete. E... | [
0.7233873605728149,
0.15280359983444214,
-0.16411355137825012,
0.056675225496292114,
-0.2849564850330353,
0.005809228401631117,
0.2488095462322235,
-0.3547183573246002,
-0.06918992847204208,
-0.7451416850090027,
0.23271256685256958,
0.6476938128471375,
-0.4743618369102478,
0.00275841960683... | |
I'm currently deprived from any Windows machine, and Mono doesn't run my application. Is there another way that might get around any reason why Mono wouldn't work? (I don't have the error message at the moment.)
Other than virtualization, no. If you have the hardware to do it I would recommend [VMware](http://www.vmwar... | [
0.6617890000343323,
0.3046674132347107,
0.021960189566016197,
0.24599094688892365,
0.26290908455848694,
-0.17475762963294983,
0.4763590097427368,
-0.014513175003230572,
-0.23659133911132812,
-0.6113660931587219,
-0.14125151932239532,
0.6253994107246399,
0.014557411894202232,
0.442602932453... | |
So yea, im working on a windows system and while this works locally, know it will break on other peoples servers. Whats a cross platform way to do the same as this
```
function fetch($get,$put){
file_put_contents($put,file_get_contents($get));
}
```
Here would be the solution using simple file operations:
```
<?... | [
0.12171377241611481,
-0.01865202561020851,
0.8296836614608765,
-0.23335878551006317,
0.2901639938354492,
-0.14349336922168732,
0.35479074716567993,
-0.38642022013664246,
-0.24978512525558472,
-0.7192819118499756,
-0.4076860547065735,
0.6514031291007996,
-0.40943434834480286,
0.317398399114... | |
= fopen($put, 'w');
while (!feof($hostfile)) {
$output = fread($hostfile, 8192);
fwrite($fh, $output);
}
fclose($hostfile);
fclose($fh);
}
```
Hope it helped! =)
---
Cheers,
KrX | [
0.0651274099946022,
0.32935914397239685,
1.007232666015625,
-0.5823444128036499,
-0.07390441745519638,
0.2960015833377838,
0.6211413145065308,
-0.2736627757549286,
-0.005173844285309315,
-0.39181652665138245,
-0.3096534311771393,
0.5491877794265747,
-0.28016841411590576,
0.1276127845048904... | |
I have an `NSMutableArray` with contents I want to replace with `NSNull` objects.
This is what I do:
```
NSMutableArray* nulls = [NSMutableArray array];
for (NSInteger i = 0; i < myIndexes.count; i++)
[nulls addObject:[NSNull null]];
[stageMap replaceObjectsAtIndexes:myIndexes withObjects:nulls];
```
How can ... | [
-0.21641550958156586,
-0.0449090451002121,
0.47940683364868164,
-0.14419034123420715,
-0.15899604558944702,
0.10222446918487549,
0.5922260284423828,
-0.4363193213939667,
-0.25576725602149963,
-0.7142508625984192,
-0.020462002605199814,
0.5070469379425049,
-0.2252337485551834,
0.30366560816... | |
[stageMap replaceObjectAtIndex:index withObject:[NSNull null]];
index = [myIndex indexGreaterThanIndex:index];
}
}
```
You can use a `for` loop. Start with the first index, use `indexGreaterThanIndex:` to get the next index, and stop after you hit the last index.
Don't forget to account for an empty index... | [
0.31988537311553955,
0.03837915509939194,
0.1806396245956421,
-0.055937692523002625,
0.10505615919828415,
-0.18785743415355682,
0.468703031539917,
-0.20997248589992523,
0.012433787807822227,
-0.584784209728241,
0.06359681487083435,
0.4881742298603058,
-0.5642852187156677,
0.111649170517921... | |
and don't go optimizing things until you have run Shark (or Instruments, if that's your thing) and found exactly what is slow. | [
0.47945094108581543,
-0.0866970494389534,
-0.11504656821489334,
0.45289137959480286,
0.4858846962451935,
-0.16412244737148285,
0.12095490843057632,
0.4159690737724304,
-0.2755033075809479,
-0.5501335859298706,
0.2145993709564209,
0.5624523162841797,
0.0957542210817337,
-0.2946649193763733,... | |
How do I replace using the following code?
```
ereg_replace("%Data_Index\[.\]%", $this->resultGData[$key ][\\1], $var)
```
I want to replace the number in [] `%Data_Index`
to `$this->resultGData[$key ][\\1]` same `%Data_Index`
and how `ex %Data_Index[1] = $this->resultGData[$key][1], $var);`
replace number in... | [
-0.11162541806697845,
-0.13164760172367096,
0.6225199103355408,
-0.1664719432592392,
-0.1239023432135582,
-0.11313743889331818,
0.0926576629281044,
-0.4964827597141266,
-0.05549587309360504,
-0.3168880343437195,
-0.5484665036201477,
0.740427553653717,
-0.2886332869529724,
-0.17214624583721... | |
I am making a rails app and having a ridiculously hard time trying to get the Redbox plugin to work. I'm pretty sure I installed everything correctly and am using it properly. When I use one of the helper methods, it seems to generate javascript properly. For example when I type:
```
<%= link_to_redbox 'hello', 'test'... | [
0.3368275761604309,
0.28448373079299927,
-0.032365575432777405,
-0.28214749693870544,
-0.17211949825286865,
0.07388628274202347,
0.64372318983078,
0.006730318535119295,
0.18403378129005432,
-0.8674646019935608,
0.11712010949850082,
0.5991200804710388,
-0.41708728671073914,
-0.1755046546459... | |
redbox.js link is generated as:
```
<script src="/javascripts/redbox.js?1239506092" type="text/javascript"></script>
```
the css has to be inline! | [
-0.1054859310388565,
0.15537478029727936,
0.542407751083374,
-0.18694424629211426,
-0.26841309666633606,
0.0968160405755043,
0.14253117144107819,
-0.027629278600215912,
-0.22428080439567566,
-0.46212729811668396,
-0.11901183426380157,
0.08604239672422409,
-0.6961130499839783,
-0.0606833435... | |
I am not sure if I am getting in a little too deep but I have decided i'd like to learn how to develop applications built using the Oracle technology stack.
I don't come from a programming background (I have always been on the business side) but I love that no matter what problem you encounter, you can almost always s... | [
0.6358999609947205,
0.30405738949775696,
-0.654136598110199,
-0.13767841458320618,
0.12095098197460175,
-0.04594040662050247,
0.08226475119590759,
0.1823217123746872,
0.029885390773415565,
-0.38969728350639343,
0.23656213283538818,
0.45665040612220764,
0.06775951385498047,
-0.0240264851599... | |
If Oracle is an ok start, from what I can ascertain i'll need to get a fair grasp of Java as well. Where should I start?
Im not necessarily looking for the quickest way, but I do want to make sure that whatever I do gives me a good understanding of what is going on.
If you don't have any object-oriented programming ba... | [
0.11760096997022629,
0.10213831067085266,
-0.18377526104450226,
-0.033730193972587585,
-0.2026708722114563,
-0.43711182475090027,
0.1206459254026413,
0.07464783638715744,
-0.1633957475423813,
-0.3196603059768677,
-0.0037961748894304037,
0.5161383748054504,
0.3325953483581543,
-0.3570474684... | |
and java. You can move yourself to use any technology including Oracle technology stack and other OO language such as python and C#. | [
0.3806550204753876,
0.06709566712379456,
-0.020162547007203102,
0.20085251331329346,
0.33409494161605835,
0.2970051169395447,
-0.41132602095603943,
0.24298666417598724,
-0.21294043958187103,
-0.45431727170944214,
-0.5085129737854004,
0.6284016966819763,
-0.09571166336536407,
-0.21312503516... | |
I've added some extra functionality to my wordpress so that I can visit it with a variable and do extra stuff.
The problem is, when I turn my ugly dynamic link into lovely permlink formatting in the .htaccess file, wordpress overrides it / ignores it. I've heard there's a way to do it, but the ways I try to do it base... | [
0.2825509011745453,
0.05457162857055664,
0.7382415533065796,
0.17332683503627777,
-0.2907344102859497,
-0.2165294885635376,
0.3910866677761078,
0.1799345761537552,
-0.1805862933397293,
-0.577001690864563,
0.006844142451882362,
0.25663644075393677,
-0.3199855387210846,
0.33504319190979004,
... | |
add\_rewrite\_rule() wordpress function somewhere
Has anybody had any success with these methods? or other methods?
Here's what my .htaccess file looks like
```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/ref/(.*)$ /index.php?ref=1&sid=$1 [NC]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
Rewri... | [
-0.236277773976326,
0.20638945698738098,
0.9625875353813171,
-0.31241247057914734,
0.05740200728178024,
0.28094056248664856,
0.14269544184207916,
-0.4736630916595459,
-0.12146168947219849,
-0.7651969194412231,
0.04530385509133339,
0.5118130445480347,
-0.3293948769569397,
0.0189747847616672... | |
What is the difference between Microsoft AJAx and AJAX Pro?
Also, for what should I use AJAX Pro?
Microsoft AJAX is Microsoft's Ajax library that contains ready to use server controls.
AJAX Pro is a free AJAX library, that enables you to implement your Ajax calls manually. It's a little bit difficult to use then Mic... | [
0.17950686812400818,
0.0036724135279655457,
0.12407519668340683,
0.26605403423309326,
-0.4207901358604431,
-0.201032817363739,
0.045612260699272156,
-0.11387478560209274,
0.002205868484452367,
-0.6548316478729248,
0.11919095367193222,
0.5781384110450745,
-0.4226980209350586,
-0.18715962767... | |
objects.
In Ajax Pro when you make an ajax call, only the method you defined is called. In Microsoft Ajax, whole page life-cycle called instead. Because of this, you can not change properties of controls on page with Ajax Pro. You should do it manually by callback functions in javascript. But in Microsoft AJAX, you ha... | [
-0.1083570122718811,
-0.012158026918768883,
0.4287709593772888,
0.3112662732601166,
-0.3807483911514282,
-0.00840925332158804,
0.09992940723896027,
-0.033073000609874725,
-0.4208024740219116,
-0.6339927911758423,
-0.07120858877897263,
0.48839810490608215,
-0.3575131595134735,
0.02441314421... | |
What if I have this:
```
union{
vector<int> intVec ;
vector<float> floatVec ;
vector<double> doubleVec ;
} ;
```
Of course, I'll be using just one of the 3 vectors. But... what happens when all the 3 vectors are contructed??
Would the consructors of the 3 vectors interfere with each other?? (since the... | [
-0.03155890852212906,
-0.11090081185102463,
0.41519540548324585,
-0.15400521457195282,
0.2184138298034668,
0.11501067131757736,
0.20989486575126648,
-0.6108123660087585,
-0.10007067769765854,
-0.8634158372879028,
-0.03394326567649841,
0.41239267587661743,
-0.621623694896698,
0.359410703182... | |
with destructor not allowed in union
```
New C++ standard ([C++0x](http://en.wikipedia.org/wiki/C%2B%2B0x)) proposes [unrestricted unions](http://en.wikipedia.org/wiki/C%2B%2B0x#Unrestricted_unions), but it [adds yet *more* object lifetime pitfalls to C++](http://www.informit.com/guides/content.aspx?g=cplusplus&seqNu... | [
0.49035391211509705,
-0.23479469120502472,
0.4974464476108551,
0.27174919843673706,
0.09183543920516968,
-0.1034211590886116,
-0.03949251398444176,
-0.32559671998023987,
-0.5068721771240234,
-0.19570834934711456,
-0.38501104712486267,
0.11080171167850494,
-0.40605130791664124,
0.6759809255... | |
Consider the following Cocoa/Obj-C code snippets:
```
MyClass *obj;
@try {
[obj doSomething];
}
@catch (NSException * e) {
NSLog(@"Exception occurred: %@", [e description]);
}
@finally {
[obj cleanUp];
}
```
and
```
MyClass *obj;
@try {
[obj doSomething];
}
@catch (NSException * e) {
NSLog(@"Exc... | [
0.04482477158308029,
-0.04910815507173538,
0.32385414838790894,
-0.20920157432556152,
0.06321021169424057,
-0.03451076149940491,
0.2868477404117584,
-0.15759415924549103,
-0.3565487861633301,
-0.5661169290542603,
-0.6622310876846313,
0.5640893578529358,
-0.22558565437793732,
-0.01398345828... | |
up when you either don’t catch the exception, or rethrow it, in either case leaving final exception response to calling code. Since exceptions in Cocoa are only supposed to be used for programming errors and thus occur rarely, this is an entirely reasonably thing to do.
It’s also worth pointing out one case where you ... | [
0.4042687714099884,
0.2342623770236969,
0.22322815656661987,
0.13761547207832336,
-0.08545798063278198,
-0.26131853461265564,
0.39465653896331787,
-0.03947233036160469,
-0.7011467218399048,
-0.6915512681007385,
-0.5269006490707397,
0.27283525466918945,
-0.24024119973182678,
0.1395530253648... | |
promote the exception itself out of your autorelease pool. | [
0.5577108860015869,
0.2361435741186142,
-0.43350139260292053,
0.08094577491283417,
-0.2667117118835449,
-0.4408380389213562,
0.1165761649608612,
0.7585410475730896,
0.35182732343673706,
-0.6626868844032288,
-0.24692337214946747,
0.42627090215682983,
-0.321814626455307,
-0.14645089209079742... | |
I'm very sorry for the conservative title and my question itself,but I'm lost.
The samples provided with ICsharpCode.ZipLib doesn't include what I'm searching for.
I want to decompress a byte[] by putting it in InflaterInputStream(ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream)
I found a decompre... | [
0.09637630730867386,
0.1540427803993225,
0.3755621016025543,
0.07091231644153595,
0.028510110452771187,
-0.08044108748435974,
0.39750558137893677,
-0.2765916585922241,
-0.06289862096309662,
-0.36543866991996765,
-0.09762154519557953,
0.35719069838523865,
-0.2129785567522049,
0.414280742406... | |
byte[4096];
int size;
while (true)
{
size = stream.Read(writeData, 0, writeData.Length);
if (size > 0)
{
memory.Write(writeData, 0, size);
} | [
0.05618150904774666,
-0.11876362562179565,
0.3270600736141205,
-0.2650158405303955,
0.3398904800415039,
0.2798402011394501,
0.21437488496303558,
-0.24172155559062958,
-0.3663971722126007,
-0.26527994871139526,
-0.20015530288219452,
0.6053794026374817,
-0.13356922566890717,
0.08682669699192... | |
else break;
}
stream.Close();
return memory.ToArray();
}
```
It throws an exception at line(size = stream.Read(writeData, 0, writeData.Length);) saying it has a invalid header.
My question is not how to fix the function,this function is not provided with the library,I just found it googli... | [
0.13773635029792786,
-0.08318154513835907,
0.3956262171268463,
0.033031970262527466,
0.15948335826396942,
-0.20214630663394928,
0.6892592906951904,
-0.18778488039970398,
-0.18999618291854858,
-0.29363158345222473,
-0.22900281846523285,
0.4149576723575592,
-0.48682475090026855,
0.1084162667... | |
like the data is just inappropriate, and that otherwise the code would work okay. (Admittedly I'd use a "using" statement for the streams instead of calling `Close` explicitly.)
Where did you get your data from? | [
0.9850476980209351,
-0.055416401475667953,
0.019651757553219795,
0.24691122770309448,
0.3202912509441376,
-0.22698794305324554,
0.2816264033317566,
0.25180405378341675,
-0.10768353939056396,
-0.0225849412381649,
-0.021318599581718445,
0.11608927696943283,
-0.14158308506011963,
-0.138799116... | |
Is there any way I can set the default ModelBinder to one of my own?
```
ModelBinders.Binders.DefaultBinder = new MyOwnModelBinder();
``` | [
-0.039496153593063354,
0.09373804181814194,
0.5780313014984131,
-0.08252012729644775,
0.353752464056015,
-0.19632914662361145,
0.15024052560329437,
0.05358634889125824,
-0.24137257039546967,
-0.8286074995994568,
0.05174703523516655,
0.7810944318771362,
-0.3532789349555969,
0.33190017938613... | |
Okay, so ASP.net allows one to embed Images into an Assembly and access them using WebResource.axd.
I just wonder: What are the Pros/Cons of using Web Resources instead of Images in a folder on the Web Server, like how it's being traditionally done?
[This article](https://web.archive.org/web/20211020131200/https://ww... | [
0.5656890869140625,
-0.23305410146713257,
0.2130129635334015,
0.22088316082954407,
-0.10331425070762634,
-0.08487502485513687,
0.11949969828128815,
-0.10019798576831818,
-0.6187812089920044,
-0.7010284662246704,
-0.004051439929753542,
0.4901595115661621,
-0.19056512415409088,
-0.0330998636... | |
web controls that you will be using across different web sites. | [
0.4997064769268036,
-0.1551530361175537,
0.5146976113319397,
0.4578608572483063,
0.22328037023544312,
-0.21745431423187256,
-0.1332719475030899,
-0.09757762402296066,
-0.4541653096675873,
-0.8911516666412354,
-0.06884569674730301,
0.24506409466266632,
-0.25519758462905884,
0.18511538207530... | |
I have coded three select statements in stored procedure in Microsoft SQL Server 2005. Both select statements return multiple number of records and table list for select statements is different. One select records from a master table and the other from a child table. In C# code I want to get all these records and put a... | [
0.07317200303077698,
-0.002989639528095722,
0.26092252135276794,
0.07535843551158905,
-0.08214031904935837,
0.20792078971862793,
0.17488116025924683,
-0.46320050954818726,
-0.19724123179912567,
-0.683711051940918,
0.13475275039672852,
0.23320923745632172,
-0.38927796483039856,
0.0513084679... | |
like this:
```
var moreResults = true;
while (moreResults)
{
while (reader.Read())
{
...
}
moreResults = reader.NextResult();
}
```
So with that as a background, and assuming the master resultset comes first, populating master and detail objects could be done like this:
First, build up a diction... | [
-0.050898291170597076,
-0.14911697804927826,
0.6943849325180054,
0.14536075294017792,
0.237727552652359,
0.08645978569984436,
-0.001236590789631009,
-0.6318652629852295,
-0.0961257815361023,
-0.9664766192436218,
-0.28315725922584534,
0.7279978394508362,
-0.21756963431835175,
0.350933104753... | |
var masterId = reader.GetInt32(masterIdOrdinal);
var master = masters[masterId];
master.Details.Add(new Detail{....});
}
```
You should obviously replace column names with what you have in your data as well as supply the full initialization of Master and Detail objects.
If the detail resultset is sorted on ... | [
0.13598395884037018,
-0.2204006314277649,
0.34065648913383484,
0.0004975462215952575,
0.044614389538764954,
0.04616353660821915,
0.2315552681684494,
-0.5325795412063599,
-0.12440459430217743,
-0.9348980188369751,
0.06746302545070648,
0.6012687683105469,
-0.18604084849357605,
0.268587261438... | |
I'm teaching myself VB.Net.
Here is a problem I have recently come across. Say I have a main Form1 in my application. Form1 calls a second LoginForm which (like the name suggests) is a login window with username/password type fields. Expected behaviour is that LoginForm will capture login details and pass them back to... | [
0.3967423141002655,
-0.0889580100774765,
0.32118651270866394,
-0.025431599467992783,
-0.12645724415779114,
-0.4472762644290924,
0.15675088763237,
0.1971903145313263,
-0.2855289876461029,
-0.9194676280021667,
-0.01752614602446556,
0.317977637052536,
-0.2831534743309021,
0.2214277982711792,
... | |
I don't see this as being possible
What I have currently is less elegant. LoginForm is shown by Form1 modally (i.e. showDialog); a 'me' reference is passed to the second window. After user input has been received on LoginForm, I set a value on Form1, then dispose.
Is this the way everybody does it?
I've always passe... | [
0.34208786487579346,
-0.203293114900589,
0.4968585968017578,
0.02812519669532776,
-0.11414908617734909,
-0.25138622522354126,
0.05475595220923424,
-0.15017648041248322,
-0.3194867968559265,
-1.023719072341919,
-0.18166321516036987,
0.17631001770496368,
-0.3980305790901184,
-0.0012933386024... | |
click event handler, instantiate the Form2 class and Form1's delegate. Assign a function of Form2 to the delegate, and call the delegate:
```
'Form1.vb
Public Delegate Sub delPassData(ByVal text As TextBox)
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
D... | [
-0.21839945018291473,
-0.4299999475479126,
0.7645075917243958,
-0.0429314449429512,
-0.051197342574596405,
-0.03514166176319122,
0.06504413485527039,
-0.402515172958374,
-0.24026063084602356,
-0.4323582053184509,
-0.4933042526245117,
0.48549360036849976,
-0.4053732454776764,
0.114154562354... | |
that returns the values you want. | [
0.3029440939426422,
0.33299893140792847,
0.022619441151618958,
0.32740065455436707,
0.06359844654798508,
-0.12957045435905457,
-0.0759216845035553,
0.07032439857721329,
0.0846245288848877,
-0.4135044515132904,
-0.267803430557251,
0.7451266646385193,
0.06929139047861099,
0.11989908665418625... | |
What's the best method to switch between forms in C# ?
Scenario: I want to click a button in a Form1, kill the existing Form1 and create Form2.
How can I achieve this ?
I would much appreciate it, if someone could even compare the complexity of this task in Winforms vs WPF.
The easiest way to do this is to have a con... | [
0.4061678647994995,
-0.2387768030166626,
0.4620583653450012,
-0.19423671066761017,
0.20199419558048248,
-0.19846805930137634,
0.17335133254528046,
-0.1957022249698639,
-0.06163090094923973,
-0.7093578577041626,
-0.2760498821735382,
0.48376548290252686,
-0.4631299376487732,
-0.0731986761093... | |
form2.ShowDialog();
}
```
The code for WPF is similar. The biggest difference is that WPF windows (and pretty much all classes as a rule) do not implement IDisposable and hence do not require the using statement.
```
var win1 = new Window1();
win1.ShowDialog();
var win2 = new Window2();
win2.ShowDialog();
``` | [
0.20138472318649292,
-0.16798603534698486,
0.44205906987190247,
-0.20364296436309814,
-0.07257138192653656,
-0.3712737560272217,
0.3970891237258911,
-0.3079703152179718,
-0.02778463438153267,
-0.7258589267730713,
-0.34008195996284485,
0.408667653799057,
-0.6074894070625305,
0.0795629993081... | |
Recently I changed a few nested resources in one of my applications to use shallow routing. It's working great and I've been able to simplify my views and controllers.
However, I've been using a path\_prefix before:
```
map.with_options :path_prefix => "blog" do |blog|
blog.resources :posts do |posts|
posts.res... | [
0.18050311505794525,
-0.24144712090492249,
0.41170740127563477,
0.216270312666893,
-0.19409863650798798,
-0.1687067300081253,
0.24684765934944153,
-0.023252839222550392,
-0.043919242918491364,
-0.8896650075912476,
0.26796257495880127,
0.3987751603126526,
-0.00516614131629467,
0.27644768357... | |
{:controller=>"posts", :action=>"index"}
# POST /blog/posts(.:format) {:controller=>"posts", :action=>"create"}
# new_post GET /blog/posts/new(.:format) | [
0.18495267629623413,
-0.6239614486694336,
0.5819166898727417,
0.4812834560871124,
-0.14629004895687103,
-0.23237916827201843,
-0.07304056733846664,
-0.2946605384349823,
-0.4594087302684784,
-0.7123094201087952,
-0.22626465559005737,
0.28970903158187866,
-0.4305265545845032,
0.3085572421550... | |
{:controller=>"posts", :action=>"new"}
# edit_post GET /blog/posts/:id/edit(.:format) {:controller=>"posts", :action=>"edit"}
# post GET /blog/posts/:id(.:format) {:controller=>"posts", :action=>"show"}
# PUT | [
0.5056946873664856,
-0.6379348039627075,
0.31821954250335693,
0.2223471999168396,
-0.39303067326545715,
-0.0537874698638916,
-0.05495385453104973,
-0.2968390882015228,
-0.15016959607601166,
-0.5176002383232117,
-0.3009738028049469,
0.2756962180137634,
-0.23456504940986633,
0.02337408065795... | |
/blog/posts/:id(.:format) {:controller=>"posts", :action=>"update"}
# DELETE /blog/posts/:id(.:format) {:controller=>"posts", :action=>"destroy"}
# post_comments GET /blog/posts/:post_id/comments(.:format) {:controller=>"comments", :action=... | [
0.1910746991634369,
-0.36778774857521057,
0.5097596049308777,
0.4390360414981842,
-0.21274138987064362,
-0.1457478404045105,
0.10646536946296692,
-0.15731389820575714,
-0.22888065874576569,
-0.7616637349128723,
-0.33241164684295654,
0.48685649037361145,
-0.44910672307014465,
0.102189458906... | |
POST /blog/posts/:post_id/comments(.:format) {:controller=>"comments", :action=>"create"}
# new_post_comment GET /blog/posts/:post_id/comments/new(.:format) {:controller=>"comments", :action=>"new"}
# edit_post_comment GET /blog/posts/:post_id/comments/:id/edit(.:format) {:controller=>"comments",... | [
0.3968092203140259,
-0.3923894464969635,
0.5791664719581604,
0.1923452764749527,
-0.47507256269454956,
0.09451112896203995,
-0.07006777822971344,
-0.277631014585495,
-0.1637985110282898,
-0.7486013770103455,
-0.33357101678848267,
0.2821105122566223,
-0.43791699409484863,
0.0484957508742809... | |
DELETE /blog/posts/:post_id/comments/:id(.:format) {:controller=>"comments", :action=>"destroy"}
```
The new routing configuration looks like this:
```
map.with_options :path_prefix => "blog", :shallow => true do |blog|
blog.resources :posts do |posts|
posts.resources :comments
end
end
```
Now, the "/... | [
0.11620458215475082,
-0.5240855813026428,
0.558590292930603,
0.2941977381706238,
0.04884250834584236,
-0.2699083387851715,
0.4540662169456482,
-0.1264149397611618,
-0.23681776225566864,
-0.9986448287963867,
0.044298626482486725,
0.33064427971839905,
-0.28161346912384033,
0.4003535211086273... | |
POST /blog/posts(.:format) {:controller=>"posts", :action=>"create"}
# new_post GET /blog/posts/new(.:format) {:controller=>"posts", :action=>"new"}
# edit_post GET /posts/:id/edit(.:format) {:controller=>"posts", :action=>"edit"}
# | [
0.3489338755607605,
-0.3535037338733673,
0.507352352142334,
0.36376404762268066,
-0.272153377532959,
-0.01316482201218605,
-0.05872941017150879,
-0.30216461420059204,
-0.22604675590991974,
-0.8157303929328918,
-0.21981270611286163,
0.13720406591892242,
-0.3729451596736908,
0.23200803995132... | |
post GET /posts/:id(.:format) {:controller=>"posts", :action=>"show"}
# PUT /posts/:id(.:format) {:controller=>"posts", :action=>"update"}
# DELETE /posts/:id(.:format) | [
0.4205925166606903,
-0.5979591608047485,
0.4743403494358063,
0.24768362939357758,
-0.37648701667785645,
-0.059330906718969345,
0.18484114110469818,
-0.12518653273582458,
0.1074935719370842,
-0.5307489633560181,
-0.24806421995162964,
0.08288883417844772,
-0.3178844749927521,
0.0753363743424... | |
{:controller=>"posts", :action=>"destroy"}
# post_comments GET /posts/:post_id/comments(.:format) {:controller=>"comments", :action=>"index"}
# POST /posts/:post_id/comments(.:format) {:controller=>"comments", :action=>"create"}
# new_post_comment GET /posts/:post_id/comments/new(.:f... | [
0.08050642907619476,
-0.46179741621017456,
0.42555704712867737,
0.46040940284729004,
-0.28233569860458374,
-0.10484950244426727,
0.03638659045100212,
-0.4950725734233856,
-0.3161380887031555,
-0.830199122428894,
-0.3675568997859955,
0.48468130826950073,
-0.3527500033378601,
0.1010729447007... | |
/comments/:id(.:format) {:controller=>"comments", :action=>"show"}
# PUT /comments/:id(.:format) {:controller=>"comments", :action=>"update"}
# DELETE /comments/:id(.:format) {:controller=>"comments", :action=>"destroy"}
```
I'm looking... | [
0.14452219009399414,
-0.2652722895145416,
0.34786221385002136,
0.22967465221881866,
-0.021156439557671547,
-0.056511297821998596,
0.20162418484687805,
-0.2921821177005768,
-0.14949148893356323,
-0.796286940574646,
-0.28208181262016296,
0.3296436071395874,
-0.474799782037735,
0.250528901815... | |
the prefixes back for all routes. I know that it's working with namespaces (`map.namespace :blog do`), but I want to prevent refactoring all my controllers/views/tests to actually use namespaces.
All code samples are tested with Rails version 2.3.2 and Ruby 1.8.7.
the documentation seems to indicate this exact behavio... | [
0.16352254152297974,
-0.12797774374485016,
0.2050405740737915,
0.047433510422706604,
-0.13348087668418884,
-0.0254486296325922,
0.6010306477546692,
-0.18838350474834442,
0.05385391414165497,
-0.6200790405273438,
0.21676552295684814,
0.46596840023994446,
-0.21810322999954224,
-0.08381166309... | |
prefix you should consider removing the :shallow option. Here's an alternate solution that appears to do what you need:
```
map.with_options :path_prefix => "blog" do |blog|
blog.resources :posts do |posts|
posts.resources :comments, :only => [:index, :create, :new]
end
blog.resources :comments, :except => [... | [
-0.009206646122038364,
-0.13436086475849152,
0.5379937291145325,
0.25621289014816284,
-0.23701925575733185,
0.11701583117246628,
0.4622980058193207,
-0.10543206334114075,
-0.20662254095077515,
-0.9351689219474792,
-0.07981904596090317,
0.4246055483818054,
-0.1563146412372589,
-0.0055934144... | |
{:controller=>"posts", :action=>"index"}
# POST /blog/posts {:controller=>"posts", :action=>"create"}
# new_post GET /blog/posts/new {:controller=>"posts", :action=>"new"}
# | [
0.09886582940816879,
-0.6014999151229858,
0.517234206199646,
0.3885335326194763,
-0.19464683532714844,
-0.08601091057062149,
0.12617841362953186,
-0.27554231882095337,
-0.5144064426422119,
-0.8469834327697754,
-0.18156948685646057,
0.29892081022262573,
-0.40961945056915283,
0.4082259535789... | |
edit_post GET /blog/posts/:id/edit {:controller=>"posts", :action=>"edit"}
# post GET /blog/posts/:id {:controller=>"posts", :action=>"show"}
# | [
0.22291159629821777,
-0.4427214562892914,
0.5418146848678589,
0.2951093912124634,
-0.38971012830734253,
-0.15488438308238983,
0.05404651537537575,
-0.13924098014831543,
-0.16038374602794647,
-0.4231264591217041,
-0.25987306237220764,
0.1158253476023674,
-0.5199856758117676,
0.0899292975664... | |
PUT /blog/posts/:id {:controller=>"posts", :action=>"update"}
# DELETE /blog/posts/:id {:controller=>"posts", :action=>"destroy"}
# post_comments GET /blog/posts/:post_id/comments | [
0.49072712659835815,
-0.43472546339035034,
0.07182104885578156,
0.15152239799499512,
-0.1641928106546402,
0.0651075541973114,
0.25019243359565735,
-0.1442565619945526,
-0.13976383209228516,
-0.8238564133644104,
-0.3276602625846863,
0.35555222630500793,
-0.3588115870952606,
0.10076607018709... | |
{:controller=>"comments", :action=>"index"}
# POST /blog/posts/:post_id/comments {:controller=>"comments", :action=>"create"}
# new_post_comment GET /blog/posts/:post_id/comments/new {:controller=>"comments", :action=>"new"}
# edit_comment GET /blog/comments/:id/edit ... | [
-0.010487737134099007,
-0.48505866527557373,
0.3818584680557251,
0.3810867667198181,
-0.2592187523841858,
0.055320098996162415,
-0.06588175892829895,
-0.3659622371196747,
-0.4794227182865143,
-0.7767413854598999,
-0.1548110991716385,
0.3512512743473053,
-0.5125678181648254,
0.1427238583564... | |
comment GET /blog/comments/:id {:controller=>"comments", :action=>"show"}
# PUT /blog/comments/:id {:controller=>"comments", :action=>"update"}
# DELETE /blog/comments/:id | [
0.39766576886177063,
-0.5122489333152771,
0.3039988577365875,
0.22958779335021973,
-0.4011678099632263,
-0.11297940462827682,
0.09744701534509659,
0.027912549674510956,
-0.06620349735021591,
-0.589566171169281,
-0.2966330945491791,
0.5107940435409546,
-0.4158746600151062,
0.005728621501475... | |
{:controller=>"comments", :action=>"destroy"}
```
Hope this helps! | [
0.23196396231651306,
0.00949356984347105,
0.2210887223482132,
0.22507242858409882,
0.18734973669052124,
-0.503566324710846,
0.37608566880226135,
0.1506539285182953,
-0.06918524205684662,
-0.7363390326499939,
-0.23030370473861694,
0.42638346552848816,
-0.28102192282676697,
0.124018803238868... | |
I want to make a section in my site where visitors can upload files (pdfs). How can this be done?
Also, after the pdf is uploaded, I need a link to that file. Rather than using a boring text link, I was thinking of having a thumbnail graphic of the first page of the pdf. Is there a tool out there that does this?
For ... | [
0.5000852942466736,
-0.2541438937187195,
0.43878257274627686,
0.1662178784608841,
-0.4656827747821808,
-0.37344568967819214,
-0.014165608212351799,
-0.14323027431964874,
-0.6136478781700134,
-0.6376121640205383,
-0.08723976463079453,
0.4706133008003235,
-0.10803305357694626,
0.036573171615... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.