pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
19,619,850 | 0 | <p>You could use a dictionary with a key that indicates your command and an anonymous method that holds the to be executed command. For performance you better refactor the Dictionary to be static and only instantiated once but this gives you the general idea.</p> <pre><code>void Engine_SpeechRecognized (object sender, SpeechRecognizedEventsArgs e) { var commands = new Dictionary<string, Action<string>>(); commands.Add( "search google", (arg) => { Search(arg); }) ; commands.Add( "open application", (arg) => { OpenApp( "https://www.google.com/#q=" + arg); }) ; foreach(var command in commands.Keys) { if (e.Result.Text.StartsWith(command)) { Action(command, e.Result.Text, commands[command]); } } } /* helper for getting one point for an arguments extractor */ static void Action(string cmd,string all, Action<string> act) { string args = all.Replace(cmd,""); act(args); } </code></pre> |
35,416,133 | 0 | <p>Change the module script to remove the reference to material.svgAssetsCache and the demo will run but without the final row of buttons - which reference "local" image resources.</p> <p>If you grab a copy of the icons(<strong>bower install material-design-icons</strong>) and locate the relevant 24px .svg files and pop them in (say) /img/icons/ from the root of your web site (adjusting file names and path as required) then even this section will work just fine. </p> <p>The demo is rather off-putting when you think about it as it is likely to be chosen as a first stab at trying things out yet it only works within the CodePen sand-tray.</p> |
8,447,944 | 0 | How can you universally override the get and post methods in RSpec? <p>I'd like to override the <code>get</code> and <code>post</code> methods in RSpec. </p> <p>I want to do this in order to deal with subdomains in my tests. As far as I can tell, the only way to deal with subdomains is to alter the <code>@request</code> object before each call. I could do this before each and every test but that's going to lead to some really messy code.</p> <p>In an effort to keep things DRY I've tried using a <code>config.before(:each)</code> method in <code>spec_helper.rb</code> however this doesn't seem to be run in the same scope as the test and doesn't have access to <code>@request</code>.</p> <p>My next bsest approach is therefore to overrride <code>get</code> and <code>post</code> which are in the correct scope.</p> <pre><code>def get *args @request.host = @required_domain if @required_domain super *args end </code></pre> <p>I can include this code in the top of each spec file but I'd rather set it universally. If I set it in <code>spec_helper.rb</code> though it does not get called. </p> <p>Where can I set this to override the default <code>get</code> method?</p> |
14,593,400 | 0 | |
9,274,522 | 0 | animate to light yellow then back to white? jQUery <p>i am trying to make my ul li's background color to turn yellow then back to white . i use the code below but it's not working.</p> <pre><code>$('#items ul li.test').animate({ 'background-color' : '#FFFEBC' }, 3000, function(){ $('#items ul li.test').animate({ 'background-color' : '#ffffff' }, 3000); }); </code></pre> <p>I have included jQuery library of course , and this code is triggered by another function. the function works but not the animate.</p> <p><code>.test</code> is the <code>ul li</code> class.</p> <p>Is there any problem with the code??</p> |
36,232,930 | 0 | C# saved folder downloaded from Google drive cannot access in visual studio <p>Good day. After i finished my practical class in school, i will upload the whole saved folder to google drive for me to revise at home. However, when i re-download the whole file from google drive at home, i couldn't open it on visual studio 2013, the whole file is just become different.</p> <p>This is when u saved it in computer <img src="https://i.stack.imgur.com/qHhxs.png" alt="This is when u saved it in computer"></p> <p>This is after u re-download from google drive <img src="https://i.stack.imgur.com/yE15P.png" alt="This is after u re-download from google drive"></p> <p>Is there any ways i can open back my work ?</p> |
25,134,439 | 0 | <p>No , dont do that . loading remote website will not able to intract with your plugins . and the app will get rejected on istore too</p> |
5,493,291 | 0 | <p>You can't directly call <code>click</code> on something in the control. However, you can register some JavaScript into the control and perform the click that way.</p> <p>See <a href="http://stackoverflow.com/questions/153748/how-to-inject-javascript-in-webbrowser-control">How to inject Javascript in WebBrowser control?</a> for details.</p> |
39,763,927 | 0 | <p>Instead of using the style attribute as mentioned by RaMeSh, I would use a css attribute. That's simply cleaner.</p> <pre><code>if(logged_in === true) { echo '<a class="hidden" href="/login"><img style="margin-top:1px;" src="/template/img/sits_01.png"></a>' } else { echo '<a href="/login"><img style="margin-top:1px;" src="/template/img/sits_01.png"></a>' } </code></pre> <p>And in your style.css</p> <pre><code>.hidden { opacity: 0; } </code></pre> <p>Always try to avoid the <code>style</code> attribute if not 100% necessary. It makes your code less futureproof and terrible to work if you have to work with it ever again.</p> |
28,469,210 | 0 | <p>You can use the <code>Windows.Web.Http.HttpClient</code> instead of <code>System.Net.Http.HttpClient</code>, i.e.:</p> <pre><code>HttpClient _httpClient = new HttpClient(); bool result = _httpClient.DefaultRequestHeaders.TryAppendWithoutValidation("Accept", "vnd.servicehost.v1+json"); var response = await _httpClient.GetAsync(uri); </code></pre> |
834,973 | 0 | <p>Help -> About Microsoft Visual Studio</p> |
21,450,810 | 0 | <p>Try to define outputRowId as ParameterDirection.InputOutput</p> |
18,923,384 | 0 | <p>The cause of the problem is twofold:</p> <ol> <li>In your module you have a behaviour declaration <code>-behaviour(cowboy_http_handler).</code>. This is perfectly correct.</li> <li>When you compile the file the compiler can't find the <code>cowboy_http_handler</code> module in its search path</li> </ol> <p>This causes the error as the behaviour declaration tells the compiler to go out and find that module and find out which callback functions the behaviour expects. Normally if the compiler can't find the behaviour module, or if it can find and there are some callbacks missing then it issues a warning about this and just continues. However your Makefile sets a compiler option which treats all warnings as errors so the compilation fails.</p> <p>There are (at least) three solutions to this:</p> <ol> <li>Remove the compiler option and accept you get a warning.</li> <li>Make sure the compiler can find the behaviour module and do the checking. A simple way of doing is to add a <code>-pa Dir</code> option for the cowboy beam file directory so it can find the file.</li> <li>Set up Erlang so that it automatically finds the cowboy directory, for example with <code>$ERL_LIBS</code>.</li> </ol> <p>Note that even if the compiler finds the right module you still have to make sure that when you run the system Erlang can find the directory. There is no automatic equivalence between the compile-time and run-time environments.</p> |
12,340,411 | 0 | Vibrate iphone when phone is silent <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/11770566/vibrate-command-only-works-when-settings-sounds-vibrate-switch-is-on">Vibrate command only works when Settings > Sounds > Vibrate switch is on</a> </p> </blockquote> <p>im working on an app where the phone vibrates when you press a certain button. I have it working but it only works when the phone is not on silent. Im using the AudioToolbox/AudioServices.h framework. Ive been look for a solution for a over an hour and a half now. Any ideas on what todo?</p> |
5,178,286 | 0 | <p>I guess that's pretty much PHP syntax question rather than PDO one.</p> <pre><code>$params = is_array($params) ? $params : array($params); </code></pre> <p>is a shortland (called <em>ternary operator</em>)) for </p> <pre><code>if (is_array($params)) { $params = $params; } else { $params = array($params); } </code></pre> <p>which I'd rather wrote as </p> <pre><code>if (!is_array($params)) $params = array($params); </code></pre> <p>which is pretty self-explanatory and can be read almost in plain English: </p> <blockquote> <p>if $params is not an array, let's make it array with one value of former $params</p> </blockquote> <p>That's why I hate ternary operator (and lambdas) and always avoid it's use. It makes pretty readable code into a mess. Just out of programmer's laziness.</p> <p>To answer your other questions,</p> <blockquote> <p>Does it meant that I don't have to prepare the query in this way anymore?</p> </blockquote> <p>Who said that? You're preparing it all right in your code, check it again.</p> <blockquote> <p>and forget about this binding?</p> </blockquote> <p>that's true. <code>execute($params)</code> is just another way to bind variables. </p> |
29,887,810 | 0 | <p>In case somebody is facing a similar problem: I was finally able to overcome the issue described above by setting the <code>android:launchMode</code> property for the <code>MainActivity</code> to <code>singleInstance</code>.</p> |
1,225,465 | 0 | Callbacks in Linq-to-SQL/ASP.NET MVC <p>After using .NET for several years, I've spent the last few months in the far off land of Ruby on Rails. While I can clearly see where much of Microsoft's MVC framework got it's influence, one of the things that I find myself suddenly missing when development in .NET are the Rails Model callbacks.</p> <p>Specifically, you can add a callback to <code>before_save, after_save, before_create, after_create</code>, etc. and then specify a function to be called at those points in execution (which seems very similar to aspect oriented programming).</p> <p>My question is, out of the box, does .NET 3.5/ASP.NET MVC offer anything similar to the callbacks in Rails? For example, if I have an <code>inserted_datetime</code> and <code>updated_datetime</code> column on one of my database tables, instead of making sure those columns get updated in the controller, I'd like to be able to tell my model that every time the "Group" object gets saved to the database, update the <code>updated_datetime</code> column.</p> <p>Is this possible? Does this question even make sense?</p> |
39,136,166 | 0 | <p>Did you try this?</p> <pre><code>console.log(recordsets[0][0][" "]) </code></pre> <p>Or maybe another way if you know for sure that the stored procedure will give you only one result is converting the object into an array and checking first element:</p> <pre><code>var raw = recordsets[0][0] var result = Object.keys(raw).map(k => raw[k])[0] console.log(result) </code></pre> |
32,109,187 | 0 | <pre><code> <form ng-submit="search()" name="searchSideNav"> <div layout="column" layout-align="center"> <md-input-container flex> <label>{{::labels.documentName}}</label> <input ng-model="searchItems.sDocumentName" ng-required="" name="sDocumentName"> <div ng-show="searchSideNav.sDocumentName.$invalid && !searchSideNav.sDocumentName.$pristine"> <p ng-show="searchSideNav.sDocumentName.$error.required" class="help-block">Document is required</p> </div> </md-input-container> <md-button ng-disabled="searchSideNav.$invalid"> Submit </md-button> </div> </form> </code></pre> |
12,990,449 | 0 | Binding to DependencyProperty with no result <p>I have problem with binding to dependency property of my new control.<br> I decided to write some tests to examine this issue.<br></p> <p><strong>Binding from TextBox.Text to another TextBox.Text</strong></p> <p>XAML code:</p> <pre><code><TextBox Name="Test" Text="{Binding ElementName=Test2, Path=Text, UpdateSourceTrigger=PropertyChanged}" /> <TextBox Name="Test2" Grid.Row="2" /> </code></pre> <p>The result is good - when I writing something in first TextBox -> second TextBox is updating (conversely too).</p> <p><img src="https://i.stack.imgur.com/i5TzV.png" alt="enter image description here"></p> <p>I created new control -> for example "SuperTextBox" with dependency property "SuperValue".</p> <p>Control XAML code:</p> <pre><code><UserControl x:Class="WpfApplication2.SuperTextBox" ... Name="Root"> <TextBox Text="{Binding SuperValue, ElementName=Root, UpdateSourceTrigger=PropertyChanged}" /> </UserControl> </code></pre> <p>Code behind:</p> <pre><code>public partial class SuperTextBox : UserControl { public SuperTextBox() { InitializeComponent(); } public static readonly DependencyProperty SuperValueProperty = DependencyProperty.Register( "SuperValue", typeof(string), typeof(SuperTextBox), new FrameworkPropertyMetadata(string.Empty) ); public string SuperValue { get { return (string)GetValue(SuperValueProperty); } set { SetValue(SuperValueProperty, value); } } } </code></pre> <p>Ok, and now tests!</p> <p><strong>Binding from TextBox.Text to SuperTextBox.SuperValue</strong></p> <pre><code> <TextBox x:Name="Test1" Text="{Binding ElementName=Test2, Path=SuperValue, UpdateSourceTrigger=PropertyChanged}" /> <local:SuperTextBox x:Name="Test2" Grid.Row="2"/> </code></pre> <p>Test is correct too! When I writing something in TextBox, SuperTextBox is updating. When i writing in SuperTextBox, TextBox is updating. All is ok!</p> <p>Now a problem:<br> <strong>Binding from SuperTextBox.SuperValue to TextBox.Text</strong></p> <pre><code> <TextBox x:Name="Test1"/> <local:SuperTextBox x:Name="Test2" SuperValue="{Binding ElementName=Test1, Path=Text, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2"/> </code></pre> <p>In this case, when I writing something in SuperTextBox, TextBox is not updating! <img src="https://i.stack.imgur.com/eqSJP.png" alt="enter image description here"></p> <p>How can I fix this?</p> <p>PS: Question is very very long, I am sorry for that, but i tried exactly describe my problem.</p> |
31,763,006 | 0 | Moving whole row between two tables <p>I have to tables with identical structure, client_data, new_client_data. Now I want to move whole one row from one table to another. I've found a way to do it, it`s working fine, but I'm wondering if there is more elegant and clean way to do it.</p> <p>new_client_data / controller:</p> <pre><code>public function actionPromotion($id) + { + $model = $this->findModel($id); + + $clientData = new ClientData; + $newClientNumber = $clientData->setNewClientNumber(); + + $clientContacts = new OClientContacts; + + + if ($model->load(Yii::$app->request->post())) { + if($this->moveToClients(Yii::$app->request->post(), $model->id) & $clientContacts->moveContacts($id)){ + return $this->redirect(['index']); + } else { + return $this->render('promprep', [ + 'model' => $model, + 'newClientNumber' => $newClientNumber, + ]); + } + } else { + return $this->render('promprep', [ + 'model' => $model, + 'newClientNumber' => $newClientNumber, + ]); + } + } </code></pre> <p>It's basic controller method build from standard actionUpdate. If user will submit all post data correctly then function is passing all post data to another method in that controller. ( also i`m wondering if shouldn't place in model instead).</p> <pre><code>+ public function moveToClients($post, $id){ + $ClientData = new ClientData; + + $ClientData->name = $post['OClientData']['name']; + $ClientData->clientNumber = $post['OClientData']['clientNumber']; + $ClientData->abr= $post['OClientData']['abr']; + $ClientData->adress = $post['OClientData']['adress']; + $ClientData->city = $post['OClientData']['city']; + $ClientData->postal = $post['OClientData']['postal']; + $ClientData->phone = $post['OClientData']['phone']; + $ClientData->fax = $post['OClientData']['fax']; + $ClientData->email = $post['OClientData']['email']; + $ClientData->nip = $post['OClientData']['nip']; + $ClientData->krs = $post['OClientData']['krs']; + $ClientData->regon = $post['OClientData']['regon']; + $ClientData->www = $post['OClientData']['www']; + $ClientData->description = $post['OClientData']['description']; + $ClientData->isNewRecord = true; + $ClientData->id = null; + + if($ClientData->save()){ + $this->actionDelete($id); + return true; + } + return false; + + } </code></pre> <p>My question is: "Is there a way to do this in more elegant way?";</p> <p>Edit. Question: "Should this <code>moveToClients</code> method land in the controller?";</p> |
6,305,270 | 0 | DevExpress ASPxComboBox not filtering <p>I have an ASPxComboBox from the DevExpress suite and am trying to get it filtered. If I click on the dropdown button of the combo box it will show the first few of the query as if the filter is empty.</p> <p>If I try to populate the filter, or scroll down to see more, it will just provide a perpetual "Loading" state. The stored procedure returns the correct results when ran with appropriate parameters. What could be the problem?</p> <p>EDIT: I have been following this tutorial on the DevExpress site: <a href="http://demos.devexpress.com/ASPxEditorsDemos/ASPxComboBox/LargeDataSource.aspx" rel="nofollow">http://demos.devexpress.com/ASPxEditorsDemos/ASPxComboBox/LargeDataSource.aspx</a></p> <p>EDIT (again): OK if I remove the line: </p> <pre><code><ClientSideEvents BeginCallback="function(s, e) { OnBeginCallback(); }" EndCallback="function(s, e) { OnEndCallback(); } " /> </code></pre> <p>from the combo box it will hit a break point in <code>cboInstructor_OnItemsRequestedByFilterCondition_SQL</code>, but on going to the <code>DataBind()</code> it will thorw the error:</p> <blockquote> <p>Index (zero based) must be greater than or equal to zero and less than the size of the argument list.</p> </blockquote> <p>ASP file</p> <pre><code><form id="form1" runat="server"> <div> <dxe:ASPxComboBox ID="cboInstructor" runat="server" Width="100%" EnableCallbackMode="True" CallbackPageSize="10" IncrementalFilteringMode="Contains" ValueType="System.Int32" ValueField="employee_id" OnItemsRequestedByFilterCondition="cboInstructor_OnItemsRequestedByFilterCondition_SQL" OnItemRequestedByValue="cboInstructor_OnItemRequestedByValue_SQL" TextFormatString="{1} {2}" DropDownStyle="DropDown" DataSourceID="SqlDataSourceInstruct" > <Columns> <dxe:ListBoxColumn FieldName="display_forename" /> <dxe:ListBoxColumn FieldName="display_surname" /> </Columns> <ClientSideEvents BeginCallback="function(s, e) { OnBeginCallback(); }" EndCallback="function(s, e) { OnEndCallback(); } " /> </dxe:ASPxComboBox> <asp:SqlDataSource ID="SqlDataSourceInstruct" runat="server" ConnectionString="Server=160.10.1.25;User ID=root;Password=password;Persist Security Info=True;Database=central" ProviderName="MySql.Data.MySqlClient" SelectCommand="GetUser" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:Parameter Name="filter" Type="String" /> <asp:Parameter Name="startIndex" Type="Int32" /> <asp:Parameter Name="endIndex" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> </div> </form> </code></pre> <p>CS file</p> <pre><code>public partial class TestComboBox : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void cboInstructor_OnItemsRequestedByFilterCondition_SQL(object source, ListEditItemsRequestedByFilterConditionEventArgs e) { ASPxComboBox comboBox = (ASPxComboBox)source; //SqlDataSourceInstruct.SelectCommand = // @"SELECT CONCAT(display_Forename, ' ', display_Surname) FROM (SELECT employee_id, display_forename , display_surname, @rownum:=@rownum+1 AS rn FROM central.user_record, (SELECT @rownum:=0) AS r WHERE CONCAT(display_forename, ' ', display_surname) LIKE @filter ORDER BY display_surname ASC) AS st where st.rn between @startIndex and @endIndex"; SqlDataSourceInstruct.SelectParameters.Clear(); SqlDataSourceInstruct.SelectParameters.Add("filter", TypeCode.String, string.Format("%{0}%", e.Filter)); SqlDataSourceInstruct.SelectParameters.Add("startIndex", TypeCode.Int64, (e.BeginIndex + 1).ToString()); SqlDataSourceInstruct.SelectParameters.Add("endIndex", TypeCode.Int64, (e.EndIndex + 1).ToString()); //comboBox.DataSource = SqlDataSourceInstruct; comboBox.DataBind(); } protected void cboInstructor_OnItemRequestedByValue_SQL(object source, ListEditItemRequestedByValueEventArgs e) { long value = 0; if (e.Value == null) return; if (!Int64.TryParse(e.Value.ToString(), out value)) return; ASPxComboBox comboBox = (ASPxComboBox)source; SqlDataSourceInstruct.SelectCommand = @"SELECT employee_id, display_surname, display_forename FROM central.user_record WHERE (employee_id = @ID) ORDER BY display_forename"; SqlDataSourceInstruct.SelectParameters.Clear(); SqlDataSourceInstruct.SelectParameters.Add("ID", TypeCode.Int64, e.Value.ToString()); comboBox.DataSource = SqlDataSourceInstruct; comboBox.DataBind(); } } </code></pre> <p>MySQL stored procedure</p> <pre><code>DELIMITER $$ USE `central`$$ DROP PROCEDURE IF EXISTS `GetUser`$$ CREATE DEFINER=`root`@`%` PROCEDURE `GetUser`(filter VARCHAR(50), startIndex INT, endIndex INT) BEGIN SELECT employee_id, display_Forename, display_Surname FROM (SELECT employee_id , display_forename , display_surname , @rownum:=@rownum+1 AS rn FROM central.user_record, (SELECT @rownum:=0) AS r WHERE CONCAT(display_forename, ' ', display_surname) LIKE filter ORDER BY display_surname ASC) AS st WHERE st.rn BETWEEN startIndex AND endIndex; END$$ DELIMITER ; </code></pre> |
27,512,372 | 0 | <p>Since the library I wanted to use was not written as a PHP extension, I had to write a wrapper extension in C, creating a PHP method which takes PHP arguments and calls the library function using the arguments after they are transformed (e.g. using a pointer for the memory address).</p> |
14,916,588 | 0 | <p>Here's how I would do it:</p> <pre><code>#!/bin/bash readonly Directory="$1" shift git --git-dir="$Directory/.git" "$@" </code></pre> <p>First, this copies the repository location (<code>$1</code>) to another variable (<code>$Directory</code>). Then it uses <a href="http://ss64.com/bash/shift.html" rel="nofollow"><code>shift</code></a> to move all the program arguments to the left by one, so <code>$@</code> just contains the arguments that were intended for Git. From there, it's just a simple matter of calling Git with the new arguments.</p> |
12,572,089 | 0 | to create a gallery in asp.net by iterating through the folders <p>I want to create a gallery in asp.net the way it should work is as follows:</p> <ul> <li>iterate through gallery folder</li> <li>select all the folder and show them as albums with cover pic as thumbnail.jpg in that folder</li> <li>when clicked on the album it should display the content of the folder (images).</li> </ul> <p>My approach for creating this was to iterate through the folders and make views and link button based on that for albums and to display the content of album in that view as images using repeater control, but that didn't work out as it had many errors while implementing it. and I had to write the whole thing in on_init() function because of dynamic views.I can implement the html and js part (like for light box and other visual stuffs). Please suggest some better approach maybe with some code example. Please use c# . Thanks</p> |
7,267,162 | 0 | How do I sort this multiple queried result table in PHP using a drop down? <p>I got a code which generate a table like this</p> <p><img src="https://i.stack.imgur.com/VQYa0.jpg" alt="table"></p> <p>and the code is here</p> <pre><code>$num1 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic1' && Indicator='$ind1' && IndicatorSubGroup='$subindg1' && (Country IN ('$sql_cntys') OR WHORegionAC IN ('$sql_cntys')) "); $num2 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic2' && Indicator='$ind2' && IndicatorSubGroup='$subindg2' && (Country IN ('$sql_cntys') OR WHORegionAC IN ('$sql_cntys')) "); $num3 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic3' && Indicator='$ind3' && IndicatorSubGroup='$subindg3' && (Country IN ('$sql_cntys') OR WHORegionAC IN ('$sql_cntys')) "); $num4 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic4' && Indicator='$ind4' && IndicatorSubGroup='$subindg4' && (Country IN ('$sql_cntys') OR WHORegionAC IN ('$sql_cntys')) "); $num5 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic5' && Indicator='$ind5' && IndicatorSubGroup='$subindg5' && (Country IN ('$sql_cntys') OR WHORegionAC IN ('$sql_cntys')) "); $data = array(); while($row = mysql_fetch_assoc($num1)) { $c = $row['Country']; if (!isset($data[$c])) { $data[$c] = array('Country' => $c); } $data[$c]['MidEstimate1'] = $row['MidEstimate']; } while($row = mysql_fetch_assoc($num2)) { $c = $row['Country']; if (!isset($data[$c])) { $data[$c] = array('Country' => $c); } $data[$c]['MidEstimate2'] = $row['MidEstimate']; } while($row = mysql_fetch_assoc($num3)) { $c = $row['Country']; if (!isset($data[$c])) { $data[$c] = array('Country' => $c); } $data[$c]['MidEstimate3'] = $row['MidEstimate']; } while($row = mysql_fetch_assoc($num4)) { $c = $row['Country']; if (!isset($data[$c])) { $data[$c] = array('Country' => $c); } $data[$c]['MidEstimate4'] = $row['MidEstimate']; } while($row = mysql_fetch_assoc($num5)) { $c = $row['Country']; if (!isset($data[$c])) { $data[$c] = array('Country' => $c); } $data[$c]['MidEstimate5'] = $row['MidEstimate']; } $i = 0; echo "<table width='880' align='center'>"; foreach ($data as $row) { echo ($i % 5) ? "<tr>" : "<tr>" ; echo "<td style='padding-left:10px' width='280'>" . $row['Country']."</td>"; echo "<td align='center' width='120'>" . $row['MidEstimate1']."</td>"; echo "<td align='center' width='120'>" . $row['MidEstimate2']."</td>"; echo "<td align='center' width='120'>" . $row['MidEstimate3']."</td>"; echo "<td align='center' width='120'>" . $row['MidEstimate4']."</td>"; echo "<td align='center' width='120'>" . $row['MidEstimate5']."</td>"; echo "</tr>" ; } echo "</table>" ; </code></pre> <p>How can I sort this table column wise ? that is using a drop down list with values "Country", "Indicator 1", "Indicator 2", "Indicator 3", "Indicator 4", "Indicator 5". when a user select values table must list values with respective sorted column. Please help.</p> <p><strong>I got the answer from here</strong> <a href="http://www.the-art-of-web.com/php/sortarray/" rel="nofollow noreferrer">Sort Multi Array</a></p> |
15,166,079 | 0 | mysql workbench load data local infile cannot find file or directory <p>Anyone else having problem using:</p> <pre><code>LOAD DATA LOCAL INFILE 'c:/PRODUCT_GROUP_UPLOAD.CSV' into TABLE ats_store.product_group FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\r\n' (product_group_id,name,price,description,image,start_time,end_time,start_date,end_date,product_code,delivery_format); </code></pre> <p>Mysql Workbench has been buggy for a few weeks now, but I can't even find the file. Also, I updated today!</p> <p>I get:</p> <pre><code>Error Code: 2. File 'c:\PRODUCT_GROUP_UPLOAD.CSV' not found (Errcode: 2 - No such file or directory) </code></pre> <p>I have loaded other files, but can't seem to get this one loaded? It's def in the folder I specify!</p> <p>Keep in mind that i already played with the slashes, forward, backward, double forward, double backward, etc...</p> |
29,057,730 | 0 | Rails-jQuery Why do I have to click twice for jQuery effect to show? <p>I am using Rails 4.1.1 Why do I have to click twice for jQuery effect to show? I have been Googling but I cannot find any solutions, not sure if there's something wrong with my jQuery code or....</p> <p>When I click "Submit" for the first time, the effect didn't appear but the POST action is already called, when I click for the second time, the effect appeared and the POST action is called. </p> <p>Please check below my <code>create.js.erb</code>, <code>users_controller.rb</code>, <code>new.html.erb</code></p> <p><strong>create.js.erb</strong></p> <pre><code>function isValidEmailAddress(emailAddress) { var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i); return pattern.test(emailAddress); }; $("form").submit(function( event ) { var email = $("input#user_email").val(); if (email == "") { $("h1").text( "Email cannot be empty" ).show().fadeOut( 3000 ); return; } else if (!isValidEmailAddress(email)) { $("h1").text( "Email address is not valid" ).show().fadeOut( 3000 ); }else { $("h1").text( "Correct email address" ).show(); } event.preventDefault(); }); </code></pre> <p><strong>new.html.erb</strong></p> <pre><code><%= form_for @user, remote: true do |f| %> <p> <%= f.text_field :email %> </p> <p> <%= f.submit :Submit %> </p> <% end %> <h1></h1> <% @users.each do |user| %> <tr> <li><%= user.email %></li> </tr> <% end %> </code></pre> <p><strong>users_controller.rb</strong></p> <pre><code>class UsersController < ApplicationController def new @users = User.all @user = User.new end def create @user = User.new(user_params) respond_to do |format| format.html { redirect_to '/' } format.js end @user.save end private def user_params params.require(:user).permit(:email) end end </code></pre> |
5,162,764 | 0 | <p>There are some logic errors in your original code (i.e. infinite loop). Fix:</p> <pre> function joinParameters(target, paramName) { var count = 1; var array = []; var name = paramName.concat(count); var value = target[name]; while (value != undefined) { /* typeof value will return "undefined". */ array.push(value); /* You need to increment 'count'. */ name = paramName.concat(++count); value = target[name]; } target[paramName] = array; } ... joinParameters(target, "x"); </pre> <p>Note this function call will add a new element <code>x</code> to <code>target</code>, <code>x1, x2, ..., x6</code> will still exist in <code>target</code>. In fact, this function doesn't take care of the <code>y</code> element, which I assume you want to "join" as well.</p> <p>For a more versatile function, the answer by <em>zachallia</em> should do the trick.</p> |
14,064,579 | 0 | <p>Pagenation problem was solved</p> <pre><code>.pager ul.yiiPager li.page:after{display: inline-block !important} </code></pre> <p>But still am getting image problem... Help please...</p> |
6,386,147 | 0 | <p>You will get the source code for any gateway for any platform in the help/documentation/ download sections of the payment gateway/payment processor website. Compile these codes and host it on codeplex.com. This will be the open source project you want...</p> <p>And do remember to upgrade the code regularly, since the APIs for the payment gateways changes often for to security measures...</p> |
29,971,477 | 0 | Reading information from Memory array into excel sheet formula <p>I'd like to use data from an array that I've got stored in my VBA memory directly into a formula in my sheet. As an example, I'd like to avoid using Application.vlookup() to print to each cell individually as this is slow. And instead do something like the following</p> <pre><code>Sub MySub() Dim MyArrayStoredInVBaMemory() As Variant MyArrayStoredInVBaMemory = Array(1, 2, 3, 4, 5, 6, 7, 8, 9) Cells(1, 1).Value = 1 Cells(1, 2).FormulaR1C1 = "=vlookup(RC1,MyArrayStoredInVBaMemory,1,0)" Cells(1, 2).Copy Cells(1, 2).PasteSpecial xlPasteValues Application.CutCopyMode = False End Sub </code></pre> <p>Your help is appreciated.</p> |
20,900,966 | 0 | Magento Price Formatting - 2 or 3 decimal places <p>I have a requirement to set prices on certain items to 3 decimal places. I have achieved this by changing the 'precision' variable to 3, however this now means that every price on the site is displayed to 3 decimal places (ie: an empty shopping cart shows as £0.000). I want to only show the 3rd decimal place if it's required but I'm not sure where to find this in the code base. Can anyone point me in the right direction please?</p> |
6,291,754 | 0 | <p>Here is some code I used to this a while back, it's not perfect but it should get you started:</p> <p>EDIT: Still ugly but output is better: <code>ajax-json-html5-the-future-of-web-</code></p> <pre><code>string title = "AJAX, JSON & HTML5! The future of web?"; title = Regex.Replace(title, @"&amp;|&", "-"); StringBuilder builder = new StringBuilder(); for (int i = 0; i < title.Length; i++) { if (char.IsLetter(title[i]) || char.IsDigit(title[i])) builder.Append(title[i]); else builder.Append('-'); } string result = builder.ToString().ToLower(); result = Regex.Replace(result, "-+", "-"); </code></pre> |
33,136,982 | 0 | Is it necessary to use document.getElementById() to access a specific DOM object, or can its Id be used directly? <p>In a lot of what I'm reading about Javascript the examples show how to edit a given element by first getting its object using document.getElementById(). However I've seen other code where this isn't used and the element's Id is just used directly.</p> <pre><code><!DOCTYPE html> <html lang="en"> <head> <script> function test1(){ document.getElementById("paragraph").innerHTML = "test 1 works"; } function test2(){ paragraph.innerHTML = "test 2 works"; } </script> </head> <body> <a href="#" onClick="test1()">Run Test 1</a> <a href="#" onClick="test2()">Run Test 1</a> <p id="paragraph"></p> </body> </html> </code></pre> <p>Both test1() and test2() are able to update the innerHTML of the 'paragraph' element. However the first one uses document.getElementById(paragraph) and the second one skips this and just uses the Id itself.</p> <p>Since both of these work is there a preferred method? Does it depend on the browser?</p> |
3,123,532 | 0 | <p>You can in upload script use a temportantly file (in temportantly directory) and if upload was finished you can simple move file to your final location with good filename.</p> <p>This is a common solution for this problem.</p> <p>For get temportantly file (enviroment independent) use PHP function:</p> <pre><code>resource tmpfile ( void ) </code></pre> <p>Documemtation for it you can find at <a href="http://pl.php.net/manual/en/function.tmpfile.php" rel="nofollow noreferrer">http://pl.php.net/manual/en/function.tmpfile.php</a> This function returning handle to your new clean tempfile.</p> <p>But if your using this function you must copy file before you close handle to it because this file was removed when you call <code>fclose(handle)</code>. To get assurance of file buffer is clean you can at end call <code>fflush(handle)</code>.</p> <hr> <p>Or if you don't want use <code>tmpfile(void)</code> function you can do this manualy.</p> <pre><code>string tempnam ( string $dir, string $prefix ) </code></pre> <p>Prefix is a prefix to your files to easly group her to delete or something. Call this function to get unique file in typed directory, as directory get you temp directory in your enviroment, you can get this by calling:</p> <pre><code>string sys_get_temp_dir ( void ) </code></pre> <p>Then when you have self tempfile, write to it upload data and close. Copy this file to your final location using:</p> <pre><code>bool copy ( string $source, string $dest [, resource $context ] ) </code></pre> <p>And delete your tempfile to get clean in your enviroment calling: </p> <pre><code>bool unlink ( string $filename [, resource $context ] ) </code></pre> |
24,154,162 | 0 | <p>Make sure your Class name field is actually <strong>Module</strong>.Task, where <strong>Module</strong> is the name of your app. CoreData classes in Swift are namespaced. Right now, your object is being pulled out of the context as an NSManagedObject, not as a Task, so the as-cast is failing.</p> |
5,402,066 | 0 | <p><a href="http://msdn.microsoft.com/en-us/library/system.stathreadattribute.aspx" rel="nofollow">MSDN answers your questions</a></p> <p>It has no effect on other functions. It only has effect if your program uses COM interop.</p> |
9,809,351 | 0 | IE8 CSS @font-face fonts only working for :before content on over and sometimes on refresh/hard refresh <p>UPDATE: I've written a blog post about what I've learned about this issue. I still don't fully understand it, but hopefully someone will read this and shed some light on my issue: <a href="http://andymcfee.com/2012/04/04/icon-fonts-pseudo-elements-and-ie8">http://andymcfee.com/2012/04/04/icon-fonts-pseudo-elements-and-ie8</a></p> <p>I have a page where I'm using @font-face to import a custom font for icons. The icons are created with a class:</p> <pre><code>.icon {font-family: 'icon-font';} .icon:before {content: 'A';} </code></pre> <p>And voila, I have whatever icon is used for "A". Pretty standard stuff, works in all browsers, including IE8. </p> <p>However, in IE8, I have a bizarre bug. When the page loads, the font is not working. Instead of icons, I have letters all over the place. Once I hover OVER the page (body), half the letters become icons. The rest become icons when I hover over them. </p> <p>SO the font-face is embedding properly. The font-family and content properties are both working, but something else is causing the icons to load only after hover.</p> <p>So there's some sort of bug with @font-face in IE8 when you try to use the font with :before{content: 'a'} but I have no idea what the bug is.</p> <p>I've searched for hours on here for a similar bug/IE8 issue/anything, but I've had no luck and I'm about to go crazy. ANY suggestions? </p> <p>Let me know if I can provide anymore info that might be helpful. </p> <p>EDIT: Updated the broken link to the blog post.</p> |
31,724,454 | 0 | Will new local class instance be garbage collected if I return an array it creates? <p>Let's say a class instance will build arrays:</p> <pre><code>class FooArrBuilder { public Foo[] FinalResult { get { return arr; } } Foo[] arr; public void BuildArr(); ... } </code></pre> <p>Then it's used like this:</p> <pre><code>Foo[] GetFooArr() { var fb = new FooArrBuilder(); fb.BuildArr(); ... return fb.FinalResult; } </code></pre> <p>When an array is built inside an instance local to a function, will the array be moved out of the instance that built it, or will the whole instance be kept in memory just to contain the array? I do not necessarily want to copy the array if the latter is the case - but maybe I could make the class a struct? Help is appreciated :)</p> <p>If you care to elaborate a bit on C#'s memory model here, it would probably help me to avoid further confusion as well.</p> <p>Thanks in advance</p> |
35,031,713 | 0 | <p>Have you tried with "before"?</p> <pre><code>$args = array( 'post_type' => 'epl_registration', 'post_status' => 'publish', 'fields' => 'ids', 'date_query' => array( array( 'column' => 'post_date_gmt', 'before' => '6 hours ago' ) ) ); $the_query = new WP_Query($args); </code></pre> |
23,239,260 | 0 | <pre><code>Use this class package com.diluo.http; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicNameValuePair; import org.apache.http.protocol.HTTP; import android.app.ProgressDialog; import android.content.Entity; import android.os.AsyncTask; public class PostCall extends AsyncTask<Void, Void, String>{ private String url; private String request; private AsyncTaskListener callListener; private int pageId; private ProgressDialog dialog; public PostCall(String url,String request,ProgressDialog dialog,AsyncTaskListener callListener,int pageId) { this.url=url; this.request=request; this.callListener=callListener; this.pageId = pageId; this.dialog=dialog; } @Override protected String doInBackground(Void... params) { // TODO Auto-generated method stub try { System.out.println(request); System.out.println(url); HttpPost post = new HttpPost(this.url); StringEntity entity = new StringEntity(request,"UTF-8"); entity.setContentType("application/json"); entity.setContentEncoding(new BasicHeader("Content-type","application/json;charset=UTF-8")); post.setEntity(entity); post.addHeader("Content-type", "application/json;charset=UTF-80"); post.setHeader("Accept", "application/json"); DefaultHttpClient httpClient = new DefaultHttpClient(); HttpResponse response = httpClient.execute(post); // Collect the response HttpEntity entity1=response.getEntity(); if(entity1 != null&&(response.getStatusLine().getStatusCode()==201||response.getStatusLine().getStatusCode()==200)) { //--just so that you can view the response, this is optional-- int sc = response.getStatusLine().getStatusCode(); String sl = response.getStatusLine().getReasonPhrase(); String response_string=convertToString(entity1.getContent()); return response_string; } else { int sc = response.getStatusLine().getStatusCode(); String sl = response.getStatusLine().getReasonPhrase(); return null; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } private String convertToString(InputStream content) throws Exception{ InputStreamReader inputStreamReader=new InputStreamReader(content); BufferedReader bufferedReader=new BufferedReader(inputStreamReader); String s=""; StringBuffer buffer=new StringBuffer(); while ((s=bufferedReader.readLine())!=null) { buffer.append(s); } return buffer.toString(); } @Override protected void onPostExecute(String result) { if( callListener!= null){ super.onPostExecute(result); if(result != null){ try { System.out.println(result); callListener.onHttpResponse(result, pageId); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } }else{ callListener.onError("Please try again.", pageId); } if(this.dialog!=null){ dialog.dismiss(); } } cancel(true); } } </code></pre> |
26,597,271 | 0 | sparse indexing in matlab <p>I have a very long code which is full of the following "if"s and matlab editor gives me a suggestion as follow:</p> <p><strong>this sparse indexing expression is likely to be slow</strong></p> <pre><code>mt = rand(200,200); [c r] = size(mt); T = sparse(r*c,2); for i = 1:c for j = 1:r if(ind(j,i)==1) templat = template + 1; T((i-1)*r+j,2)=100000; end end; end; </code></pre> <p>Is there any way by which I can make the code faster and do the matlab's suggestion? (The code may not run, because I just picked a few lines and tried to show the issue)</p> |
23,583,368 | 0 | <p>First, a capitalization typo: </p> <pre><code>stage.find // not stage.Find </code></pre> <p>When you use the hashtag (#) within a .find key, KineticJS searches for a node <code>id</code>. </p> <p>So when you create each path (room) you should assign it a node id (eg "Room1"):</p> <pre><code>var path = new Kinetic.Path({ id:"Room1", data: c, fill: '#fff', stroke: '#555', strokeWidth: 1 }); </code></pre> <p>Then your .find will succeed:</p> <pre><code>var room = stage.find("#Room1")[0]; </code></pre> |
37,806,419 | 0 | <p>I have found the solution. The problem is with setting the contentScaleFactor of UIView. By default, it is 2.0 for retina displays. So, it should be set to 1.0. Here is the link for more details: <a href="http://stackoverflow.com/a/7130677/5814521">UIView ContentScaleFactor</a></p> |
5,762,453 | 0 | <p><a href="http://php.net/manual/en/function.array-map.php"><strong>array_map</strong></a> and <a href="http://php.net/manual/en/function.trim.php"><strong>trim</strong></a> can do the job</p> <pre><code>$trimmed_array=array_map('trim',$fruit); print_r($trimmed_array); </code></pre> |
22,469,393 | 0 | <p>It is possible to do bulk inserts in MongoDB. Check out the <a href="http://docs.mongodb.org/manual/core/bulk-inserts/" rel="nofollow">documentation</a> for details.</p> <p>Quoting from the documentation:</p> <blockquote> <p>The insert() method, when passed an array of documents, performs a bulk insert, and inserts each document atomically. Bulk inserts can significantly increase performance by amortizing write concern costs.</p> </blockquote> |
37,734,931 | 0 | <p>As far as the rest of your program is aware your <code>wait_queue</code> is just a <code>Collection</code>, it doesn't have <code>get</code> or <code>remove</code> methods.</p> <p>You're correct in that you don't want to couple your implementation to the variable's type, however you shouldn't use <code>Collection</code> unless you only want to iterate over the contents. Use <code>List</code>, <code>Set</code>, or other collections interfaces to describe collections. These expose the <code>get</code> and <code>remove</code> (in the case of the <code>List</code>) methods you want, and expose the <strong>behaviour</strong> of the object (but not the implementation - in this case <code>ArrayList</code>). e.g., a <code>List</code> allows duplicates whereas a <code>Set</code> does not.</p> |
5,852,295 | 0 | xQuery return all values but one <p>Here is my xml:</p> <pre><code><?xml version="1.0" encoding="utf-8"?> <library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="library.xsd"> <items> <book asin="0201100886" created="128135928" lastLookupTime="128135928"> <uuid>BA57A934-6CDC-11D9-830B-000393D3DE16</uuid> <title>Compilers</title> <authors> <author>Alfred V. Aho</author> <author>Ravi Sethi</author> <author>Jeffrey D. Ullman</author> </authors> <publisher>Addison Wesley</publisher> <published>1986-01-01</published> <price>102.00</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0122513363" created="128135600" lastLookupTime="128136224"> <uuid>F7468E09-6CDB-11D9-830B-000393D3DE16</uuid> <title>Database Driven Web Sites</title> <authors> <author>Jesse Feiler</author> </authors> <publisher>Morgan Kaufmann</publisher> <published>1998-04-15</published> <edition>Paperback</edition> <price>50.95</price> <purchaseDate>2005-01-22</purchaseDate> <currentValue>35.00</currentValue> <netRating>1.5</netRating> <genres> <genre>Computer Bks - Internet</genre> <genre>Computer Books: Web Programming</genre> <genre>Computer Networks</genre> <genre>Computers</genre> <genre>Database Management - General</genre> <genre>Database management</genre> <genre>Design</genre> <genre>Distributed Databases</genre> <genre>Information Technology</genre> <genre>Internet - Web Site Design</genre> <genre>Networking - General</genre> <genre>Web sites</genre> <genre>Computers / Computer Science</genre> </genres> <upc>608628133638</upc> </book> <book asin="0201441241" created="128136896" lastLookupTime="128136896"> <uuid>FBC45DF4-6CDE-11D9-830B-000393D3DE16</uuid> <title>Introduction to Automata Theory, Languages, and Computation (2nd Edition)</title> <authors> <author>John E. Hopcroft</author> <author>Rajeev Motwani</author> <author>Jeffrey D. Ullman</author> </authors> <publisher>Addison Wesley</publisher> <published>2000-11-14</published> <price>108.20</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0471250600" created="128136896" lastLookupTime="128136896"> <uuid>FBC7CA56-6CDE-11D9-830B-000393D3DE16</uuid> <title>Operating System Concepts</title> <authors> <author>Abraham Silberschatz</author> <author>Greg Gagne</author> <author>Peter Baer Galvin</author> </authors> <publisher>Wiley</publisher> <published>2002-03-08</published> <price>107.95</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0321193628" created="128136896" lastLookupTime="128136896"> <uuid>FBCB3DCF-6CDE-11D9-830B-000393D3DE16</uuid> <title>Concepts of Programming Languages, Sixth Edition</title> <authors> <author>Robert W. Sebesta</author> </authors> <publisher>Addison Wesley</publisher> <published>2003-07-24</published> <price>112.40</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0138613370" created="128136944" lastLookupTime="128136944"> <uuid>19E5E602-6CDF-11D9-830B-000393D3DE16</uuid> <title>First Course in Database Systems, A</title> <authors> <author>Jeffrey D. Ullman</author> <author>Jennifer Widom</author> </authors> <publisher>Prentice Hall</publisher> <published>1997-04-02</published> <edition>Hardcover</edition> <price>67.00</price> <purchaseDate>2005-01-22</purchaseDate> <netRating>3.2</netRating> <genres> <genre>Computer Books: Database</genre> <genre>Computers</genre> <genre>Database Engineering</genre> <genre>Database Management - General</genre> <genre>Database management</genre> </genres> <recommendations> <book asin="0130402648" created="128136952" lastLookupTime="128136952"> <uuid>1C60074A-6CDF-11D9-830B-000393D3DE16</uuid> <title>Database System Implementation</title> <authors> <author>Hector Garcia-Molina</author> <author>Jeffrey D. Ullman</author> <author>Jennifer D. Widom</author> </authors> <publisher>Prentice Hall</publisher> <published>1999-06-11</published> <price>89.00</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0130319953" created="128136952" lastLookupTime="128136952"> <uuid>1C635DB0-6CDF-11D9-830B-000393D3DE16</uuid> <title>Database Systems: The Complete Book</title> <authors> <author>Hector Garcia-Molina</author> <author>Jeffrey D. Ullman</author> <author>Jennifer D. Widom</author> </authors> <publisher>Prentice Hall</publisher> <published>2001-10-02</published> <price>98.00</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0201976994" created="128136952" lastLookupTime="128136952"> <uuid>1C66B7B4-6CDF-11D9-830B-000393D3DE16</uuid> <title>Computer Networking: A Top-Down Approach Featuring the Internet</title> <authors> <author>James F. Kurose</author> <author>Keith W. Ross</author> <author>James Kurose</author> <author>Keith Ross</author> </authors> <publisher>Addison Wesley</publisher> <published>2002-07-17</published> <price>100.00</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0131433512" created="128136952" lastLookupTime="128136952"> <uuid>1C6AC88C-6CDF-11D9-830B-000393D3DE16</uuid> <title>Computer Networks and Internets, Fourth Edition</title> <authors> <author>Douglas E Comer</author> <author>Ralph E. Droms</author> </authors> <publisher>Prentice Hall</publisher> <published>2003-07-28</published> <price>100.00</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0262062178" created="128136952" lastLookupTime="128136952"> <uuid>1C6E712C-6CDF-11D9-830B-000393D3DE16</uuid> <title>Essentials of Programming Languages - 2nd Edition</title> <authors> <author>Daniel P. Friedman</author> <author>Mitchell Wand</author> <author>Christopher T. Haynes</author> </authors> <publisher>The MIT Press</publisher> <published>2001-01-29</published> <price>62.00</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0471250600" created="128136952" lastLookupTime="128136952"> <uuid>1C71B23E-6CDF-11D9-830B-000393D3DE16</uuid> <title>Operating System Concepts</title> <authors> <author>Abraham Silberschatz</author> <author>Greg Gagne</author> <author>Peter Baer Galvin</author> </authors> <publisher>Wiley</publisher> <published>2002-03-08</published> <price>107.95</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0137903952" created="128136952" lastLookupTime="128136952"> <uuid>1C764AD4-6CDF-11D9-830B-000393D3DE16</uuid> <title>Artificial Intelligence: A Modern Approach (2nd Edition)</title> <authors> <author>Stuart J. Russell</author> <author>Peter Norvig</author> </authors> <publisher>Prentice Hall</publisher> <published>2002-12-20</published> <price>93.33</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="155860832X" created="128136952" lastLookupTime="128136952"> <uuid>1C898640-6CDF-11D9-830B-000393D3DE16</uuid> <title>Computer Networks: A Systems Approach, 3rd Edition</title> <authors> <author>Larry L. Peterson</author> <author>Bruce S. Davie</author> </authors> <publisher>Morgan Kaufmann</publisher> <published>2003-05-22</published> <price>89.95</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0130669474" created="128136952" lastLookupTime="128136952"> <uuid>1C8DD37A-6CDF-11D9-830B-000393D3DE16</uuid> <title>SQL Fundamentals (2nd Edition)</title> <authors> <author>John J. Patrick</author> </authors> <publisher>Prentice Hall PTR</publisher> <published>2002-05-07</published> <price>54.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0321122267" created="128136952" lastLookupTime="128136952"> <uuid>1C91D772-6CDF-11D9-830B-000393D3DE16</uuid> <title>Fundamentals of Database Systems, Fourth Edition</title> <authors> <author>Ramez Elmasri</author> <author>Shamkant B. Navathe</author> </authors> <publisher>Addison Wesley</publisher> <published>2003-07-23</published> <price>104.20</price> <purchaseDate>2005-01-22</purchaseDate> </book> </recommendations> </book> <book asin="1558604820" created="128136024" lastLookupTime="128136024"> <uuid>F3C7B24F-6CDC-11D9-830B-000393D3DE16</uuid> <title>A Complete Guide to DB2 Universal Database</title> <authors> <author>D. D. Chamberlin</author> <author>Don Chamberlin</author> </authors> <publisher>Morgan Kaufmann</publisher> <published>1998-08-15</published> <edition>Paperback</edition> <price>62.95</price> <purchaseDate>2005-01-22</purchaseDate> <netRating>4.4</netRating> <genres> <genre>Computer Bks - Data Base Management</genre> <genre>Computer Books: Database</genre> <genre>Computers</genre> <genre>Database Management - General</genre> <genre>General</genre> <genre>IBM Database 2</genre> <genre>Information Storage &amp; Retrieval</genre> <genre>Relational Databases</genre> <genre>Computers / Information Storage &amp; Retrieval</genre> </genres> <recommendations> <book asin="0072133449" created="128136024" lastLookupTime="128136024"> <uuid>F6B35F21-6CDC-11D9-830B-000393D3DE16</uuid> <title>DB2: The Complete Reference (Complete Reference Series)</title> <authors> <author>Roman B. Melnyk</author> <author>Paul C. Zikopoulos</author> </authors> <publisher>McGraw-Hill Companies</publisher> <published>2001-10-01</published> <price>59.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0130661112" created="128136024" lastLookupTime="128136024"> <uuid>F6B97E54-6CDC-11D9-830B-000393D3DE16</uuid> <title>DB2 UDB v8 Handbook for Windows and UNIX/Linux</title> <authors> <author>Philip K. Gunning</author> </authors> <publisher>Prentice Hall PTR</publisher> <published>2003-08-06</published> <price>59.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0131007726" created="128136024" lastLookupTime="128136024"> <uuid>F6BCBB88-6CDC-11D9-830B-000393D3DE16</uuid> <title>DB2 SQL Procedural Language for Linux, Unix and Windows</title> <authors> <author>Paul Yip</author> <author>Drew Bradstock</author> <author>Hana Curtis</author> <author>Michael Gao</author> <author>Zamil Janmohamed</author> <author>Clara Liu</author> <author>Fraser McArthur</author> </authors> <publisher>Prentice Hall PTR</publisher> <published>2002-12-24</published> <price>59.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0131424653" created="128136024" lastLookupTime="128136024"> <uuid>F6C0A296-6CDC-11D9-830B-000393D3DE16</uuid> <title>DB2 UDB V8.1 Certification Exam 700 Study Guide</title> <authors> <author>Roger E. Sanders</author> </authors> <publisher>Prentice Hall PTR</publisher> <published>2003-09-17</published> <price>49.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0764508415" created="128136024" lastLookupTime="128136024"> <uuid>F6C4058C-6CDC-11D9-830B-000393D3DE16</uuid> <title>DB2 Fundamentals Certification for Dummies</title> <authors> <author>Paul C. Zikopoulos</author> <author>Jennifer Gibbs</author> <author>Roman B. Melnyk</author> </authors> <publisher>For Dummies</publisher> <published>2001-08-01</published> <price>34.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0130463612" created="128136024" lastLookupTime="128136024"> <uuid>F6D9A3D8-6CDC-11D9-830B-000393D3DE16</uuid> <title>DB2 Universal Database V8 for Linux, UNIX, and Windows Database Administration Certification Guide (5th Edition)</title> <authors> <author>George Baklarz</author> <author>Bill Wong</author> </authors> <publisher>Prentice Hall PTR</publisher> <published>2003-02-10</published> <price>59.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0130463884" created="128136024" lastLookupTime="128136024"> <uuid>F6DDBAB9-6CDC-11D9-830B-000393D3DE16</uuid> <title>Advanced DBA Certification Guide and Reference for DB2 UDB v8 for Linux, Unix and Windows</title> <authors> <author>Dwaine R. Snow</author> <author>Thomas Xuan Phan</author> <author>Dwaine Snow</author> </authors> <publisher>Prentice Hall PTR</publisher> <published>2003-07-07</published> <price>59.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="155860443X" created="128136024" lastLookupTime="128136024"> <uuid>F6E1063D-6CDC-11D9-830B-000393D3DE16</uuid> <title>Advanced Database Systems (The Morgan Kaufmann Series in Data Management Systems)</title> <authors> <author>Carlo Zaniolo</author> <author>Stefano Ceri</author> <author>Christos Faloutsos</author> <author>Richard T. Snodgrass</author> <author>V. S. Subrahmanian</author> <author>Roberto Zicari</author> </authors> <publisher>Morgan Kaufmann</publisher> <published>1997-05-01</published> <price>88.95</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0131840487" created="128136024" lastLookupTime="128136024"> <uuid>F6E441CE-6CDC-11D9-830B-000393D3DE16</uuid> <title>DB2 UDB V8.1 Certification Exams 701 and 706 Study Guide</title> <authors> <author>Roger E. Sanders</author> </authors> <publisher>Prentice Hall PTR</publisher> <published>2003-12-12</published> <price>49.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> <book asin="0132037955" created="128136024" lastLookupTime="128136024"> <uuid>F6E77C2C-6CDC-11D9-830B-000393D3DE16</uuid> <title>DB2 High Performance Design and Tuning</title> <authors> <author>Richard Yevich</author> <author>Susan Lawson</author> <author>Richard A. Yevich</author> </authors> <publisher>Prentice Hall PTR</publisher> <published>2000-08-24</published> <price>54.99</price> <purchaseDate>2005-01-22</purchaseDate> </book> </recommendations> </book> </items> <borrowers> <borrower id="1"> <name> John Doe </name> <phone> 555-1212 </phone> <borrowed> <book asin="0138613370"/> <book asin="0122513363"/> </borrowed> </borrower> <borrower id="2"> <name> Mary Jane </name> <phone> 555-1213 </phone> <borrowed> <book asin="0201100886"/> <book asin="0122513363"/> </borrowed> </borrower> <borrower id="3"> <name> Bill Jones </name> <phone> 555-1312 </phone> <borrowed /> </borrower> <borrower id="4"> <name> Anne Marie</name> <phone> 555-1314</phone> <borrowed> <book asin="0138613370"/> <book asin="0201100886"/> <book asin="0122513363"/> <book asin="1558604820"/> </borrowed> </borrower> </code></pre> <p> </p> <p>Here is my XQuery:</p> <pre><code>xquery version "1.0"; for $library in doc("library.xml")/library for $book in $library/items/book let $borrowed := $library/borrowers/borrower/borrowed/book where not($borrowed[@asin = $book/@asin]) and ($book/authors/author = "Jeffrey D. Ullman") return if($book/authors/author != "Jeffrey D. Ullman") then <librarytitle>{$book/authors/author}</librarytitle> else <librarytitle/> </code></pre> <p>I need to return all authors where Jeff D Ullman is a coauthor but in the list I cant return his name. So i get all books he is an author in and print them out. If his name is there dont print it out. My if then else statement is not working. Any ideas????</p> |
39,505,739 | 0 | OpenCV floodfill while maintaining intensity of objects takes too long to run <p>I am using OpenCV 3.1.0 to change the color of certain areas in an image. OpenCV's floodfill is doing an excellent job of selecting the area and changing the color to a solid new value. But the output image pixels lose their intensity and the shadows in the images are lost.</p> <p>What I need is that the color replacement in floodfill takes into consideration the intensity of the pixel and fill a slightly darker or lighter shade of that color accordingly.</p> <p>What I did -</p> <ol> <li>Converted the original image to HLS color space and saved this Mat separately. Original Image link- <a href="https://www.walldevil.com/wallpapers/a40/thumb/desktop-themes-skins-office-wallpapers-walls.jpg" rel="nofollow">https://www.walldevil.com/wallpapers/a40/thumb/desktop-themes-skins-office-wallpapers-walls.jpg</a></li> <li>Used floodfill on image with new color. Convert this to HLS too. </li> <li>Parsed each pixel of the new image and wherever the floodfill had replaced the color, changed the L value by incrementing or decrementing the new L with the difference between the old L and average L of changed pixels. <a href="http://i.stack.imgur.com/gMVWk.png" rel="nofollow">Output after Intensity Readjustment</a></li> </ol> <p>The problem is first I calculated the average L of changed pixels and then parse each pixel again to adjust the L value. All this is taking too long to execute</p> <p>Is there a way I can optimize my approach for faster output.</p> <pre><code>Mat dst = isColor ? image : gray; int area; if( useMask ) { threshold(mask, mask, 1, 128, THRESH_BINARY); area = floodFill(dst, mask, seed, newVal, &ccomp, Scalar(lo, lo, lo), Scalar(up, up, up), flags); imshow( "mask", mask ); } else { area = floodFill(dst, seed, newVal, &ccomp, Scalar(lo, lo, lo), Scalar(up, up, up), flags); } cvtColor(dst,hsvmask,CV_BGR2HLS); for(int i=0;i<image.rows;i++) for(int j=1;j<image.cols*3;j=j+3) { float o_hue=(float)imghsv.at<uchar>(i,j); float n_hue=(float)hsvmask.at<uchar>(i,j); float s_intensity=(float)imghsv.at<uchar>(y,x*3+1); float o_intensity=(float)imghsv.at<uchar>(i,j); float n_intensity=(float)hsvmask.at<uchar>(i,j); float newIntensity=n_intensity + (o_intensity-s_intensity); hsvmask.at<uchar>(i,j)=((o_hue==n_hue)?o_intensity:newIntensity<0?0:newIntensity); } hsvmask.copyTo(imghsv); cvtColor(hsvmask,dst,CV_HLS2BGR); imshow("image", dst); </code></pre> <p>The code in nested for loops is how I restore the intensity by traversing each pixel. But it is very slow in terms of execution.</p> |
12,391,404 | 0 | android align View programmatically <p>I have a LinearLayout that comprises some number of TextViews. I set </p> <pre><code>android:gravity="center_horizontal" </code></pre> <p>for the parent Layout and result looks as below (for N=2):</p> <p><img src="https://i.stack.imgur.com/0OeOg.png" alt="enter image description here"></p> <p>I want it look like</p> <p><img src="https://i.stack.imgur.com/4FjE8.png" alt="enter image description here"></p> <p>In other words, I want them to be aligned to the left. More precisely, my plan is to find the longest TextView and then align other TextViews to the left bound of that view. Can anyone explain me in what callback of my Activity can I do it? I tried</p> <pre><code>public void onCreate(Bundle savedInstanceState) </code></pre> <p>but</p> <pre><code>textView.getWidth() </code></pre> <p>(that I use to find the longest TextView) returns 0 for all textViews. The second question is: what method should I use to move a TextView "n" pixels left?</p> |
22,553,160 | 0 | <p>You can consider to check the number of displayed elements in the <code>open</code> event, if the <code>len</code> is 0 you can display another element accordingly.</p> <p>Other solutions are to use a custom <code>_renderItem</code> function or a custom extended widget, but in this case this can be a simpler solution.</p> <p>Code:</p> <pre><code>$("#project").autocomplete({ minLength: 0, source: projects, open: function (event, ui) { var len = $('.ui-autocomplete > li').length; $('#count').html('Founded ' + len + ' results'); } }); </code></pre> <p>Demo: <a href="http://jsfiddle.net/IrvinDominin/DZ9zU/" rel="nofollow">http://jsfiddle.net/IrvinDominin/DZ9zU/</a></p> <h2>UPDATE</h2> <p>Better using <a href="http://api.jqueryui.com/autocomplete/#event-response" rel="nofollow"><code>response</code></a> event:</p> <blockquote> <p>Triggered after a search completes, before the menu is shown. Useful for local manipulation of suggestion data, where a custom source option callback is not required. This event is always triggered when a search completes, even if the menu will not be shown because there are no results or the Autocomplete is disabled.</p> </blockquote> <p>Code:</p> <pre><code>$("#project").autocomplete({ minLength: 0, source: projects, response: function (event, ui) { var len = ui.content.length; $('#count').html('Founded ' + len + ' results'); } }); </code></pre> <p>Demo: <a href="http://jsfiddle.net/IrvinDominin/DZ9zU/1/" rel="nofollow">http://jsfiddle.net/IrvinDominin/DZ9zU/1/</a></p> |
38,156,993 | 0 | How to use for in loop decrement condition in swift? <p>I can use the for in loop in Swift through this code</p> <pre><code> for i in 0..<5 { print ("Four multiplied by \(i) results in \(i*4)" ) } </code></pre> <p>But how do i use the for with less than ">" condition.</p> <pre><code> for i in 10>..5 { print ("Four multiplied by \(i) results in \(i*4)" ) } </code></pre> <p>It shows <strong>error: '>' is not a postfix unary operator for i in 10>..5</strong></p> |
32,674,086 | 0 | <p>The <code><html></code> background is "behind" the <code><body></code> background. Try this to see what I mean:</p> <pre><code>html{ background-color:blue; } body{ background-color:white; max-width:400px; margin:0 auto; } </code></pre> |
13,729,706 | 0 | <p>If you want to copy the item from index 0 in the first list to index 0 in the second, and so on for all of the other indexes you can do this:</p> <pre><code>var pairs = members.Zip(divisions, (a, b) => new { Member = a, Division = b, }); foreach (var pair in pairs) { Copy(pair.Member, pair.Division); } </code></pre> <p>If the indexes don't match you need to do a join:</p> <pre><code>var pairs = members.Join(divisions , member => member.DivisionId , division => division.DivisionId , (a, b) => new { Member = a, Division = b, }); foreach (var pair in pairs) { Copy(pair.Member, pair.Division); } </code></pre> <p>Note that the <code>Zip</code> will be faster, if the items are already in the proper order. Join will be slower than the Zip, but will be faster than manually re-ordering the items to allow a <code>Zip</code>.</p> |
16,526,029 | 0 | <p>Your OS will buffer a certain amount of incoming TCP data. For example on Solaris this defaults to 56K but can be reasonably configured for up to several MB if heavy bursts are expected. Linux appears to default to much smaller values, but you can see instructions on this web page for increasing those defaults: <a href="http://www.cyberciti.biz/faq/linux-tcp-tuning/" rel="nofollow">http://www.cyberciti.biz/faq/linux-tcp-tuning/</a></p> |
14,388,250 | 0 | Android : Network on main Thread with a Widget <p>I made a simple widget (<code>AppWidgetProvider</code>). To load its content, it needs to connect to the internet (<code>JSoup</code> is amazing). Obviously, I've got a wonderful <code>NetworkOnMainThreadException</code>. I tried to do an <code>AsyncTask</code> but Eclipse is shouting <code>No enclosing instance of type WidgetClass is accessible. Must qualify the allocation with an enclosing instance of type WidgetClass (e.g. x.new A() where x is an instance of WidgetClass).</code> at me, so I can't run it.</p> <p>How could I solve it ?</p> <p>Thanks !</p> |
36,142,507 | 0 | Php AJAX search with external JSON file <p>So Im trying to create an input field that displays results without the need of a refresh from an external JSON file. My current code works fine, however how would I achieve checking for results in an external JSON file instead of directly in the php file?</p> <p>My JSON file: (I'd like to display results from "name").</p> <pre><code>[ {"name" : "300", "year" : "1999", "plot" : "X", "run" : "200 min", "rated" : "PG-13", "score" : "10/10", "source" : "A", "id" : "000"}, {"name" : "200", "year" : "1999", "plot" : "X", "run" : "200 min", "rated" : "PG-13", "score" : "10/10", "source" : "A", "id" : "000"} ] </code></pre> <p>My html and Javascript:</p> <pre><code><script> function showHint(str) { if (str.length == 0) { document.getElementById("txtHint").innerHTML = ""; return; } else { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("txtHint").innerHTML = xmlhttp.responseText; } }; xmlhttp.open("GET", "gethint.php?q=" + str, true); xmlhttp.send(); } } </script> <p><b>Start typing a name in the input field below:</b></p> <form> First name: <input type="text" onkeyup="showHint(this.value)"> </form> <p>Suggestions: <span id="txtHint"></span></p> </code></pre> <p>gethint.php</p> <pre><code><?php //Instead of using these I'd like to use the external JSON file $a[] = "Anna"; $a[] = "Brittany"; $a[] = "Cinderella"; $a[] = "Diana"; // get the q parameter from URL $q = $_REQUEST["q"]; $hint = ""; // lookup all hints from array if $q is different from "" if ($q !== "") { $q = strtolower($q); $len=strlen($q); foreach($a as $name) { if (stristr($q, substr($name, 0, $len))) { if ($hint === "") { $hint = $name; } else { $hint .= ", $name"; } } } } // Output "no suggestion" if no hint was found or output correct values echo $hint === "" ? "no suggestion" : $hint; ?> </code></pre> |
1,182,395 | 0 | <p>As a bug-tracker, I am using <a href="http://www.mantisbt.org/" rel="nofollow noreferrer">Mantis</a> :</p> <ul> <li>it is not too hard to use (our clients are using it OK, even if they are not programmers) </li> <li>it does the job ; tracking bugs, at least, with what functionnalities you could expect</li> <li>it is written in PHP, which is great if you are yourself working with PHP : it means you already have servers that can host it, and that you will know how to solve problems if you encounter some (that's one of my problems with Trac : I don't know anything about Python, to, when there's a problem, I'l literally stuck... )</li> <li>also, if you take a look at their <a href="http://www.mantisbt.org/blog/" rel="nofollow noreferrer">blog</a>, you will notice there have been some new versions this years, which means it's still under development <em>(which is better than using an old tool noone cares about anymore ^^ )</em></li> </ul> <p>There's a <a href="http://www.mantisbt.org/demo/my_view_page.php" rel="nofollow noreferrer">demo available</a>, btw.</p> |
15,485,149 | 0 | <p>It will help you. <a href="http://css-tricks.com/snippets/css/media-queries-for-standard-devices/" rel="nofollow">Media Queries for standard devices.</a></p> <p>And use it as your meta tag.</p> <pre><code><meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi" /> </code></pre> |
17,502,294 | 0 | What is the proper way to submit data from Parent form with partial view MVC 4? <p>The Main Controller</p> <pre><code>public class TestPartialController : Controller { // // GET: /TestPartial/ public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(Main model) { HttpContext.Items.Add("MainModel", model); return View(); } public ActionResult PartialA() { return PartialView(); } [HttpPost] public ActionResult PartialA(PartialA a) { if (HttpContext.Items["MainModel"] != null) { Main model =(Main) HttpContext.Items["MainModel"]; model.PA = a; } return PartialView(); } public ActionResult PartialB() { return PartialView(); } [HttpPost] public ActionResult PartialB(PartialB b) { if (HttpContext.Items["MainModel"] != null) { Main model = (Main)HttpContext.Items["MainModel"]; model.PB = b; } SubmitDatatoDB(); return PartialView(); } public void SubmitDatatoDB() { if (HttpContext.Items["MainModel"] != null) { Main model = (Main)HttpContext.Items["MainModel"]; //SubmitDatatoDB } } } </code></pre> <p>Models:-</p> <pre><code>namespace TestingMVC4.Models { public class Main { public string Main1 { get; set; } public string Main2 { get; set; } public virtual PartialA PA { get; set; } public virtual PartialB PB { get; set; } } public class PartialA { public string UserName { get; set; } public string UserID { get; set; } } public class PartialB { public string UserNameB { get; set; } public string UserIDB { get; set; } } } </code></pre> <p>View :-</p> <pre><code>@model TestingMVC4.Models.Main @{ ViewBag.Title = "Index"; } <h2>Index</h2> @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <legend>Main</legend> <div class="editor-label"> @Html.LabelFor(model => model.Main1) </div> <div class="editor-field"> @Html.EditorFor(model => model.Main1) @Html.ValidationMessageFor(model => model.Main1) </div> <div class="editor-label"> @Html.LabelFor(model => model.Main2) </div> <div class="editor-field"> @Html.EditorFor(model => model.Main2) @Html.ValidationMessageFor(model => model.Main2) </div> <div> @Html.Action("PartialA","TestPartial") </div> <div> @Html.Action("PartialB","TestPartial") </div> <p> <input type="submit" value="Create" /> </p> </fieldset> } @model TestingMVC4.Models.PartialA @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <legend>PartialA</legend> <div class="editor-label"> @Html.LabelFor(model => model.UserName) </div> <div class="editor-field"> @Html.EditorFor(model => model.UserName) @Html.ValidationMessageFor(model => model.UserName) </div> <div class="editor-label"> @Html.LabelFor(model => model.UserID) </div> <div class="editor-field"> @Html.EditorFor(model => model.UserID) @Html.ValidationMessageFor(model => model.UserID) </div> </fieldset> } </code></pre> <p>Mine Question is if doing like this, the Index of HTTPPOST of main view will fire first. than follow by Partial view A and Partial View B. In this case I need to store the data in HttpContext.Items and call the submit to Database in the last Partial view B.</p> <p>What I want is fire the Partial view A and B first, and store the data into Main View's model and call the SubmitDatatoDB function in Main View's POST Action. </p> |
9,483,876 | 0 | <p>Apparently the VCSCommand plugin has a setting called <code>VCSCommandDeleteOnHide</code> which when set to non zero will <code>:bdelete</code> the buffer on a hide which this includes <code>:q</code>. Note: this will apply to all VCSCommand buffers.</p> <pre><code>let g:VCSCommandDeleteOnHide = 1 </code></pre> <p>If you really want to wipe just the annotate the buffer you can do the following instead.</p> <pre><code>autocmd FileType svnannotate set bufhidden=wipe </code></pre> <p>See</p> <pre><code>:h VCSCommandDeleteOnHide :h 'bufhidden' </code></pre> |
32,672,383 | 0 | Swift use of unresolved identifier 'webView' <p>I want to add a webview to my application, but i keep getting this freaking error for webview. Please help!</p> <pre><code>import UIKit class Browse: UIViewController { @IBOutlet weak var browseweb: UIWebView! let browseurl = "http://google.com" override func viewDidLoad() { super.viewDidLoad() let requestURL = NSURL(string:browseurl) let request = NSURLRequest(URL: requestURL!) webView.loadRequest(request) // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } </code></pre> |
21,746,286 | 0 | <p><code>gsl_ran_binomial</code> should be declared with the <code>random</code> attribute, because it is a random number generator:</p> <pre><code>function gsl_ran_binomial random; </code></pre> |
33,506,495 | 0 | <p>If you can wait a month Postgres 9.5 will be out and has Row Security. Oracle has it now if you have ten million bucks kicking around. </p> <p>For now, or in other dbs, you can mimic row security:</p> <ol> <li><p>Each protected table gets an "owner" column. By default only the owner can select, update, or delete that row.</p></li> <li><p>Each "child" table also has an owner column, with a cascading foreign key to the parent table. So if change parent.owner, then this changes all children.owners as well</p></li> <li><p>Use updateable CHECK OPTION views to enforce security.</p></li> <li><p>You need to set current_user from your application. <a href="https://stackoverflow.com/questions/2998597/switch-role-after-connecting-to-database/19602050#19602050">Here's how</a> for pg + spring</p></li> </ol> <p>In Postgres:</p> <pre><code>create schema protected; create table protected.foo ( foo_id int primary key, bar text, owner name not null default_current user ); create table protected.foo_children ( foo_child_id int primary key, foo_id int not null references foo(food_id), owner name not null default current_user references foo(owner) on update cascade ); </code></pre> <p>Now some CHECK OPTION views - use security_barrier if postgres:</p> <pre><code>create view public.foo with (security_barrier) as select * from protected.foo where owner = current_user WITH CHECK OPTION; create view public.foo_children with (security_barrier) as select * from protected.foo_children where owner = current_user WITH CHECK OPTION; grant delete, insert, select, update on public.foo to some_users; grant delete, insert, select, update on public.foo_children to some_users; </code></pre> <p>For sharing, you need to add some more tables. The important thing is that you can index the right columns so that you don't kill performance:</p> <pre><code>create schema acl; create table acl.foo ( foo_id int primary key references protected.foo(foo_id), grantee name not null, privilege char(1) not null ); </code></pre> <p>Update your views:</p> <pre><code>create or update view public.foo with (security_barrier) as select * from protected.foo where owner = current_user or exists ( select 1 from acl.foo where privilege in ('s','u','d') and grantee = current_user) ); --add update trigger that checks for update privilege --add delete trigger that checks for delete privilege </code></pre> |
11,628,374 | 0 | <p>The reason to use a double here is the attempt to provide enough accuracy. </p> <p>In detail: The systems interrupt time slices are given by <em>ActualResolution</em> which is returned by <code>NtQueryTimerResolution()</code>. NtQueryTimerResolution is exported by the native Windows NT library NTDLL.DLL. The System time increments are given by <em>TimeIncrement</em> which is returned by <code>GetSystemTimeAdjustment()</code>.</p> <p>These two values are determining the behavior of the system timers. They are integer values and the express 100 ns units. However, this is already insufficient for certain hardware today. On some systems <em>ActualResolution</em> is returned 9766 which would correspond to 0.9766 ms. But in fact these systems are operating at 1024 interrupts per second (tuned by proper setting of the multimedia interface). 1024 interrupts a second will cause the interrupt period to be 0.9765625 ms. This is of too high detail, it reaches into the 100 ps regime and can therefore not be hold in the standard <em>ActualResolution</em> format.</p> <p>Therefore it has been decided to put such time-parameters into double. But: This does <strong>not</strong> mean that all of the posible values are supported/used. The granularity given by <em>TimeIncrement</em> will persist, no matter what.</p> <p>When dealing with timers it is always advisable to look at the granularity of the parameters involved.</p> <p>So back to your question: <code>Can Interval support values like 5.768585 (ms) ?</code></p> <p><strong>No</strong>, the system I've taken as an example above cannot.</p> <p><strong>But it can support 5.859375 (ms)!</strong></p> <p>Other systems with different hardware may support other numbers.</p> <p>So the idea of introducing a double here is not such a stupid idea and actually makes sense. Spending another 4 bytes to get things finally right is a good investment.</p> <p>I've summarized some more details about Windows time matters <a href="http://www.windowstimestamp.com/description" rel="nofollow">here</a>.</p> |
7,950,654 | 0 | <p>Try this, while calling your <strong>MainMenu</strong> activity from <strong>Game</strong> activity:</p> <pre><code>Intent intent = new Intent(this, MainMenu.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); this.startActivity(intent); </code></pre> <p>Hope this would help.</p> |
37,975,201 | 0 | <p>I was able to resolve it by replacing <code>'</code> with <code>%27</code>.</p> <pre><code>data-path="@file.Replace("'","%27")" </code></pre> |
8,794,634 | 0 | <p>MySQL has an <code>UNSIGNED</code> qualifier for integer types.</p> <p>Negative values will be clamped to zero, but will generate a warning:</p> <pre><code>mysql> create table test ( id int(5) unsigned not null ); Query OK, 0 rows affected (0.05 sec) mysql> insert into test values (-1), (5), (10); Query OK, 3 rows affected, 1 warning (0.01 sec) Records: 3 Duplicates: 0 Warnings: 1 mysql> select * from test; +----+ | id | +----+ | 0 | | 5 | | 10 | +----+ 3 rows in set (0.01 sec) </code></pre> |
27,937,346 | 0 | <p>I have used this snippet on my ios app project:</p> <pre><code> window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, success, fail); var target_directory=""; function fail() { //alert("failed to get filesystem"); } function downloadImage(url, filename){ alert("download just started."); try{ var ft = new FileTransfer(); ft.download( url, target_directory + filename, function(entry) { //alert("download complete!:" + entry.nativeURL ); //path of the downloaded file }, function(error) { //alert("download error" + error.code); //alert("download error" + JSON.stringify(error)); } ); } catch (e){ //alert(JSON.stringify(e)); } } function success(fileSystem) { target_directory = fileSystem.root.nativeURL; //root path downloadImage(encodeURI("http://upload.wikimedia.org/wikipedia/commons/2/22/Turkish_Van_Cat.jpg"), "cat.jpg"); // I just used a sample url and filename } </code></pre> |
31,439,918 | 0 | <pre><code>with x as (select *, row_number() over(order by SYS_CREAT_TS desc) as rn from DATA_STUS) SELECT RVSN FROM x WHERE rn =1 and DATA_STUS_CD = 2 </code></pre> <p>If the data needs partitioning by a column, add it to the <code>over</code> clause so you get the desired results.</p> |
27,625,987 | 0 | <p>try</p> <pre><code>moveResult.MoveParts.map(function (movePart) { console.log(movePart.From); }; </code></pre> |
32,811,935 | 0 | <p>If you want to add five hours to <code>startTimePoint</code>, it's boringly simple:</p> <pre><code>startTimePoint += hours(5); // from the alias std::chrono::hours </code></pre> <p><a href="http://coliru.stacked-crooked.com/a/58b599e11f0bc13e" rel="nofollow">Live example</a>.</p> <p>By the way, you're trying to convert a <code>steady_clock::now()</code> into a <code>system_clock::time_point</code>, which <a href="http://coliru.stacked-crooked.com/a/9c2dd186ee0f6522" rel="nofollow">shouldn't even compile</a>. Change the <code>steady_clock::now()</code> to <code>system_clock::now()</code> and you should be good to go.</p> |
19,669,246 | 0 | <p>In the code you have posted above, there is no retain cycle.</p> <p>A retain cycle would be <code>self.A = self;</code> or more likely, <code>self.A.someStrongProperty = self</code>.</p> <p><strong>Edit:</strong> In the case you have edited above, assuming <code>self</code> is a view controller, it would not deallocate because of the retain cycle. You should change your <code>someStrongProperty</code> to be a <code>weak</code> property, which will prevent the retain cycle.</p> |
10,798,274 | 0 | Opening a database connection in a constructor, when should I close it? <p>well, I've been thinking of making database requests a little faster by keeping the connection to the database open as long as the object is being used. So I was thinking of opening the connection in the constructor of that class. Now the question is, how can I close the connection after I stopped using? I have to call close() somewhere, don't I? I've been reading about the finalize() method, but people seemed to be skeptical about usage of this method anywhere at all. I'd expect it to have something like a destructor, but Java doesn't have that, so?</p> <p>So could anyone provide me with a solution? Thanks in advance.</p> |
33,335,890 | 0 | <p>Just plot each segment separately. This also allows for more flexibility as you can independently change the colors, add direction arrows, etc, for each connection.</p> <p>Here, I used a Python dictionary to hold your connectivity info.</p> <pre><code>import matplotlib.pyplot as plt coords = [(0.0, 0.0), (1.0, 1.0), (1.0, 0.0), (2.0, 1.0), (2.0, 0.0), (3.0, 1.0)] connectivity = {0: (1,2), #coords[0] <--> coords[1], coords[2] 1: (0, 2, 3), #coords[1] <--> coords[0], coords[2], coords[3] 2: (0, 1, 4), #coords[2] <--> coords[0], coords[1], coords[4] 3: (1, 3, 5), #coords[3] <--> coords[1], coords[3], coords[5] 4: (2, 3, 5), #coords[4] <--> coords[2], coords[3], coords[5] 5: (3, 4) #coords[5] <--> coords[3], coords[4] } x, y = zip(*coords) plt.plot(x, y, 'o') # plot the points alone for k, v in connectivity.iteritems(): for i in v: # plot each connections x, y = zip(coords[k], coords[i]) plt.plot(x, y, 'r') plt.show() </code></pre> <p><a href="https://i.stack.imgur.com/EUIBv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EUIBv.png" alt="enter image description here"></a></p> <p>There are duplicate lines here based on how you presented the connectivity, for example, <code>(0,1)</code> and <code>(1,0)</code>. I'm assuming that you'll eventually want to put in the direction, so I left them in.</p> |
24,630,478 | 0 | <p>If you are using .Net 4.5 you can save yourself some key strokes and use the TPL</p> <pre><code>for (int i = 0; i < count; i++) { Task.Run(() => cl.Print("id","password")); } </code></pre> |
11,516,282 | 0 | <p>If rob's post did not work, then i would try typing in bt (for backtrace) in the console</p> |
39,067,961 | 0 | My imported eclipse project gives error the project was not build since the build path is incomplete. Cannot find the class file for java.lang.object <p>i have imported a existing project to eclipse but it gives errors for java files only i have set libraries i have also set window>preferences>installed jres.BUt the problem is not solved. The error message is the project was not build since the build path is incomplete. Cannot find the class file for java.lang.object. Fix the error. <a href="http://i.stack.imgur.com/4upHD.png" rel="nofollow">error screenshot</a></p> |
35,065,788 | 0 | How to determine the vendor/bin directory of Composer in a library? <p>Is there a reliable way to determine the local <code>vendor/bin</code> directory of an application from within a library? What I really want is the following:</p> <p>I am writing a library that depends on a third library. This third library ships with a binary, that is installed in the local <code>vendor/bin</code> of the main application. My library needs to have the possibility to execute this binary. I could probably hack something using <code>__DIR__/../...../bin</code> but that feels not very good an is probably <em>not</em> reliable.</p> |
16,402,013 | 0 | Select all records of a type <p>I'm trying to get all records of specific type from RavenDB with C#.</p> <p>When I'm using Lucene:</p> <pre><code> var serviceTraces = session.Advanced.LuceneQuery<ServiceTrace>("IDLoadDateIndex").Take(50); </code></pre> <p>I'm getting the results in: </p> <p>serviceTraces.QueryResult.Results</p> <p>When I'm not using Lucene:</p> <pre><code>var serviceTraces = session.Query<ServiceTrace>("IDLoadDateIndex").Take(50); </code></pre> <p>I'm not getting any results and an exception is thrown when trying to perform "ToList()" on "serviceTraces" object.</p> <p>Why is that ?</p> <p><strong>UPDATE:</strong></p> <p>ServiceTrace class:</p> <pre><code>public class ServiceTrace { public ServiceTrace(ServiceDeployment sd) { // TODO: Complete member initialization this.ServiceDeploymentID = sd.Id; } public string Id { get; set; } public string TransactionID { get; set; } public string ParentTransactionID { get; set; } public string RequestID { get; set; } public int ApplicationCode { get; set; } public int InstituteCode { get; set; } public string ServiceDeploymentID { get; set; } public string UserHostAddress { get; set; } public string UserAgent { get; set; } public string Username { get; set; } public DateTime RequestDateTime { get; set; } public DateTime ResponseDateTime { get; set; } public string RequestBody { get; set; } public string ResponseBody { get; set; } public string Key1Value { get; set; } public string Key2Value { get; set; } public string Key3Value { get; set; } public string Key4Value { get; set; } public string Key5Value { get; set; } public int StatusCode { get; set; } public string StatusDescription { get; set; } public string FullExceptionText { get; set; } public DateTime LoadDate { get; set; } public DateTime ActivationDateTime { get; set; } public string HostAddress { get; set; } public string BpmID { get; set; } public DateTime PreProcessDatetime { get; set; } public string DestHostAddress { get; set; } public string ArchivePath { get; set; } public string BTInstanceID { get; set; } public string Temp1 { get; set; } public string ExternalComponentDuration { get; set; } public string SQLIdentity { get; set; } public string ExceptionCode { get; set; } public string CertificateID { get; set; } public string ExternalComponentType { get; set; } public string ActivationID { get; set; } } </code></pre> <p>IDLoadDateIndex:</p> <pre><code>public class IDLoadDateIndex : AbstractIndexCreationTask<ServiceTrace> { public IDLoadDateIndex() { Map = serviceTrace => from st in serviceTrace select new { LoadDate = st.LoadDate }; Index(x => x.LoadDate, FieldIndexing.Analyzed); } } </code></pre> |
646,295 | 0 | <p>This is what I do for MVC + AJAX...</p> <p>Really simple implementation, if you were to ask me.</p> <p><a href="http://jarrettatwork.blogspot.com/2009/02/aspnet-mvc-ajax-brief-introduction.html" rel="nofollow noreferrer">http://jarrettatwork.blogspot.com/2009/02/aspnet-mvc-ajax-brief-introduction.html</a></p> |
22,126,424 | 0 | <p>I don't have access handy, but I'll give it a shot "free hand" and see how it goes :)<br> Since Access does not (afaik) have <code>CASE</code>, the trick would seem to be to use <code>IIF</code>;</p> <pre class="lang-sql prettyprint-override"><code>SELECT SUM(Total) as RoomRevenue, SUM(ExtraCharges) AS Extra, SUM(Discount) AS DiscountGiven, SUM(Tax) AS TaxCollection, SUM(GrandTotal) AS TotalCollection, SUM(IIF(ExtraChargesType = 'Tickets', ExtraCharges, 0)) AS TheatreTickets, SUM(IIF([CheckInDate])<=[regDate] AND [CheckOutDate])>=[regDate], 1, 0)) AS OcuppiedRooms regDate FROM tblRegistration GROUP BY regDate; </code></pre> |
13,109,827 | 0 | <p>if you have exact the format <code>+Z (YYY) XXX-XX-XX</code>:</p> <pre><code>var num = input.replace( '/^\+\S+\s\((\d{3})\)\s(\d{3})-(\d{2})-(\d{2})$/', '\1\2\3\4' ); </code></pre> <p>but a more tolerant variant would be</p> <pre><code>var num = input.replace( '/^(\+\S+|\D/', '' ); </code></pre> |
5,932,874 | 0 | How can I use Visual basic to download the file I want in URl? <p>I'd like to downlowd one file chosen form this url</p> <blockquote> <p><a href="http://www.senao.com.tw/download.aspx" rel="nofollow">http://www.senao.com.tw/download.aspx</a></p> </blockquote> <p>But I need to use Visual Basic to autodownload form this url. Without click on it. so, can I finish the work? </p> |
18,835,256 | 0 | <p>I realized I can just add the icons as background images using the menu-item classes. Inelegant, but functional.</p> |
9,499,804 | 0 | <p>The PHP driver just returns the fields from MongoDB in whatever order MongoDB sends them. So, regardless of how you select the fields you wish to return, the data sent back won't change (unless you alter the fields list of course). Why don't you just order the results yourself after they are returned?</p> |
33,747,893 | 0 | Visual Studio 2015 "non-standard syntax; use '&' to create pointer for member" <p>I'm creating a quick game and I used a different class file for inputting player names. I keep getting the specified error :</p> <blockquote> <p>use '&' to create pointer for member</p> </blockquote> <p>when I am trying to call the function from main. </p> <p>The function <code>getPlayerOne</code> and <code>getPlayerTwo</code> are public functions. I think it's because I'm changing the <code>player1</code> value so I need a pointer but when I try to add a pointer it gives me the same error. </p> <p>How do I edit values of strings using pointers?</p> <p>main:</p> <pre><code>#include <iostream> #include <string> //Included Header Files #include "Player.h" using namespace std; int main() { Player players; cout << players.getPlayerOne << endl; cout << players.getPlayerTwo << endl; } </code></pre> <p>Player.h:</p> <pre><code>#pragma once #include <iostream> #include <string> using namespace std; class Player { public: //Initialize player1 void getPlayerOne(string &playerOne); void getPlayerTwo(string &playerTwo); Player(); private: //Players string player1; string player2; }; </code></pre> <p>Player.cpp</p> <pre><code>#include "Player.h" Player::Player() { } void Player::getPlayerOne(string &playerOne) { cout << "Enter player 1 name: \n"; cin >> playerOne; cout << playerOne << " is a great name!\n"; player1 = playerOne; } void Player::getPlayerTwo(string &playerTwo) { cout << "Enter player 2 name: \n"; cin >> playerTwo; cout << playerTwo << " is a great name!\n"; player2 = playerTwo; } </code></pre> <p>I could probably just put the <code>Player</code> code in main because it's so small, but I think it is better to have separate classes when (eventually) I can program files with more characters.</p> |
25,552,137 | 0 | <p>I'll copy paste my answer from <a href="http://stackoverflow.com/a/25552002/3987202">http://stackoverflow.com/a/25552002/3987202</a><br><br> Another solution for those of us who can't make the jump to Hibernate 4.1.3.<br> Simply use <code>/*'*/:=/*'*/</code> inside the query. Hibernate code treats everything between <code>'</code> as a string (ignores it). MySQL on the other hand will ignore everything inside a blockquote and will evaluate the whole expression to an assignement operator.<br> I know it's quick and dirty, but it get's the job done without stored procedures, interceptors etc.</p> |
24,254,845 | 0 | <p>Finally, I find there's a lock when compiling prepared statements. I was compiling a new prepared statement whenever a new request come in, after I changed to reuse it I got my app server scale. However, I still don't know why cross-region case can scale.</p> |
16,943,441 | 0 | Safari crashes instantly when trying to debug iPad Simulator app <p>I realize that this is a long-shot... but I'm looking for tips or advice on how to prevent or debug this issue.</p> <p>If I start my app in the iPad simulator (webapp using phonegap), then start Safari and select Develope->iPad Simulator->index.html - Safari immediately crashes. The odd thing is that I'm one of several developers working on this app... and we all have seemingly identical setups - yet this doesn't happen for them. They are able to debug in Safari as expected. I should also mention that the app itself works great in the simulator.</p> <p>Software involved: Xcode 4.6.2 Safari 6.0.5 Running simulator for iPad 6.1</p> <p>Again, I realize that this isn't much to go on. Hoping someone might be able to point me in the right direction to figure it out.</p> |
4,205,321 | 0 | <p>I had this problem and it took me forever to figure out. The Child table has to allow nulls on it's parent foreign key. NHibernate likes to save the children with NULL in the foreign key column and then go back and update with the correct ParentId.</p> |
20,559,968 | 0 | <p>We can use another approach without bit shift to convert <code>bytes</code> to <code>short</code> without shift by using <code>java.nio.ByteBuffer</code></p> <pre><code>ByteBuffer bb = ByteBuffer.allocate(2); bb.order(ByteOrder.LITTLE_ENDIAN); bb.put(nTempByteArr[1]); bb.put(nTempByteArr[0]); short shortVal = bb.getShort(0); </code></pre> <p>and we can use the <code>get</code> function of <code>ByteBuffer</code> will help us back to get <code>bytes</code></p> <pre><code>bb.putShort(ShortValue); nTempByteArr[0] = bb.get(0); nTempByteArr[1] = bb.get(1); </code></pre> |
15,945,306 | 0 | <p>From your code and exception actually you have an Object[] at pos[targetPos3].</p> <p>You cannot cast that to HashSet.</p> |
17,169,661 | 0 | How to unselect the parent checkbox when their child checkbox is unchecked using Jquery? <p>I am using asp.net tree view control. And using Jquery to select all the corresponding child check box when its parent is checked. The working Jquery and the rendered HTML is in here...<a href="http://jsfiddle.net/srk1982/Gak2h/7/" rel="nofollow">JS Fiddle</a></p> <p>Jquery to select the checkbox :</p> <pre><code> $('.tree').on('change', ':checkbox', function () { var checked = this.checked; var $elem = $(this).closest('table'); var depth = $elem.find('div').length; var $childs = $elem.nextAll('table'); $childs.each(function () { var $child = $(this); var d = $child.find('div').length; if (d <= depth) { return false; } $child.find(':checkbox').prop('checked', checked); }); }); </code></pre> <p>But I do not know how to unselect the parent node when one of its child item is checked. Help needed..</p> |
27,017,971 | 0 | Changing an unhandled exception to a handled one in a finally block <p>Consider this program:</p> <pre><code>using System; static class Program { static void Main(string[] args) { try { try { throw new A(); } finally { throw new B(); } } catch (B) { } Console.WriteLine("All done!"); } } class A : Exception { } class B : Exception { } </code></pre> <p>Here, an exception of type <code>A</code> is thrown for which there is no handler. In the <code>finally</code> block, an exception of type <code>B</code> is thrown for which there is a handler. Normally, exceptions thrown in <code>finally</code> blocks win, but it's different for unhandled exceptions.</p> <p>When debugging, the debugger stops execution when <code>A</code> is thrown, and does not allow the <code>finally</code> block to be executed.</p> <p>When not debugging (running it stand-alone from a command prompt), a message is shown (printed, and a crash dialog) about an unhandled exception, but after that, "All done!" does get printed.</p> <p>When adding a top-level exception handler that does nothing more than rethrow the caught exception, all is well: there are no unexpected messages, and "All done!" is printed.</p> <p>I understand how this is happening: the determination of whether an exception has a handler happens before any <code>finally</code> blocks get executed. This is generally desirable, and the current behaviour makes sense. <code>finally</code> blocks should generally not be throwing exceptions anyway.</p> <p>But <a href="http://stackoverflow.com/questions/2911215/what-happens-if-a-finally-block-throws-an-exception">this other Stack Overflow question</a> cites the C# language specification and claims that the <code>finally</code> block is required to override the <code>A</code> exception. Reading the specification, I agree that that is exactly what it requires:</p> <blockquote> <ul> <li>In the current function member, each <code>try</code> statement that encloses the throw point is examined. For each statement <code>S</code>, starting with the innermost try statement and ending with the outermost try statement, the following steps are evaluated: <ul> <li>If the <code>try</code> block of <code>S</code> encloses the throw point and if S has one or more <code>catch</code> clauses, the catch clauses are examined [...]</li> <li>Otherwise, if the <code>try</code> block or a <code>catch</code> block of <code>S</code> encloses the throw point and if <code>S</code> has a <code>finally</code> block, control is transferred to the <code>finally</code> block. If the <code>finally</code> block throws another exception, processing of the current exception is terminated. Otherwise, when control reaches the end point of the <code>finally</code> block, processing of the current exception is continued.</li> </ul></li> <li>If an exception handler was not located in the current function invocation, the function invocation is terminated, and one of the following occurs: <ul> <li>[...]</li> </ul></li> <li>If the exception processing terminates all function member invocations in the current thread, indicating that the thread has no handler for the exception, then the thread is itself terminated. The impact of such termination is implementation-defined.</li> </ul> </blockquote> <p>An exception isn't considered unhandled, according to my reading of the spec, until <em>after</em> all function invocations have been terminated, and function invocations aren't terminated until the <code>finally</code> handlers have executed.</p> <p>Am I missing something here, or is Microsoft's implementation of C# inconsistent with their own specification?</p> |
27,536,672 | 1 | A dict-like class that uses transformed keys <p>I'd like a dict-like class that transparently uses transformed keys on lookup, so that I can write</p> <pre><code>k in d # instead of f(k) in d d[k] # instead of d[f(k)] d.get(k, v) # instead of d.get(f(k), v) </code></pre> <p>etc. (Imagine for example that <code>f</code> does some kind of canonicalization, e.g. <code>f(k)</code> returns <code>k.lower()</code>.)</p> <p>It seems that I can inherit from <code>dict</code> and override individual operations, but not that there is a centralized spot for such transformation that all keys go through. That means I have to override all of <code>__contains__</code>, <code>__getitem__</code>, <code>get</code>, and possibly <code>__missing__</code>, etc. This gets too tedious and error-prone, and not very attractive unless this overhead outweighs that of manually substituting <code>f(k)</code> for every call on a plain <code>dict</code>.</p> |
32,568,700 | 0 | Install Old XML R Package From Source On Windows <p>I'm trying to install this package from source on Windows and cannot work out what is going on and what I need to do in order to get this working.</p> <p>I have the tar-gz file from CRAN, I have R-3.1.2 installed and RTools installed. </p> <p>When I try to install this package I get the following error:</p> <pre><code>* installing *source* package 'XML' ... ** package 'XML' successfully unpacked and MD5 sums checked ** libs *** arch - i386 gcc -m32 -I"C:/PROGRA~1/R/R-31~1.2/include" -DNDEBUG -I/include/libxml2 -I/include -D_R_=1 -DUSE_R=1 -DUSE_XML_VERSION_H=1 -DLIBXML -DUSE_EXTERNAL_SUBSET=1 -DROOT_HAS_DTD_NODE=1 -DUMP_WITH_ENCODING=1 -DXML_ELEMENT_ETYPE=1 -DXML_ATTRIBUTE_ATYPE=1 -DLIBXML2=1 -DHAVE_XML_HAS_FEATURE -DLIBXML_STATIC -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O3 -Wall -std=gnu99 -mtune=core2 -c DocParse.c -o DocParse.o In file included from DocParse.c:10:0: DocParse.h:18:27: fatal error: libxml/parser.h: No such file or directory compilation terminated. make: *** [DocParse.o] Error 1 Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R-31~1.2/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-31~1.2/share/make/winshlib.mk" SHLIB="XML.dll" OBJECTS="DocParse.o EventParse.o ExpatParse.o HTMLParse.o NodeGC.o RSDTD.o RUtils.o Rcatalog.o Utils.o XMLEventParse.o XMLHashTree.o XMLTree.o fixNS.o libxmlFeatures.o schema.o xmlsecurity.o xpath.o"' had status 2 ERROR: compilation failed for package 'XML' </code></pre> <p>Which seems that this is the actual problem:</p> <pre><code>DocParse.h:18:27: fatal error: libxml/parser.h: No such file or directory compilation terminated. </code></pre> <p>So I've grabbed libxml2 from here:</p> <p><a href="http://www.zlatkovic.com/libxml.en.html" rel="nofollow">http://www.zlatkovic.com/libxml.en.html</a></p> <p>But I have literally no idea what to do next.</p> <p>In the source for the libxml2 I can see the parser.h file mentioned in the error but what do I do with it or the library in order to get this install working?</p> |
27,132,432 | 0 | How to debug %post with rpmbuild <p>I'm building an RPM that needs to run a number of scripts to configure it after it's been installed to complete the installation. I have to run the scripts in the %post section because the configuration is dependent upon the type of host. All this is fairly easy and well, but every time I run into a bug with the %post section, I have to rebuild the entire package which takes about 20 minutes. Is there a way to skip recompiling everything and just build a new package with just the changes from %post?</p> |
2,185,287 | 0 | <p>Yes, as long as your controller inherits from Controller (which it must in order to work as an MVC controller), you can use the same syntax without the <%= %>.</p> <pre><code>Dim url = Url.Action("myAction", "myController", New With { ... }) </code></pre> <p>alternatively if you reference the MVCContrib DLL, you will have access to strongly typed helpers, and be able to do something like:</p> <pre><code>Dim url = Url.Action(Of myController)(function(a) a.myAction(ID)) </code></pre> <p>my VB coding days are dated, so forgive me if the syntax is a bit fudged</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.