pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
12,976,403
0
<p>Since you are showing the child form as a dialog, and the parent form doesn't need it until the form as closed, all you need to do is add a property with a public getter and private setter to the child form, set the value in the child form whenever it's appropriate, and then read the value from the main form after the call to <code>ShowDialog</code>.</p>
10,185,165
0
FaceBook UI is not populating multiple friends selected <p>I am using an FB.ui 'apprequests' method to select friends,and it is happening. Then i am redirecting from there to a Send Message pop up (FB.ui 'send' method). Before, the 'To:' section in the pop up was populating multiple friends. But now its showing only the first selected friend.Your suggestions are welcome.</p> <p>The code looks like this,</p> <pre><code>$('#sendinvite').click(function () { FB.ui ({ method: 'apprequests', message: "sds" },send_Message); }); function send_Message(response) { var eventName = 'Event Name'; var varMessage ="You are invited for " + eventName; console.log(response.to); FB.ui ({ method: 'send', to: response.to, name: 'People Argue Just to Win', description: varMessage, link: 'http://www.techvantagesystems.com' }); } </code></pre>
14,367,196
0
WM_PAINT Bitblitting multiple times? <p>This is for C++ - win32. Basically I've loaded an image (bmp) into a HBITMAP from a file and bitblitted it to the device context for the main window.</p> <p>How would I call it again in case I want to change the image?</p> <p>I've called InvalidateRectangle() and UpdateWindow() but that causes the window controls to flicker.</p>
5,112,552
0
<p>According to <a href="http://en.wikipedia.org/wiki/Q-learning" rel="nofollow">Wikipedia</a>, gamma has to be strictly less than one.</p>
30,429,279
0
<p>Sorry, I just disabled line wrapping on the tooltip by using the <code>white-space</code> in the css file and then checked if the tooltip isn't visible by the jQuery <code>$("#element").visible()</code> and changed positions with css from the JS file :)</p>
28,873,015
0
<p>I had the similar problem, I did the same as you have done and was getting 404 error for the PNG. When reviewed the other requests that are made, I came up with, you must pass the "package name" in the parameter logo as well. </p> <p>Just as;</p> <pre><code>$scope.image = { logo: 'system/assets/img/logo.png' }; </code></pre> <p>Than the logo is displayed as desired</p>
28,447,945
0
<p>method 1.you can use load data command </p> <pre><code>http://blog.tjitjing.com/index.php/2008/02/import-excel-data-into-mysql-in-5-easy.html </code></pre> <p>method 2. Excel reader</p> <p><a href="https://code.google.com/p/php-excel-reader/" rel="nofollow">https://code.google.com/p/php-excel-reader/</a></p> <p>method 3. parseCSV</p> <pre><code>https://github.com/parsecsv/parsecsv-for-php </code></pre> <p>method4. (PHP 4, PHP 5) fgetcsv</p> <pre><code> http://in1.php.net/fgetcsv </code></pre>
37,004,827
0
<p>You need to lerp (linearly interpolate) between the two textures. Your fragment shader needs to hold both textures and then trigger lerping once you load the second texture, the one that you want to change to. Than use operation like <code>col = fromTex.rgb * (1.0-t) + toTex.rgb * t</code> and change the blending/lerping coefficient <code>t</code> throughout the time until you completely blend into the second texture. <code>t</code> can be sent as a uniform that would be slowly changing from the <code>0.0-&gt;1.0</code> over the time.</p>
21,932,574
0
From second time "In app purchase" throwing exception in android <p>I Am trying to include in app purchase and i have successfully through in showing up SKUs available.Now I want to make a fake purchase.So I used appId = "android.test.purchased". For the first time it worked flawlessly, but from next it is throwing exception as below.</p> <p>Attempt to invoke virtual method 'android.content.IntentSender android.app.PendingIntent.getIntentSender()' on a null object reference</p> <p>Has any body come across such situation?Please help out.</p> <pre><code>package com.inappbilling.poc; import java.util.ArrayList; import org.json.JSONObject; import android.app.Activity; import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import com.android.vending.billing.IInAppBillingService; public class TestInAppPurchase extends Activity { private final static String SERVICE_INTENT = "com.android.vending.billing.InAppBillingService.BIND"; private static final String _TAG = "BILLING ACTIVITY"; private final String _testSku = "android.test.purchased"; //available skus static final String SKU_7DAYS = "7days"; static final String SKU_30DAYS = "30days"; private Button _7daysPurchase = null; private Button _30daysPurchase = null; private IInAppBillingService _service = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.d(_TAG, "created"); _7daysPurchase = ( Button ) findViewById(R.id.sevendays_btn); _30daysPurchase = ( Button ) findViewById(R.id.thirtydays_btn); _7daysPurchase.setOnClickListener(_purchaseListener); _30daysPurchase.setOnClickListener(_purchaseListener); } @Override protected void onStart() { super.onStart(); } OnClickListener _purchaseListener = new OnClickListener() { @Override public void onClick(View v) { switch ( v.getId() ) { case R.id.sevendays_btn: doPurchase(); break; case R.id.thirtydays_btn: break; } } }; private ServiceConnection _serviceConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { _service = IInAppBillingService.Stub.asInterface( service ); Log.d(_TAG, _service.toString()); } @Override public void onServiceDisconnected(ComponentName name) { _service = null; Log.d(_TAG, "destroyed"); } }; private void doPurchase(){ if ( _service == null) { Log.e( _TAG , "Billing failed: billing service is null "); return; } ArrayList testSku = new ArrayList( ); testSku.add( _testSku ); Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", testSku); Bundle skuDetails ; try { skuDetails = _service.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if( response == 0 ){ ArrayList&lt;String&gt; responseList = new ArrayList&lt;String&gt;( ); responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for( String responseString : responseList ) { JSONObject jobj = new JSONObject( responseString ); String sku = jobj.getString("productId"); if( sku.equals( _testSku )){ Bundle buyIntentBundle = _service.getBuyIntent(3, getPackageName(), sku ,"inapp","" ); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } else { Log.e( _TAG , "Failed " ); } } catch (Exception e) { Log.e( _TAG, "Caught exception !"+ e.getMessage() ); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == 1001 ){ String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); if( resultCode == RESULT_OK ){ try{ JSONObject jobj = new JSONObject( purchaseData ); String sku = jobj.getString(_testSku); String paid = jobj.getString("price"); Log.v("SKU DATA", sku +"============"+ paid); }catch( Exception e) { e.printStackTrace(); } } } } @Override protected void onDestroy() { super.onDestroy(); if( _serviceConnection != null ){ unbindService( _serviceConnection ); } } } </code></pre>
21,252,288
0
<p>You can't call any method from service before it connected. So, you can:</p> <p>1) add progress dialog "Connecting service..." on activity's start</p> <p>2) hide progress dialog after service connected and call placeCallWithOption() from onServiceConnected() (not early).</p>
29,214,004
0
Change the color of the series line dynamically by month <p>I have a series from Jan - Dec, the requirement is to update the last data point to grayscale colors. So I have created additional data series assigning grayscale colors to the series. Can I be able to join the colored series with grayscale colored series</p> <p><a href="http://jsfiddle.net/hgj7sfhp/33/" rel="nofollow">http://jsfiddle.net/hgj7sfhp/33/</a></p> <p>for example, London colored and London grayscale should be joined, like continuouss series after November, without any break in the series. I have London &amp; Berlin in December points in the chart, but i wanted to attached to the colored series, is it possible ?</p> <p>Also group the legend of colored series and grayscale series.</p> <p>London, Berlin</p> <p>LondonGray, BerlinGray</p> <pre><code>$(function () { var grayblue = '#1D1D1D'; var grayred = '#4C4C4C'; dataLondon = [ 48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 45.6, 90.4]; dataBerlin = [ 42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 23.6, 29.1] highcharts(dataLondon, dataBerlin, 0); function highcharts(dataLondon, dataBerlin, number) { $('#container').highcharts({ chart: { type: 'line' }, title: { text: 'Monthly Average Rainfall' }, subtitle: { text: 'Source: WorldClimate.com' }, xAxis: { categories: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ], plotBands: { color: 'Red', from: 10.5, to: 10.55, label: { text: 'I am label' } } }, yAxis: { min: 0, title: { text: 'Rainfall (mm)' } }, tooltip: { headerFormat: '&lt;span style="font-size:10px"&gt;{point.key}&lt;/span&gt;&lt;table&gt;', pointFormat: '&lt;tr&gt;&lt;td style="color:{series.color};padding:0"&gt;{series.name}: &lt;/td&gt;' + '&lt;td style="padding:0"&gt;&lt;b&gt;{point.y:.1f} mm&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;', footerFormat: '&lt;/table&gt;', shared: true, useHTML: true }, colors: ['#0000FF', '#FF0000'], plotOptions: { column: { pointPadding: 0.2, borderWidth: 0 } }, series: [{ name: 'London', data: dataLondon }, { name: 'Berlin', data: dataBerlin }, { name: 'London', data: [null,null,null,null,null,null,null,null,null,null,null,10], color: '#1D1D1D' }, { name: 'Berlin', data: [null,null,null,null,null,null,null,null,null,null,null, 51.1], color: '#4C4C4C' }] }); } }); </code></pre>
28,422,790
0
<p>Per <code>ngInfiniteScroll</code>'s test case of <a href="https://github.com/sroze/ngInfiniteScroll/blob/master/test/spec/ng-infinite-scroll.spec.coffee#L115" rel="nofollow">infinite-scroll-immediate-chec</a>, If this parameter is set as <code>true</code> (the default value), meanwhile the directive's element can not fill up the browser window' height, it will trigger a <code>loadMore()</code> immediately even you don't scroll your window at all. And this action will only be triggered once, therefor if there are 3 three tiny results on first load and they don't reach the bottom, function <code>loadMore()</code> won't be triggered until you scroll the window.</p> <p>While if this parameter is set as false, you have to trigger the first call of <code>loadMore</code> manually or programmably.</p>
26,627,576
0
<p>On Android 5.0 this has changed, you have to call setElevation(0) on your action bar. Note that if you're using the support library you must call it to that like so:</p> <pre><code>getSupportActionBar().setElevation(0); </code></pre> <p>It's unaffected by the windowContentOverlay style item, so no changes to styles are required </p>
19,718,770
0
<p>Perhapse this is what you're looking for:</p> <pre><code>a = [[4, 3, 2, 1], [5, 6, 7, 8], [12, 11, 10, 9]] [sorted(list) for list in a] </code></pre> <p>Returns: <code>[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]</code></p> <p>Or, if you additionally want to sort by the first element:</p> <pre><code>a = [[4, 3, 2, 1], [12, 11, 10, 9], [5, 6, 7, 8]] sorted([sorted(list) for list in a], key=min) </code></pre> <p>Also returns: <code>[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]</code></p>
22,064,095
1
fast system calls in R <p>I have a nest for loop inside which I run a python script using the system call option in R, I found that all the execution time of my code is spent just on the system call in order to run the python script, so I was wondering if there is any tricks that I can use to save this great loss of time spent on repeatedly using the system call especially cause the python script in itself only take 1 second per each call, the problem is that I can't run the .py script independently cause I's using some parameters generated by other parts in R. here is a snapshot of my code and any suggestion is highly appreciated:</p> <pre><code> for(x in 1:10000){ ....... for (y in 1:10000){ ..... x=system("python calc.py -c1 -c2",intern = TRUE) } } </code></pre>
18,638,692
0
Gradient Filling a PNG with Quartz <p>How can I fill the non-transparent areas of a PNG UIImage with a linear gradient? I'd like to reuse a PNG shape for MKAnnotationViews, but change the gradient per annotation's properties.</p>
29,734,434
0
<p>If you want to send a parameter to another page, then you need to set the url and query string in the href tag of an a tag.</p> <p>For example:</p> <pre><code>&lt;a id="myatag" href=""&gt; &lt;!-- Whatever you want the user to click--&gt; &lt;/a&gt; </code></pre> <p>and the js:</p> <pre><code>document.getElementById("myatag").href = "OrderPrint.html?image=" + "sniperImg" + i; </code></pre> <p>Then, you can retrieve the name of the image on the server side script, and append ".jpg" or whatever extension you are using. For example, in PHP:</p> <pre><code>$image = "VideoImages/" + $_GET["image"] + ".jpg"; </code></pre>
10,223,043
0
<p>I think you missed 2 quotes and a +.</p> <p>$('input[name=choices' + k + ']').val();</p>
38,074,230
0
<p>You can match number with decimals only or numbers with integer and decimal parts:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>for (var x in arr = ["ZAR 200.15", "300.0", "1.02", "29.001", "10"]) { // decimal part only console.log(x, arr[x].match(/(\d+)(\.\d+)?/g)) // integer + decimal part console.log(x, arr[x].match(/(\d+\.\d+)/g)) }</code></pre> </div> </div> </p>
36,007,311
0
<p>Give a try to below AFNetworking snippet,</p> <pre><code>+(void)downloadImageFromUrl:(NSURL*)url forImageView:(UIImageView*)imageView { NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url]; AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; requestOperation.responseSerializer = [AFImageResponseSerializer serializer]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [imageView setImage: responseObject]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Image error: %@", error); }]; [requestOperation start]; } </code></pre>
29,690,401
0
<p>Try this in the place of while loop:</p> <pre><code>&lt;?php $res = mysqli_query($conn,"select * from dept_manager"); echo"dept_manager"; echo "&lt;table&gt;"; while($row=mysqli_fetch_assoc($res)) { echo "&lt;tr&gt;&lt;td&gt;" . $row['emp_no'] . "&lt;/td&gt;&lt;td&gt;" . $row['dept_no'] . "&lt;/td&gt;&lt;td&gt;" . $row['from_date'] . "&lt;/td&gt;&lt;td&gt;" . $row['to_date'] . "&lt;/td&gt;&lt;/tr&gt;"; } echo "&lt;/table&gt;"; ?&gt; </code></pre>
6,678,622
0
<p>Others have already told you that what you've asked for isn't possible, as HTML attributes must be plain text, not more HTML.</p> <p>They've also told you that there are Javascript and JQuery libraries which will help you do what you're wanting to do. There are loads of scripts you could use, here's a link to one that you might want to try: <a href="http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/" rel="nofollow">http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/</a></p> <p>However, I feel I should add one further point which others have missed, and which is actually quite important:</p> <p><strong>You're using the wrong attribute.</strong></p> <p>The <code>alt</code> attribute is <em>not</em> the correct attribute to use for a hover tooltip effect. You should be using the <code>title</code> attribute for this.</p> <p>Using <code>alt</code> works this way for historic reasons in some browsers (I believe it works in IE, but not much else), but it is <em>not</em> intended as a tooltip. The correct use of <code>alt</code> is for a small bit of descriptive text that will appear if the image is not loaded. This could be because the file failed to load, or the user has images turned off, or the user has a text-to-speech browser, etc, but if the image is displayed, then this text should never be displayed.</p> <p>The <code>title</code> attribute on the other hand is intended to be displayed, and all browsers implement it as a tooltip (in fact, it's not just on <code>&lt;img&gt;</code> tags; you can use <code>title</code> for <em>any</em> element).</p> <p>Hope that helps.</p>
25,470,471
0
<p>Instead of checking null try below code</p> <pre><code> Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; if (!localSettings.Values.ContainsKey("waslaunched")) { localSettings.Values.Add("waslaunched", "launched"); } </code></pre> <p>Hope this helps!</p>
39,856,051
0
<p>Since you're using PS3+, instead of joining the lines (it's slow), read the file as one string via <code>-Raw</code>:</p> <pre class="lang-ps prettyprint-override"><code>$content = Get-Content $filepath -Raw | ConvertFrom-Json </code></pre> <ul> <li><p>Filtering by name, showing contents without name:</p> <pre class="lang-ps prettyprint-override"><code>$name = 'Child1' $content.Root.$name | ConvertTo-Json </code></pre> <p>In PS2.0:</p> <pre class="lang-ps prettyprint-override"><code>$content.Root | Select -expand $name | ConvertTo-Json </code></pre></li> <li><p>Filtering by name, showing name and contents:</p> <pre class="lang-ps prettyprint-override"><code>$name = 'Child1' ($content.Root | select $name | ConvertTo-Json) -replace '^.|.$','' </code></pre></li> <li><p>Filtering by <code>Id</code>, showing contents:</p> <pre class="lang-ps prettyprint-override"><code>$content.Root | ForEach { $_.PSObject.Properties.Value | Where Id -eq 2 } | ConvertTo-Json </code></pre></li> <li><p>Filtering by <code>Id</code>, showing name and contents of the node:</p> <pre class="lang-ps prettyprint-override"><code>($content.Root | ForEach { $_.PSObject.Properties | Where { $_.Value.Id -eq 2 } | ForEach { @{$_.Name = $_.Value} } } | ConvertTo-Json ) -replace '^.|.$','' </code></pre></li> </ul>
21,924,406
0
<p>I believe there are a few questions asked, so I will answer them accordingly in the comments:</p> <blockquote> <ol> <li>I'd like the label to display the current selection of the date picker</li> <li>updating every time the date picker is adjusted</li> <li>in the format as the following, Sunday 9th February 2014 14:00</li> <li>set the picker so that users can only choose a date and time in the future, nothing from the past!</li> </ol> </blockquote> <pre><code>//declared as a property UIDatePicker *dateTimePicker; NSDateFormatter *dateFormatter; UILabel *lblDateDisplay; NSDate *selectedDate; //in your viewdidload dateFormatter = [[NSDateFormatter alloc] init]; dateTimePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 300, 220)]; //whatever you want it, I am just listing an example [dateTimePicker setDatePickerMode:UIDatePickerModeDateAndTime]; [dateTimePicker setHidden:NO]; [dateTimePicker setDate:[NSDate date]]; [dateTimePicker setMinimumDate: [NSDate date]]; //no.4 [dateTimePicker addTarget:self action:@selector(dateChangedValue) forControlEvents:UIControlEventValueChanged]; //no.2 //create another method called, dateChangedValue - (void) dateFromChangedValue { selectedDate = dateTimePicker.date; [dateFormatter setDateFormat:@"EEEE dd MMM YYYY HH:mm"]; //no.3 lblDateDisplay.text = [NSString stringWithFormat:@"%@", [dateFormatter stringFromDate:selectedDate]; //no.1 } </code></pre> <p>There, I am done. I guess you could try these codes.</p>
137,750
0
<ol> <li><p>Get the query text of your view.</p> <pre><code>SELECT text FROM dba_views WHERE owner = 'the-owner' AND view_name = 'the-view-name'; </code></pre></li> <li><p>Parse. Search for view names within the query text.</p></li> <li><p>Get the query text for each view name found. (see item 1.)</p></li> <li><p>Replace each view name in the query with the related query text.</p></li> <li><p>Do this recursively until there are no more views found.</p></li> </ol> <p>Easy?</p> <p><strong>EDIT:</strong> The above instructions do not do everything required. Thinking about this a little more it gets hairy, grows legs, and maybe another arm. Finding column names, and column names that might be elaborate functions and subqueries. Bringing it all back together with the joins and clauses. The resulting query might look very ugly.</p> <p>Somewhere within Oracle there may be something that is actually unwrapping a view. I don't know. I am glad I didn't use views that much in Oracle.</p>
17,097,342
0
<p>The ODP.NET managed data provider does not support code-first development with the Entity Framework. From its readme.txt in odp.net/doc under the oracle client dir:</p> <p>"7. ODP.NET 11.2.0.3 does not support Code First nor the DbContext APIs."</p> <p>You'll have to use the model-first or database-first approach.</p>
40,716,909
0
<p>I suggest kind of <em>meet in the middle</em> algorithm:</p> <pre><code> A[i] + B[j] + C[k] + D[l] = 0 </code></pre> <p>actually means to find out <code>A[i] + B[j]</code> and <code>C[k] + D[l]</code> such that</p> <pre><code> (A[i] + B[j]) == (-C[k] - D[l]) </code></pre> <p>We can put all possible <code>A[i] + B[j]</code> sums into a <em>dictionary</em> and then, in the loop over <code>-C[k] - D[l]</code>, try to look up in this dictionary. You can implement it like this:</p> <pre><code> private static int FourSumCount(int[] A, int[] B, int[] C, int[] D) { // left part: all A[i] + B[j] combinations Dictionary&lt;int, int&gt; left = new Dictionary&lt;int, int&gt;(); // loop over A[i] + B[j] combinations foreach (var a in A) foreach (var b in B) { int k = a + b; int v; if (left.TryGetValue(k, out v)) left[k] = v + 1; // we have such a combination (v of them) else left.Add(k, 1); // we don't have such a combination } int result = 0; // loop over -C[k] - D[l] combinations foreach (var c in C) foreach (var d in D) { int v; if (left.TryGetValue(-c - d, out v)) result += v; } return result; } </code></pre> <p>As you can see, we have <code>O(|A| * |B| + |C| * |D|)</code> complexity; in case <code>A</code>, <code>B</code>, <code>C</code> and <code>D</code> arrays have the approximately equal sizes <code>N</code> the complexity is <code>O(N**2)</code>.</p>
3,396,872
0
<p>One solution is to use <a href="http://library.gnome.org/devel/pango/stable/" rel="nofollow noreferrer">pango</a>'s cairo bindings. Using it could get quite confusing really fast so here's a essentials. You could create class around it in C++ if you want.</p> <pre><code>#include &lt;pango/pangocairo.h&gt; // Pango context PangoContext* pangoContext = pango_font_map_create_context( pango_cairo_font_map_get_default()); // Layout and attributes PangoLayout* pangoLayout = pango_layout_new(pangoContext); pango_layout_set_wrap(pangoLayout, PANGO_WRAP_WORD_CHAR); pango_layout_set_width(pangoLayout, maxWidth * PANGO_SCALE); pango_layout_set_height(pangoLayout, maxHeight * PANGO_SCALE); // Set font PangoFontDescription* fontDesc = pango_font_description_from_string("Verdana 10"); pango_layout_set_font_description(pangoLayout, fontDesc); pango_font_description_free(fontDesc); // Set text to render pango_layout_set_text(pangoLayout, text.data(), text.length()); // Allocate buffer const cairo_format_t format = CAIRO_FORMAT_A8; const int stride = cairo_format_stride_for_width(format, maxWidth); GLubyte* buffer = new GLubyte[stride * maxHeight]; std::fill(buffer, buffer + stride * maxHeight, 0); // Create cairo surface for buffer cairo_surface_t* crSurface = cairo_image_surface_create_for_data( buffer, format, maxWidth, maxHeight, stride); if (cairo_surface_status(crSurface) != CAIRO_STATUS_SUCCESS) { // Error } // Create cairo context cairo_t* crContext = cairo_create(crSurface); if (cairo_status(crContext) != CAIRO_STATUS_SUCCESS) { // Error } // Draw cairo_set_source_rgb(crContext, 1.0, 1.0, 1.0); pango_cairo_show_layout(crContext, pangoLayout); // Cleanup cairo_destroy(crContext); cairo_surface_destroy(crSurface); g_object_unref(pangoLayout); g_object_unref(pangoContext); // TODO: you can do whatever you want with buffer now // copy on the texture maybe? delete[] buffer; </code></pre> <p>In this case buffer will contain 8 bit alpha channel values only. Fiddle with format variable if you want something else. Compiling... <code>pkg-config --cflags --libs pangocairo</code> should do it on linix. I have no idea about windows.</p>
14,136,639
0
<p>Yes, you might run into trouble. See this link for how to solve your problem.</p> <p><a href="http://stackoverflow.com/questions/4333390/service-are-constructed-twice">@Service are constructed twice</a></p> <p>The way you proceed when creating modules seems valid to me. You have a context.xml file for each module and all will get loaded once you load the application. Your modules are self-contained and can also be used in different environments. That's pretty much the way I'd also do it.</p>
10,051,688
0
<p>A local branch can only track a remote branch for pushing if the local and remote branches have the same name. For pulling, the local branch need not have the same name as the remote branch. Interestingly, if you setup a branch 'foo' to track a remote branch 'origin/bar' (with 'git branch foo origin/bar') and if the remote repository <strong>does not</strong> currently have a branch named 'foo', then if later the remote does get a branch named foo, then the local branch foo will track origin/foo thereafter!</p> <pre><code>$ git clone dev1 dev2 Cloning into 'dev2'... done. $ cd dev2 # # After clone, local master tracks remote master. # $ git remote show origin * remote origin Fetch URL: /Users/ebg/dev1 Push URL: /Users/ebg/dev1 HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) # # Create branch br1 to track origin/master # $ git branch br1 origin/master Branch br1 set up to track remote branch master from origin. # # br1 tracks origin/master for pulling, not pushing # $ git remote show origin * remote origin Fetch URL: /Users/ebg/dev1 Push URL: /Users/ebg/dev1 HEAD branch: master Remote branch: master tracked Local branches configured for 'git pull': br1 merges with remote master master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) # # Go to the origin repo and now create a new 'br1' branch # $ cd ../dev1 $ git checkout -b br1 Switched to a new branch 'br1' # # Go back to dev2, fetch origin # $ cd ../dev2 $ git fetch origin From /Users/ebg/dev1 * [new branch] br1 -&gt; origin/br1 # # Now local branch 'br1' is tracking origin/br1 for pushing # $ git remote show origin * remote origin Fetch URL: /Users/ebg/dev1 Push URL: /Users/ebg/dev1 HEAD branch (remote HEAD is ambiguous, may be one of the following): br1 master Remote branches: br1 tracked master tracked Local branches configured for 'git pull': br1 merges with remote master master merges with remote master Local refs configured for 'git push': br1 pushes to br1 (up to date) master pushes to master (up to date) </code></pre> <p>So br1 was originally supposed to pull/push from master and we end up with br1 pulling from origin/master and pushing to a branch we never knew existed.</p>
17,413,697
0
<pre><code>def self.find_by_foo_templates(foo_template_ids) joins(:foos =&gt; :foo_template).where(['foo_templates.id in (?)', foo_template_ids.reject!(&amp;:empty?)]) end </code></pre>
19,828,260
0
<p>You are getting all 1s because the loop initialization statement <code>int c= x*y</code> will be executed only once for a <code>for</code> loop. That is it is executed the first time when <code>x=1</code> and <code>y=1</code> and since, it is given as the loop initialisation statement and not in the loop body, it is never reevaluated. The for loop works as :</p> <p>The loop initialisation statement is executed only once at the beginning of the loop. After each iteration the loop update expression is executed and the loop condition is reevaluated. <code>for(loop_initialisation;loop_condition;loop_update) { ... }</code></p> <p>So you should update <code>c</code> inside the loop, something like :</p> <pre><code>for ( int c= x*y; y&lt;= 12; y++) { c = x*y; System.out.print(c + " "); } </code></pre>
21,934,217
1
Relocate mouse cursor on screen <p>I am using Python and PyCharm. In my script I am trying to move the mouse to the top corner of the screen ((0,0) I think).</p> <p>I googled and found uinput however got this when trying to install it using:</p> <pre><code>sudo pip install python-uinput </code></pre> <p>I get the following error:</p> <pre><code>/usr/bin/ld: cannot find libudev.so.0 collect2: error: ld returned 1 exit status error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Cleaning up... </code></pre> <p>I do have libudev installed and the cosponsoring headers. </p> <p>Some advice would be very appreciated! </p> <p>Maybe even another simple way to move the mouse to the top left corner as I am still very inexperienced. </p>
29,651,029
0
<p>If i'm not getting your question wrongly, your question mysql solution would be <a href="http://stackoverflow.com/a/12114021/1728836">Get top n records for each group of grouped results</a></p> <p>But when we convert our desire query to laravel, so its will look alike:</p> <pre><code>$Rating1 = Model::whereRating(1)-&gt;take(10); $Rating2 = Model::whereRating(2)-&gt;take(10); $Rating3 = Model::whereRating(3)-&gt;take(10); $result = Model::unionAll($Rating1)-&gt;unionAll($Rating2)-&gt;unionAll($Rating3)-&gt;get(); </code></pre> <p>And its also one query not multiple as per laravel 4.2 docs, If you still confuse to implement it, let me know.</p>
24,816,042
0
CSS - Table mode how to display correctly? <p>Good night stackoverflow community! </p> <p>I'm trying to create a table-like model using CSS but having hard time to figure it out. It's a table with text and some images on each row, I've tried the <em>display: table</em> property but got no success on making rows and cells. What I'm trying to do is as follows:</p> <p><img src="https://i.stack.imgur.com/GWOh8.png" alt="Simple to make on paint, sweating to turn CSS"></p> <p>I've tried to apply this css I created to make it at least a table but got no success. Is there anything else I have to put in my css? I really don't want to use tables.</p> <pre><code>#tabelona { display: table; } #linha { display: table-row; } #conteudo { display: table-cell; } </code></pre> <p>Here's the HTML part, I'm just using text first:</p> <pre><code> &lt;div id="tabelona"&gt; &lt;div id="linha"&gt; &lt;div id="conteudo"&gt;1.&lt;/div&gt; &lt;div id="conteudo"&gt;OK&lt;/div&gt; &lt;/div&gt; &lt;div id="linha"&gt; &lt;div id="conteudo"&gt;2.&lt;/div&gt; &lt;div id="conteudo"&gt;OK Too&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Thank you very much! </p>
20,698,019
0
<pre><code>var fs = require('fs') function(req, res) { var id = req.param('id') fs.exists('/private/img/'+id, function(exists) { if(exists) res.sendfile('/private/img/'+id) else res.end('err') }) } </code></pre>
7,009,356
0
<p>Not very elegant solution too, but also works and do not require recreating array. Also, you can access the element value.</p> <pre><code>$array = (array)json_decode('{"123":100}'); $array_keys = array_keys($array); $array = (object)$array; foreach ($array_keys as $key) { if (!isset($array-&gt;$key)) { print "What is happening here?"; } else { print "It's OK val is {$array-&gt;$key}"; } } </code></pre> <p>Note <code>$</code> before key in <code>$array-&gt;$key</code>, it is important.</p>
31,275,378
0
<p>If you can use a library like underscore or lodash (or recreate the methods used here) it can be done like so: </p> <pre><code>var attributes = ['fruit', 'color']; var fruits = ['apple', 'orange', 'banana']; var colors = ['red', 'orange', 'yellow']; //Combine arrays in to list of pairs //(this would be expanded with each new array of attribute values) //ORDER IS IMPORTANT var zipped = _.zip(fruits, colors); //Map the zipped list, returning an object based on the keys. //Remember the order of the arrays in the zip operation //must match the order of the attributes in the attributes list var result = _.map(zipped, function(item, index) { return _.object(attributes, item); }); console.log(result); </code></pre>
3,817,360
0
Where does PHP save temporary files during uploading? <p>I am using XAMPP on Windows. By printing <code>$_FILES["file"]["tmp_name"]</code>, it seems that the temporary file was saved at C:\xampp\tmp\phpABCD.tmp. But I cannot see it on the filesystem of the server. However, the file can be moved or copied via <code>move_uploaded_file()</code>, <code>rename()</code>, or <code>copy()</code>. So where does PHP actually save temporary files during uploading?</p>
5,710,706
0
<p>I'm a total Haskell nube and this is a shot in the dark, but couldn't you use hscolour to output the code as HTML and then do something along the lines of <em>cabal haddock --executables --hyperlink-source</em> to include the colorized HTML?</p>
10,277,401
0
Generating all possible permutations for a given base and number of digits <p>I'm sure this is pretty simple, but I'm stumped for a way to do this. Essentially if I have an array with P collumns and V^P rows, how can I fill in all the combinations, that is, essentially, all possible numbers in base V of P digits. For example, for P=3 and V=2:</p> <pre><code>000 001 010 011 100 101 110 111 </code></pre> <p>Keep in mind that this is an 2 dimensional array, not an array of ints.</p> <p>For P=4 and V=3.</p> <pre><code>0000 0001 0002 0010 0011 0012 .... </code></pre> <p>Having this array generated, the rest of work for what I'm trying to devolop is trivial. So having some code/tips on how to do this would be greatly appreciated. Thanks.</p>
21,665,479
0
How to skip/ignore a specific position (on a list) within a loop, in C language? <p>A beginner in C language, I have to find the second and third smallest numbers from a list of N numbers.</p> <pre><code>void MenordeN (int N, int lista[100], int *c,int *posicion) { int menor,cont; menor=lista[0]; for (cont=1;cont&lt;N;cont++) { if (lista[cont]&lt;menor) { menor=lista[cont]; *posicion= cont+1; } } *c=menor; </code></pre> <p>}</p> <pre><code>int main() { int lista[100],menor, n, con,res,pos; printf("Ingrese el valor de N: \n"); scanf("%i",&amp;n); printf("Ingrese %i numeros: \n",n); for (con=0;con&lt;n;con++) { scanf("%i",&amp;lista[con]); } MenordeN(n,lista,&amp;res,&amp;pos); printf("El elemento menor es: %i en posicion %i",res,pos); //*res is the answer(smallest number) </code></pre> <h2>As of now: void MenordeN is to find the smallest number and its position. Main calls void MenordeN. However, how do I skip posicion[res] so that I can call void MenordeN again to find the second smallest number?</h2> <pre><code>int low = lista[0],m,i,idx; // init with first array element. m = low; for( i=0; i&lt;3; ++i) { for(idx=0; idx&lt;=100; ++idx) { if (lista[idx]&gt;low) { m = MIN(m,lista[idx]); } } } printf("\n3rd lowest value is %d\n", m); return 0; </code></pre> <h2>----->This just prints the first value entered, not the third smallest.</h2> <pre><code>int main() { int lista[100],menor, n, con, res, pos,resp; printf("Ingrese el valor de N: \n"); scanf("%i",&amp;n); printf("Ingrese %i numeros: \n",n); for (con=0;con&lt;n;con++) { scanf("%i",&amp;lista[con]); } MenordeN(n,lista,&amp;res,&amp;pos); printf("El elemento menor es: %i en posicion %i",res,pos); res=NULL; MenordeN(n,lista,&amp;resp,&amp;pos); printf("\nEl segundo elemento menor es: %i en posicion %i",resp,pos); return 0; </code></pre> <p>---------------> I know this is wrong, but isn't there something simpler like res=NULL or lista[res]==NULL? My teacher wouldn't expect anything too complicated because we are still in programming I. </p>
27,222,363
0
R: How to count number of 1 and write to vector <p>I have as signal-vector that looks like this: </p> <blockquote> <p>a &lt;- c(1,1,1,1,1,0,0,0,0,1,1,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1) </p> </blockquote> <p>I will count how often a 1 occurs in one raw and write that in to a vector b e.g. for vector a it should result in: </p> <blockquote> <p>b<br> 5,2,1,1,1,1,3 </p> </blockquote> <p>The reason is that i will plot a histogram that shows me the distribution of the length of the events. Maybe there is already a function in R that does exactly that? Otherwise with if-loop? </p> <p>Cheers Greg </p>
23,893,604
0
Caused by: com.google.gson.TokenMgrError: Lexical error at line 1, column 1. Encountered: "<" (60), after : "" <p>In my android application I am facing a very strange error and cannot get into root of it. I making a network call and parsing the JSON response. But the application crashes and I receive the following error.</p> <p>It occurs randomly and unable to reproduce the error. It would be very handy if some one who have faced this before could tell me what possibly could trigger this crash.</p> <pre><code>com.google.gson.JsonParseException: Failed parsing JSON source: java.io.StringReader@40e13578 to Json at com.google.gson.JsonParser.parse(JsonParser.java:57) at com.google.gson.Gson.fromJson(Gson.java:443) at com.google.gson.Gson.fromJson(Gson.java:396) at com.google.gson.Gson.fromJson(Gson.java:372) at com.xyz.getStaffFromJson(JsonUtils.java:201) at com.xyz.getMyDetails(WebAPI.java:666) at com.xyz.OptimisedSyncService.onHandleIntent(OptimisedSyncService.java:147) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:156) at android.os.HandlerThread.run(HandlerThread.java:60) Caused by: com.google.gson.TokenMgrError: Lexical error at line 1, column 1. Encountered: \"&lt;\" (60), after : \"\" at com.google.gson.JsonParserJavaccTokenManager.getNextToken(JsonParserJavaccTokenManager.java:1168) at com.google.gson.JsonParserJavacc.jj_ntk(JsonParserJavacc.java:635) at com.google.gson.JsonParserJavacc.parse(JsonParserJavacc.java:10) at com.google.gson.JsonParser.parse(JsonParser.java:54) ... 10 more com.google.gson.TokenMgrError: Lexical error at line 1, column 1. Encountered: \"&lt;\" (60), after : \"\" at com.google.gson.JsonParserJavaccTokenManager.getNextToken(JsonParserJavaccTokenManager.java:1168) at com.google.gson.JsonParserJavacc.jj_ntk(JsonParserJavacc.java:635) at com.google.gson.JsonParserJavacc.parse(JsonParserJavacc.java:10) at com.google.gson.JsonParser.parse(JsonParser.java:54) at com.google.gson.Gson.fromJson(Gson.java:443) at com.google.gson.Gson.fromJson(Gson.java:396) at com.google.gson.Gson.fromJson(Gson.java:372) at com.xyz.getStaffFromJson(JsonUtils.java:201) at com.xyz.getMyDetails(WebrosterAPI.java:666) at com.xyz.OptimisedSyncService.onHandleIntent(OptimisedSyncService.java:147) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:156) at android.os.HandlerThread.run(HandlerThread.java:60) </code></pre> <p>Sample response : {"mcode":"123","mobilesettings":{"mobile":"07405123154","email":"rcb@rtc.com","telephone":"0174465599","timeout":20,"mail_address":"abc.gmail.com","mail_user":"mail.user@gmail.com","mail_password":"password","task_state":0,"force_task_reason":0,"allow_free_task_reason":1,"unsent_sync":10,"booking_sync":240,"default_scan_mode":0,"gps_enabled":1,"gps_poll_interval":5,"minimum_gps_accuracy":100.0,"allow_blank_aborted_reason":false,"allow_free_aborted_reason":true},"staff":{"json_class":"Staff","staff_id":1234,"title":"","fname":"rags","mname":"","sname":"rags","location_id":321,"pager":"","mobile":"07444456789","email":"abc@def.com","website":"","dob":null,"job_title":"","uid_ref":1,"dt_stamp":"Tue Feb 11 13:13:44 +0000 2014","pin_no":"","wroptions":0,"dt_created":"Wed Dec 04 16:13:08 +0000 2013","user_created":1,"pin_start":"1234","pin_end":"1234","payroll_report":"Payroll.xml","external_payroll_ref":"","payroll_export":"Payroll.sql","supplier":0,"is_saved":1}}</p>
15,205,731
0
<p>I ended up adding the pickerview to an action sheet like so:</p> <pre><code>UIActionSheet *aac = [[UIActionSheet alloc] initWithTitle:@"Choose Date and Time" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; [datePicker addTarget:self action:@selector(dateChanged) forControlEvents:UIControlEventValueChanged]; pickerDateToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; pickerDateToolbar.barStyle = UIBarStyleBlackOpaque; [pickerDateToolbar sizeToFit]; NSMutableArray *barItems = [[NSMutableArray alloc] init]; UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; [barItems addObject:flexSpace]; UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(DatePickerDoneClick)]; [barItems addObject:doneBtn]; [pickerDateToolbar setItems:barItems animated:YES]; [aac addSubview:pickerDateToolbar]; [aac addSubview:datePicker]; [aac showFromTabBar:self.tabBarController.tabBar]; CGFloat wideth = self.view.frame.size.width; if (UIDeviceOrientationIsLandscape([self interfaceOrientation])) { [aac setBounds:CGRectMake(0,0,wideth, 355)]; [datePicker sizeToFit]; } else { [aac setBounds:CGRectMake(0,0, wideth, 470)]; [datePicker sizeToFit]; } picker = aac; </code></pre> <p>Hope that this helps others.</p>
38,432,624
0
Fast inserting or updating data from huge JSON to MYSQL with php <p>In a project of mine I have a problem updating my mysql db from a huge json. the json object in question consist of ~1000 entries like this:</p> <pre><code>[{ "uniqueId":"578742901714e", "lat": -76.760541, "lng": 121.289062, "description":"foo and bar", "visible": true }] </code></pre> <p>In order to compare the data in the json to the database, I used different statements enclosed in different loops. While this worked it took some time ~45 seconds for the whole json to be processed and written.</p> <p><strong><em>Edit:</em></strong></p> <p><strong>To clarify, I loop through the array returned by json_decode() and compare the data directly to the Database via SELECT and INSERT STATEMENTS - which works but is slow as hell, because the data is huge</strong></p> <p>Because the user has to wait for this to ensure data integrity, I decided this should be sped up.</p> <p>So I looked using INSERT INTO ON DUPLICATE KEY UPDATE, which should work with multiple data sets.</p> <p>But here's the real problem: Because some entries like "description" are saved in their own table I need something like LAST_INSERT_ID() to know the auto-increment id of the just inserted dataset. But LAST_INSERT_ID() doesn't work that way and only returns the first row if it is used in a batch INSERT. (<a href="http://dev.mysql.com/doc/refman/5.6/en/information-functions.html#function_last-insert-id" rel="nofollow">Documentation</a>)</p> <p>So I'm stuck between a functioning but very slow execution and a non-functioning but (supposedly) very fast execution.</p> <p>I don't really know how to proceed, can you help me?</p> <hr> <p><strong>Edit:</strong></p> <p>The database in question consists of some tables. The most prominent ones are the following two:</p> <p>table poi:</p> <pre><code>#1 id int auto-increment primary #2 unique_id varchar(13) unique #3 date int(11) #4 visible tinyint(1)/bool </code></pre> <p>table poi_description:</p> <pre><code>#1 id int auto-increment primary #2 poi_id int(11) #3 description text #4 date int(11) #5 user int(11) </code></pre> <p>I read so much in the last two days that I'm really not sure how to update the rows if the uniqueid is already in the table. I thought, I could get it to work with INSERT ON DUPLICATE UPDATE, but that looks only for the primary key - at least that's how it looks to me.</p>
25,928,936
0
Get the size of an array from its type <p>I have a template parameter T which I know will be a</p> <pre><code>MyArray&lt;Tbis, n&gt; </code></pre> <p>Is there a way to get back the integer n so I can use it as a template parameter ?</p> <p>Best regards,</p>
36,343,998
0
<p>How I centered a Topojson, where I needed to pull out the feature:</p> <pre><code> var projection = d3.geo.albersUsa(); var path = d3.geo.path() .projection(projection); var tracts = topojson.feature(mapdata, mapdata.objects.tx_counties); projection .scale(1) .translate([0, 0]); var b = path.bounds(tracts), s = .95 / Math.max((b[1][0] - b[0][0]) / width, (b[1][1] - b[0][1]) / height), t = [(width - s * (b[1][0] + b[0][0])) / 2, (height - s * (b[1][1] + b[0][1])) / 2]; projection .scale(s) .translate(t); svg.append("path") .datum(topojson.feature(mapdata, mapdata.objects.tx_counties)) .attr("d", path) </code></pre>
9,583,652
0
<p>Your script is looking for a DOM element with ID "overlay" which does not exist. The id of the button is btnAddUser.ClientID</p> <pre><code>&lt;asp:Button runat="server" ID="btnAddUser" Text="Add Currency Combination" ValidationGroup="valSum2" CssClass="showHide" /&gt; &lt;script type="text/javascript" language="javascript"&gt; $(document).ready(function() { $('&lt;%= btnAddUser.ClientID %&gt;').click(function() { $.blockUI({ overlayCSS: { backgroundColor: '#00f' } }); setTimeout($.unblockUI, 2000); }); }); &lt;/script&gt; </code></pre> <p>Note the removal of OnClientClick!</p> <p>Alternatively you can make this code a named function and type its name in the OnClientClick property. You can also bind by CssClass ( $('.showHide') ) (see @PraveenVenu's answer) but this will bind the function to all elements that use this css class.</p>
31,868,428
0
<p>Not completely sure if I understand what you are trying to do, but I gave it a shot.</p> <p>In the CSS if you change the margin to padding, then any background color on the child element will extend to the parent. background color is includes the padding but not the margin.</p> <p>I also had to bump up the width of the child 20px for it to fill properly.</p> <p>Updated fiddle: <a href="https://jsfiddle.net/5qp1a3um/1/" rel="nofollow">https://jsfiddle.net/5qp1a3um/1/</a></p> <pre><code>.inner{ padding-left: 100px; padding-right: 100px; background-color: blue; width: 220px; height: 300px; border: 1px solid green; } </code></pre>
21,652,345
0
From inside a custom directive how to change text of another span element? <p>I have an <code>&lt;input&gt;</code> which holds my custom directive as an attribute and inside that attribute I give the ID of destination that will receive the text. At the moment I am doing the text change with jQuery but I would rather use the full Angular way...So it's kinda of a binding but from within a directive. To make it simple, I made a simple draft of my code: <br><br>HTML Code</p> <pre><code>&lt;input type="text" name="input1" my-directive="message1" /&gt; &lt;span id="message1"&gt;&lt;/span&gt; </code></pre> <p>JS Code</p> <pre><code>// Angular - custom Directive directive('myDirective', function($log) { return{ require: "ngModel", link: function(scope, elm, attrs, ctrl) { var receiverId = attrs.myDirective; var whateverText = 'blabla'; $('#'+receiverId).text(whateverText); } }; }); </code></pre> <p>Using the ID on my <code>&lt;span&gt;</code> element is probably not the best solution, but that is how I got it working with jQuery. It's probably better to remove the ID, but then how could I update the text in my span after all? And let's not forget that it's a Form and we can have multiple input and span elements. Also note that I do not want to use the controller to pass the text, it has to stay within the directive as I want to re-use it. <br><br>Please don't tell me that I shouldn't do it this way, I want to stick with this behavior. </p>
38,736,983
0
<p>you can also use this query for test:</p> <pre><code>UPDATE dupli d SET description = ( SELECT CONCAT('duplicate in ',GROUP_CONCAT(`id` ORDER BY id)) FROM (SELECT * FROM dupli) AS d1 WHERE `name` = d.`name` AND id &lt;&gt; d.id ) ; </code></pre> <p><strong>sample</strong></p> <pre><code>MariaDB [yourSchema]&gt; UPDATE dupli d -&gt; SET description = ( -&gt; SELECT CONCAT('duplicate in ',GROUP_CONCAT(`id` ORDER BY id)) -&gt; FROM (SELECT * FROM dupli) AS d1 -&gt; WHERE `name` = d.`name` AND id &lt;&gt; d.id ) ; Query OK, 0 rows affected, 1 warning (0.00 sec) Rows matched: 4 Changed: 0 Warnings: 1 MariaDB [yourSchema]&gt; select * from dupli; +----+------+------------------+ | id | name | description | +----+------+------------------+ | 1 | foo | duplicate in 3,4 | | 2 | bar | NULL | | 3 | foo | duplicate in 1,4 | | 4 | foo | duplicate in 1,3 | +----+------+------------------+ 4 rows in set (0.00 sec) MariaDB [yourSchema]&gt; </code></pre>
17,286,730
0
<p>The problem is as others in the comments mentioned, that your javascript resource is not precompiled.</p> <p>The solution is a little bit more than just making sure you precompile the assets, which by the way heroku will do when you push so you don't have to.</p> <p>The problem lies in that you are doing this:</p> <pre><code>&lt;% content_for :script do %&gt; &lt;%= javascript_include_tag 'hover_content' %&gt; &lt;% end %&gt; </code></pre> <p>Since you are referencing hover_content directly instead of just including it in your application.js then you must tell Rails that you want this included in the asset precompile step.</p> <p>Modify your production.rb file and add this line:</p> <pre><code>config.assets.precompile += %w( hover_content.js ) </code></pre> <p>That will tell rails that in addition to the application.js which automatically gets compiled and included that you want to also include this other file hover_content.js</p>
17,983,180
0
Updating Yii Dropdownlist After Insert New Element [SOLVED] <p>I'm totally new in Yii, so, excuse me if the answer for this question is a little bit trivial.</p> <p>Here's my code: </p> <pre><code>&lt;p&gt; &lt;?php echo $form-&gt;labelEx($model,'phone_type'); ?&gt; &lt;span class="field"&gt; &lt;?php echo $form-&gt;dropDownList($model,'phone_type', CHtml::listData(PhonesTypes::model()-&gt;findAll(), 'id','type' )); ?&gt; &lt;?php echo $form-&gt;error($model,'phone_type'); ?&gt; &lt;/span&gt; &lt;/p&gt; </code></pre> <p>There will be a button to register new Phone types. So, after the submition of the form, that will be inside of a CJUiDialog, I wish that the above dropDownList be updated with the new type, without refresh the page. </p> <p>I google it a lot, but i only find things related to "dependent dropdowns" in Yii.</p> <p>What's the better approach to solve this problem? Is there something like <code>$.fn.cgridview.update</code>?</p> <p>Here's the Dialog code:</p> <pre><code>&lt;?php $this-&gt;endWidget('zii.widgets.jui.CJuiDialog'); $this-&gt;beginWidget('zii.widgets.jui.CJuiDialog', array( 'id'=&gt;'dialog-crud', 'options'=&gt;array( 'title'=&gt;'Create new Phone Type', 'autoOpen'=&gt;false, 'modal'=&gt;true, 'width'=&gt;1080, 'height'=&gt;820, 'resizable'=&gt;false ), )); ?&gt; &lt;iframe src="http://myapp/phone_types/create" width="100%" height="100%"&gt;&lt;/iframe&gt; &lt;?php $this-&gt;endWidget(); ?&gt; </code></pre> <p>And the code of the controller, is a trivial create function:</p> <pre><code>public function actionCreate(){ $model = new PhoneType; if(isset($_POST['PhoneType'])){ $model-&gt;attributes = $_POST['PhoneType']; if( $model-&gt;save() ){ //----&gt; some suggestion here? echo CHtml::script(""); Yii::app()-&gt;end(); } } } </code></pre> <hr> <p><strong>So, below is the code of my solution.</strong> In the view: </p> <pre><code>&lt;?php $this-&gt;beginWidget('zii.widgets.jui.CJuiDialog', array( 'id'=&gt;'dialog', 'options'=&gt;array( 'title'=&gt;'Phone Types', 'autoOpen'=&gt;false, 'modal'=&gt;true, 'width'=&gt;1080, 'height'=&gt;820, 'resizable'=&gt;false ), )); ?&gt; &lt;iframe src="phoneTypes/create" id="cru-frame" width="100%" height="100%"&gt;&lt;/iframe&gt; &lt;?php $this-&gt;endWidget(); ?&gt; </code></pre> <p>In my PhoneTypesController:</p> <pre><code>public function actionCreate(){ $model = new PhoneTypes; if(isset($_POST['PhoneTypes'])){ $model-&gt;attributes = $_POST['PhoneTypes']; if($model-&gt;save()){ echo CHtml::script(" window.parent.$('#dialog').dialog('close'); window.parent.$('#Phone_types_id').append('&lt;option value=".$model-&gt;id." &gt;'+'".$model-&gt;type."'+'&lt;/option&gt;'); "); Yii::app()-&gt;end(); } } $this-&gt;render('create',array( 'model'=&gt;$model, )); } </code></pre> <p>Thanks for your help!</p>
15,153,597
0
<p>You could use this: </p> <p>If this was your url:</p> <pre><code>url(r'(?P&lt;category&gt;[a-z]+)$', 'display', name='dyn_display') reverse('dyn_display', kwargs={'category': 'first'}) </code></pre> <p>To redirect you can use it like this in your view:</p> <pre><code>from django.http import HttpResponseRedirect return HttpResponseRedirect(reverse('dyn_display', kwargs={'category': 'first'})) </code></pre> <p>If this was your url:</p> <pre><code>url(r'$', 'display', name='dyn_dysplay') reverse('dyn_display') </code></pre> <p>To redirect you can use it like this in your view:</p> <pre><code>from django.http import HttpResponseRedirect return HttpResponseRedirect(reverse('dyn_display')) </code></pre> <p>To have a view that could receive an optional value you would need 2 urls:</p> <pre><code>url(r'$', 'display', name='dyn_optional_display') url(r'(?P&lt;category&gt;[a-z]+)$', 'display', name='dyn_display') </code></pre> <p>And then your view:</p> <pre><code>def courses_display(request, category=None): ctx = {} if category: ctx.update({category: 'in'}) return render_to_response('display/basic.html', ctx, context_instance=RequestContext(request)) </code></pre>
39,919,091
0
<p>I've forked that project and made a <a href="https://github.com/jonmountjoy/PerfectTemplate#deploy-to-heroku" rel="nofollow">Heroku Button deployable version here</a>. In order to get that working, I checked out the sample app, and found that the build dumped the binary in <code>.build/release/PerfectTemplate</code>, so your Procfile should be:</p> <p><code> web: .build/release/PerfectTemplate --port $PORT </code></p> <p>Note, you also want to set the <code>$PORT</code>. If you've deployed but failed prior to this, you'll also want to make sure you scale up the web dyno: <code>heroku ps:scale web=1</code>.</p>
36,117,190
0
Laravel with drivers of MongoDB <p>I'm new using MongoDB in laravel, I want to use laravel 4.2 with MongoDB but I have this problem: </p> <pre> > C:\xampp\htdocs\laravel-mongo>composer require jenssegers/mongodb Using version ^3.0 for jenssegers/mongodb ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - jenssegers/mongodb v3.0.0 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1]. - jenssegers/mongodb v3.0.1 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1]. - jenssegers/mongodb v3.0.2 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1]. - mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb has the wrong version (1.0.0) installed. - mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb has the wrong version (1.0.0) installed. - Installation request for jenssegers/mongodb ^3.0 -> satisfiable by jenssegers/mongodb[v3.0.0, v3.0.1, v3.0.2]. To enable extensions, verify that they are enabled in those .ini files: - C:\xampp\php\php.ini You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode. Installation failed, reverting ./composer.json to its original content.</pre>
22,982,367
0
13,650,676
0
<p>You don't need the "Object" keyword and should quote the properties. This worked in my console: </p> <pre><code>var myJsObject = { 'A.b': 1, 'A.c': 2 }; var value = myJsObject['A.c']; console.log(value); // 2 </code></pre>
28,918,643
0
Full Calendar Event Height in Month View <p><img src="https://i.stack.imgur.com/8KBlx.png" alt="enter image description here"></p> <p>I have Full calender issue here i have two events</p> <ol> <li>16 to 19th events are shown in view( which is visible as 16-18th dates only)</li> <li>Another event from 17-18th ( which is behind the 1st event not visible though)</li> </ol> <blockquote> <p>in console.log($('#calendar').fullCalendar('clientEvents')); I get two events in expected format pls help with this</p> </blockquote>
24,712,756
0
Want to start an activity from listview click but my class does not extend activity <p>I have a listview in viewpager. I want to start a new activity or if that possible, to make same activity for multiple xml, if I click on item in that list view. </p> <p>But my class does not extend activity.</p> <p>This is my code:</p> <pre><code> public class SampleListFragment extends ScrollTabHolderFragment implements OnScrollListener { private static final String ARG_POSITION = "position"; private ListView mListView; private ArrayList&lt;String&gt; mListItems; private int mPosition; public static Fragment newInstance(int position) { SampleListFragment f = new SampleListFragment(); Bundle b = new Bundle(); b.putInt(ARG_POSITION, position); f.setArguments(b); return f; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPosition = getArguments().getInt(ARG_POSITION); mListItems = new ArrayList&lt;String&gt;(); if (mPosition==0){ mListItems.add("Game" ); mListItems.add(".iphone " ); mListItems.add("xxx" ); mListItems.add("yyy" ); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { switch (position){ case 0 : // i want to start new activity if i clicked in game break; case 1 : //start a new activity if i clicked in iphone break; } } private Context getApplicationContext() { // TODO Auto-generated method stub return null; } }); } else if (mPosition==1){ mListItems.add(". item - currnet page:حة 1 " ); } else if (mPosition==2){ mListItems.add(". item - currnet page:حة2 " ); } else if (mPosition==3){ mListItems.add(". item - currnet page:حة 3 " ); } else if (mPosition==4){ mListItems.add(". item - currnet page:حة 4 " );}} @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_list, null); mListView = (ListView) v.findViewById(R.id.listView); View placeHolderView = inflater.inflate(R.layout.view_header_placeholder, mListView, false); mListView.addHeaderView(placeHolderView); return v; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setOnScrollListener(this); mListView.setAdapter(new ArrayAdapter&lt;String&gt;(getActivity(), R.layout.list_item, android.R.id.text1, mListItems));} @Override public void adjustScroll(int scrollHeight) { if (scrollHeight == 0 &amp;&amp; mListView.getFirstVisiblePosition() &gt;= 1) { return; } mListView.setSelectionFromTop(1, scrollHeight);} @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mScrollTabHolder != null) mScrollTabHolder.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount, mPosition); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { // nothing } } </code></pre>
15,299,618
0
<blockquote> <p>I would like to set startAt as an number.</p> </blockquote> <p><code>SomeClass.prototype.startAt</code> <strong>is</strong> a number (<code>0</code>).</p> <p>Your <code>get</code> function explicitly returns <code>false</code> if the property is "falsey":</p> <pre><code>if(!this[prop]){return false;} </code></pre> <p>In JavaScript, <code>0</code>, <code>""</code>, <code>false</code>, <code>undefined</code>, and <code>null</code> are all "falsey", and so the condition above will be true and cause <code>get</code> to return <code>false</code>.</p> <p>If your goal is to return <code>false</code> if the property <em>doesn't exist</em>, you can do that like this:</p> <pre><code>if (!(prop in this)) { return false; } </code></pre> <p>That will check if the property exists on the object itself <em>or</em> its prototype, which I suspect is what you want. But if you only want to check the object itself and ignore properties on the prototype, that would be:</p> <pre><code>if (!this.hasOwnProperty(prop)) { return false; } </code></pre> <p>Bringing that all together, if your goal is for <code>get</code> to return <code>false</code> for properties that the object doesn't have (either its own, or via its prototype), then:</p> <pre><code>get : function(prop){ if (typeof prop !== "string" || !(prop in this)) { return false; } return this[prop]; } </code></pre> <p>I've done a few things there:</p> <ol> <li><p><code>typeof</code> is an operator, not a function, so you don't use parens around its operand (normally)</p></li> <li><p>Since <code>"undefined"</code> is <code>!== "string"</code>, there's no need to check for it specifically when checking that <code>prop</code> is a string.</p></li> <li><p>I used <code>!(prop in this)</code> to see if the object (or its prototype) has the property.</p></li> <li><p>I combined the two conditions that returned <code>false</code> into a single <code>if</code> statement using <code>||</code>.</p></li> </ol>
17,654,634
0
<p>Add quotes to your <code>where</code> clause:e.g. <code>where column5 = '$value'</code></p>
41,010,312
0
Bootstrap datetimepicker - How to set all picker tooltips at once? <p>The following are my example codes:</p> <pre><code>$('#ex1').datetimepicker({ tooltips: { today: 'today', clear: 'clear', close: 'close', }, format: 'YYYY/MM/DD', locale: 'zh-tw', }); $('#ex2').datetimepicker({ tooltips: { today: 'today', clear: 'clear', close: 'close', }, format: 'YYYY/MM/DD', locale: 'zh-tw', }); $('#ex3').datetimepicker({ tooltips: { today: 'today', clear: 'clear', close: 'close', }, format: 'YYYY/MM/DD', locale: 'zh-tw', }); </code></pre> <p>As above, the code is duplicate! How to set all picker tooltips and option at once?</p> <p>I have tried add them to "calendar" class, and use</p> <pre><code>$('.calendar').datetimepicker({ tooltips: { today: 'today', clear: 'clear', close: 'close', }, format: 'YYYY/MM/DD', locale: 'zh-tw', }); </code></pre> <p>to set them, but not working...</p> <p>Thank you!</p> <p>---Updated: --- These are my code about class:</p> <pre><code>&lt;input type='text' class="form-control calendar" id='leave-end'&gt; &lt;input type='text' class="form-control calendar" id='leave-start'&gt; </code></pre> <p>And:</p> <pre><code>$('.calendar').datetimepicker({ tooltips: { close: '關閉日曆', selectMonth: '選擇月份', prevMonth: '上個月', nextMonth: '下個月', selectYear: '選擇年份', prevYear: '前一年', nextYear: '下一年', }, format: 'YYYY/MM/DD', locale: 'zh-tw', }); </code></pre> <p>But not working and no error message, what wrong?</p> <p>And </p> <pre><code>var options = { tooltips: { today: 'today', clear: 'clear', close: 'close', }, format: 'YYYY/MM/DD', locale: 'zh-tw', } $('#leave-start').datetimepicker({options}); </code></pre> <p>I copy and paste but got 1 warning <code>jquery.min.js:2 jQuery.Deferred exception: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded</code> and 1 error <code>jquery.min.js:2 Uncaught RangeError: Maximum call stack size exceeded</code></p>
39,506,157
0
<p>You should first learn about <a href="http://sass-lang.com/guide" rel="nofollow"><em>SASS</em></a></p> <p>You will see that SASS is actually CSS made easy and with more features like the ability to use Variables : <code>$myHeight : 500px;</code></p> <p>In your example, he is using variable.</p> <p>To inject it in your project, you need to find a way to save your SASS file in a CSS file. In the above link it is using the command</p> <blockquote> <p>sass --watch app/sass:public/stylesheets</p> </blockquote> <p>But you can also do it with grunt or <a href="https://www.npmjs.com/package/gulp-sass" rel="nofollow">gulp</a></p>
38,229,544
0
Node-Webkit screen rotation/orientation enforcement or control? <p>By default when using Node-Webkit on a machine with screen rotation (like Asus Transformer on Windows 10), when flipping the screen to portrait mode, the app will flip as well.</p> <p>Is there any way to enforce a specific mode (ex: landscape, portrait), to make sure the app will only view that way, and will not rotate or flip?</p>
19,644,095
0
<p>You must have a lot of lines. Are you sure that the second row repeats enough to put those records into an individual file? Anyway, awk is holding the files open until the end. You'll need a process that can close the file handles when not in use. </p> <p>Perl to the rescue. Again.</p> <pre><code>#!perl while( &lt;&gt; ) { @content = split /,/, $_; open ( OUT, "&gt;&gt; $content[1]") or die "whoops: $!"; print OUT $_; close OUT; } </code></pre> <p>usage: <code>script.pl your_monster_file.csv</code></p> <p>outputs the entire line into a file named the same as the value of the second CSV column in the current directory, assuming no quoted fields etc.</p>
20,322,130
0
<p>You can look into jQuery to dynamically change CSS properties as the certain events are called. You can find a great tutorial <a href="http://www.w3schools.com/jquery/css_css.asp" rel="nofollow">here</a>. Here is an example from an old project of mine:</p> <pre><code> $(window).scroll(function (e) { $el = $('.fixedElement'); if ($(this).scrollTop() &gt; 98 &amp;&amp; $el.css('position') != 'fixed') { $('.fixedElement').css({ 'position': 'fixed', 'top': '0px', 'width': '90%', 'min-width': '1200px' }); } }); </code></pre>
34,439,047
0
<p>This is what you want to use:</p> <p><code>sort -t: -k 1.5,1.8n -k 2.1,2.7n inputfile 440c0401 mfcc.1.ark:9 440c0401 mfcc.1.ark:501177 440c0402 mfcc.2.ark:15681 440c0403 mfcc.3.ark:516849</code></p> <p>-t -separator of fields(should not be used elsewhere in the inputfile</p> <p><code>-k</code> is key for sorting(could be used > 1) <code>-k 1.5,1.8n</code> means: sort numerical(this tells the <code>n</code>) by the field 1 from 5th to 8th character. </p> <p>second <code>-k</code> tells sort the field 2 from the first to the 7th character numerically.</p>
7,565,568
0
<blockquote> <p>From what I can tell, there doesn't seem to be a way using streaming to send certain records in output file A and the rest of the records in output file B.</p> </blockquote> <p>By using a custom <a href="http://hadoop.apache.org/mapreduce/docs/r0.21.0/mapred_tutorial.html#Partitioner" rel="nofollow">Partitioner</a>, you can specify which key goes to which reducer. By default the <a href="http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/mapred/lib/HashPartitioner.html" rel="nofollow">HashPartitioner</a> is used. Looks like the only other Partitioner Streaming supports is <a href="http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/mapred/lib/KeyFieldBasedPartitioner.html" rel="nofollow">KeyFieldBasedPartitioner</a>.</p> <p>You can find more details about the KeyFieldBasedPartitioner in the context of Streaming <a href="http://hadoop.apache.org/common/docs/current/streaming.html#Hadoop+Partitioner+Class" rel="nofollow">here</a>. You need not know Java to configure the KeyFieldBasedPartitioner with Streaming.</p> <blockquote> <p>Is there a way to do a map/reduce job to re-split every log files correctly?</p> </blockquote> <p>You should be able to write a MR job to re-split the files, but I think Partitioner should solve the problem.</p>
24,087,718
0
<p>It seems you use Default Connection Factory. Did you try define connection strings with datasource parameter and indication on .sdf file?</p> <pre><code>&lt;connectionStrings&gt; &lt;add name="ConnectionStringName" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=|DataDirectory|\DatabaseFileName.sdf" /&gt; &lt;/connectionStrings&gt; </code></pre> <p>If it won't work, I've got one more idea. You're logging in by Windows Authentication. Maybe it's not possible to make two parallel connections via the same credentials? I'm not sure, but try to check other way than windows authentication. </p>
9,475,742
0
Making UIImagePickerController look like Photos app <p>I'm trying to use <code>UIImagePickerController</code>, but it doesn't look like the one in Photos app. Can anyone guide me please? </p>
17,324,888
0
<p>Better code (at least for me):</p> <pre><code> void MyClass::OnPaint() { CPaintDC dc(this); // device context for painting COLORREF highlightFillColor; CPen nPen, *pOldPen = NULL; CBrush nBrush, *pOldBrush = NULL; CRect rect; GetWindowRect(rect); ScreenToClient(rect); BmsMemDC memDc(&amp;dc, &amp;rect); memDc.SetBkMode(TRANSPARENT); //dc.Re highlightFillColor = RGB(0x99,0xB4,0xFF); nPen.CreatePen( PS_SOLID, 4, highlightFillColor); nBrush.CreateSolidBrush( GetSysColor(COLOR_3DFACE )); pOldPen = memDc.SelectObject(&amp;nPen); pOldBrush = memDc.SelectObject(&amp;nBrush); if(leftGroupSelected) { rect.SetRect(rect.left + 4, rect.top+30, rect.left + 126, rect.bottom - 5); memDc.FillRect(&amp;rect,&amp;nBrush); memDc.RoundRect(rect.left, rect.top, rect.right, rect.bottom, 8, 8); } if (rightGroupSelected) { rect.SetRect(rect.left + 134, rect.top+30, rect.left + 256, rect.bottom - 5); memDc.FillRect(&amp;rect,&amp;nBrush); memDc.RoundRect(rect.left, rect.top, rect.right, rect.bottom, 8, 8); } </code></pre> <p>}</p>
36,242,029
0
<p>You can request a long-lived token and use it for testing purpose. <a href="https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension" rel="nofollow">https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension</a></p>
19,886,884
0
<p>Based on my comments above, below is a workaround. Unfortunately at this stage, Windows 8.1 store Unit Test project types, using NUnit extension wouldn't work due to the different .NET targets. I tried with different Test Unit Adapters including an <a href="http://www.nuget.org/packages/NUnitTestAdapter.WithFramework/" rel="nofollow noreferrer">NUnitTestAdapterWithFramework</a>. </p> <p>It seems that the issue you haveing was occurring with standard .NET libraries targeting NUnit test adapter but the above NUnitTestAdapterWithFramework must have fixed those issue. See the <a href="http://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d/view/Reviews/3" rel="nofollow noreferrer">Q &amp; A section of the NUnitTestExtension</a></p> <p>But unfortunatly it seems that this still of an issue that hasn't been fixed for Win8 Store App type Unit Testing. Pretty sure <a href="http://xunit.codeplex.com/workitem/9826" rel="nofollow noreferrer">xUnit.NET also not compatible</a> yet with different .NET target types (i,e WinRT)</p> <p>So what are the options? a. For your group, you can change them to use MSTest framework. Outcome - Problem Solved no issues.</p> <p>b. Workaround "linked project". Outcome - Can't *guarantee** but this should also work.</p> <p><strong>With option 'b'</strong></p> <p>In your comment you mentioned.</p> <blockquote> <p>but I'm still not sure what it does or how to implement a 'linked project', do you have any more information on this? Also, as this is for a group university project, I was hoping i wouldn't have to force too many workarounds</p> </blockquote> <p>When you think about it, it is not really hard work around. It is simple and I'm sure your group would be able to apply this workaround easily.</p> <p>Please follow the below steps.</p> <ol> <li><p>Create a separate class library in your solution (you can target .NET framework 4).</p></li> <li><p>Then add NUnit assemblies and the NUnit test adapter as usual.</p> <p><img src="https://i.stack.imgur.com/jxZU8.png" alt="enter image description here"></p></li> <li><p>Right click on this project and select 'Add' then 'Existing Item'</p></li> <li><p>Select the Win8 Store Unit Test project and locate the Unit Test file you want to add. When you add the file, make sure you select 'Add As a Link' button. Please see below.</p> <p><img src="https://i.stack.imgur.com/GIx7g.png" alt="enter image description here"></p></li> <li><p>Now rebuild the solution, close and re-open the UnitTest explorer and you should be able to run those tests.</p></li> </ol> <p><img src="https://i.stack.imgur.com/p6AiB.png" alt="enter image description here"></p> <p>*The reason I said can't guaranteed. I haven't really written Unit tests against Win8 App. So if your SUT (System Under Test) require special configuration it might cause issues. But I'm not sure.</p> <p><strong>Finally creating a link files are not that hard if everything works you can continue to do this until NUnit has the support for Win8 Unit Testing. Or the other option is simply change all your Unit Tests to use MSTest framework if possible.</strong></p>
20,570,153
0
<p>Ping is used to check if a server is alive. Telnet, normally allows to use the telnet service, but it can be used to check if a port is open (firewall) for remote connections.</p> <p>You should check connectivity from the client</p> <pre><code>telnet db2serverName db2Port </code></pre> <p>For example</p> <pre><code>telnet 192.168.0.1 50000 </code></pre> <p>Once you have checked that the DB2 port is open for your client, you should establish the connection or receive a different error message.</p>
37,672,202
0
I'm facing Duplicate name exception <p>This is the .aspx.cs file.</p> <pre><code>using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Xml.Linq; using System.Linq; using Telerik.Web.UI; using System.Web.UI.WebControls; using System.Web.UI; //using System.Web.UI.Control; using System.Web; using System.Web.Util; using System.Xml; using System.Windows.Forms; namespace Grid.Examples.DataEditing.XmlDataSourse { public partial class Default : System.Web.UI.Page { private const string BACKUP_PATH = "~/App_Data/Xml/NewBuyerLoginRef.xml"; private const string FILE_PATH = "~/App_Data/Xml/NewBuyerLogin.xml"; private const int MAX_LENGTH = 25; /// &lt;summary&gt; /// Tracks how many times the page was requested. /// &lt;/summary&gt; public int TimesRequested { get { if (this.Application["requested"] == null) { this.Application["requested"] = 0; } return (int)this.Application["requested"]; } set { this.Application["requested"] = value; } } /* protected void Page_Load(object sender, EventArgs e) { TimesRequested++; if (TimesRequested &gt;= 3) { //If the page is requested more than three times, refresh the XML file... TimesRequested = 0; RefreshXmlFile(BACKUP_PATH, FILE_PATH); } }*/ protected void RadGrid2_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { var sourceDocument = LoadDocument(FILE_PATH); //var customers = GetCustomersEnumeration(sourceDocument, "Customers", "Customer"); // var customers = from field in sourceDocument.Descendants() select field; var x = sourceDocument.Descendants("tasks"); var y = x.Descendants("fillPage"); var z= y.Descendants("input"); var w=z.Descendants("fields"); // XmlNodeList nodes= sourceDocument.selectNodes // IEnumerable&lt;XNode&gt; nodes = sourceDocument.NodesAfterSelf().Single(XElement.Equals(Attribute("seq").Value,"3" )).FirstOrDefault; var gridSource = (from field in w.Descendants() select new { id = field.Attribute("id").Value, email = field.Attribute("email").Value, login_passowrd = field.Attribute("login_password").Value }); (sender as RadGrid).DataSource = gridSource; //Rebind the upper Grid so the changes are reflected this.RadGrid1.Rebind(); } protected void RadGrid2_UpdateCommand(object source, GridCommandEventArgs e) { GridEditFormItem editForm = (GridEditFormItem)e.Item; Hashtable newValues = new Hashtable(); //Extract the new values from the editor controls editForm.ExtractValues(newValues); //Get the "Primary key" value that will be used to perform CRUD operations string id = editForm.GetDataKeyValue("id").ToString(); //Load the XML document in memory... var sourceDocument = LoadDocument(FILE_PATH); var x = sourceDocument.Descendants("tasks"); var y = x.Descendants("fillPage"); var z = y.Descendants("input"); var w = z.Descendants("fields"); //Get IEnumerable of the Customer elements // var customers = GetCustomersEnumeration(sourceDocument, "Customers", "Customer"); //Get a reference to the modified record XElement affectedElement = (from field in z.Descendants() where field.Attribute("id").Value == id select field).FirstOrDefault(); //Validate and update the input strings foreach (DictionaryEntry entry in newValues) { affectedElement.Attribute(entry.Key.ToString()).Value = ValidateString(entry.Key.ToString(), entry); } //Save the new values to the document SaveChanges(sourceDocument, FILE_PATH); } protected void RadGrid2_InsertCommand(object source, GridCommandEventArgs e) { GridEditFormItem editForm = (GridEditFormItem)e.Item; Hashtable newValues = new Hashtable(); //Extract the new values from the editor controls editForm.ExtractValues(newValues); //Load the XML document in memory... var sourceDocument = LoadDocument(FILE_PATH); var x = sourceDocument.Descendants(); var y = x.Descendants("fillPage"); var z = y.Descendants("input"); var w = z.Descendants("fields"); //Get IEnumerable of the Customer elements // var customers = GetCustomersEnumeration(sourceDocument, "Customers", "Customer"); XElement root = (from fields in z select fields).LastOrDefault(); // int x = 1; //Construct the new "Primary key" string lastid = root.Attribute("id").Value; int a = 1 + Int32.Parse(lastid); //Add the "Primary key" to the attributes values that will be used to construct the new element newValues.Add("id", a); //Construct the new element that will be inserted XElement element = new XElement("field"); //Validate and add the input strings foreach (DictionaryEntry entry in newValues) { XAttribute attribute = new XAttribute(entry.Key.ToString(), ValidateString(entry.Key.ToString(), entry)); //Add the supplied values as attributes to the newly created element element.Add(attribute); } //Add the newly created element var b = sourceDocument.Descendants().Descendants("fillPage").Descendants("input").Descendants().LastOrDefault(); b.Add(element); //Save the new values to the document SaveChanges(sourceDocument, FILE_PATH); } protected void RadGrid2_DeleteCommand(object source, GridCommandEventArgs e) { GridDataItem dataItem = (GridDataItem)e.Item; //Get the "Primary key" value that will be used to perform the Delete operation string customerID = dataItem.GetDataKeyValue("id").ToString(); //Load the XML document in memory... XDocument sourceDocument = LoadDocument(FILE_PATH); var x = sourceDocument.Descendants("tasks"); var y = x.Descendants("fillPage"); var z = y.Descendants("input"); var w = z.Descendants("fields"); //Get IEnumerable of the Customer elements // var customers = GetCustomersEnumeration(sourceDocument, "Customers", "Customer"); //Get the element that should be deleted XElement elelemntToDelete = (from field in w.Descendants() where field.Attribute("id").Value == customerID select field).FirstOrDefault(); //Remove the element from the XML document elelemntToDelete.Remove(); //Save the new values to the document SaveChanges(sourceDocument, FILE_PATH); } /// &lt;summary&gt; /// Load the source document /// &lt;/summary&gt; /// &lt;param name="path"&gt;Path to the source document&lt;/param&gt; /// &lt;returns&gt;XDocument&lt;/returns&gt; private XDocument LoadDocument(string path) { XDocument sourceDocument = XDocument.Load(this.Server.MapPath(path)); return sourceDocument; } /// &lt;summary&gt; /// Save the changes to the specified document /// &lt;/summary&gt; /// &lt;param name="sourceDocument"&gt;Path where the document will be saved&lt;/param&gt; /// &lt;param name="path"&gt;Path to the file where the changes will be saved&lt;/param&gt; private void SaveChanges(XDocument sourceDocument, string path) { try { //Save the changes back to the file sourceDocument.Save(this.Server.MapPath(path)); } catch (Exception ex) { //Notify the user if exception is raised this.Notification1.Text = ex.Message; this.Notification1.Show(); } } /// &lt;summary&gt; /// Refresh the source file if more than 5 changes are made /// &lt;/summary&gt; /// &lt;param name="sourcePath"&gt;Path to the source file that will be used for the copy operation&lt;/param&gt; /// &lt;param name="targetPath"&gt;Path to the file that needs to be refreshed&lt;/param&gt; private void RefreshXmlFile(string sourcePath, string targetPath) { try { File.Copy( this.Server.MapPath(sourcePath), this.Server.MapPath(targetPath), true); } catch (IOException ex) { this.Trace.Write(ex.InnerException.Message); this.Notification1.Text = ex.InnerException.Message; this.Notification1.Show(); } Notification1.Text = "The xml data file was refreshed!"; Notification1.Show(); } /// &lt;summary&gt; /// Get all the customers elements from the file /// &lt;/summary&gt; /// &lt;param name="sourceDocument"&gt;File that will be traversed&lt;/param&gt; /// &lt;param name="rootNode"&gt;Root node of the document&lt;/param&gt; /// &lt;param name="childNode"&gt;Child nodes that will be taken&lt;/param&gt; /// &lt;returns&gt;IEnumerable&lt;/returns&gt; /* private IEnumerable&lt;XElement&gt; GetCustomersEnumeration(XDocument sourceDocument, XName rootNode, XName childNode,XName schild,XName sschild) { var customers = sourceDocument.getElementById ; return customers; }*/ /// &lt;summary&gt; /// Validates the input string before it is saved to the file /// &lt;/summary&gt; /// &lt;param name="attribute"&gt;The attribute to which the value should be saved&lt;/param&gt; /// &lt;param name="entry"&gt;DictionaryEntry that stores the input value&lt;/param&gt; /// &lt;returns&gt;String&lt;/returns&gt; private string ValidateString(string attribute, DictionaryEntry entry) { int strLength = this.ConvertNullToEmpty(entry.Value.ToString()).Length; //Split the string if it is too long if (strLength &gt; MAX_LENGTH) { return HttpUtility.HtmlEncode(this.ConvertNullToEmpty(entry.Value).Substring(0, MAX_LENGTH)); } else { return HttpUtility.HtmlEncode(this.ConvertNullToEmpty(entry.Value).Substring(0, strLength)); } } /// &lt;summary&gt; /// Converts null value to empty string /// &lt;/summary&gt; /// &lt;param name="obj"&gt;Object that will be converted&lt;/param&gt; /// &lt;returns&gt;String&lt;/returns&gt; private String ConvertNullToEmpty(Object obj) { if (obj == null) { return String.Empty; } else { return obj.ToString(); } } } } </code></pre> <p>Here is the datasource i.e. xml file</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;tasks xmlns="http://xxxxxx.com/systemic/testflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xxxxxx.com/systemic/testflow ../../testflow.xsd"&gt; &lt;!-- Seller Login --&gt; &lt;loadPage seq="1" deleteCookies="true"&gt; &lt;taskName&gt;Load login&lt;/taskName&gt; &lt;location url="/cgi-bin/webscr?cmd=_login-run" relative="true" /&gt; &lt;/loadPage&gt; &lt;clickElement seq="2" optional="true"&gt; &lt;taskName&gt;Click LogIn Button&lt;/taskName&gt; &lt;input&gt; &lt;fields&gt; &lt;field id="login-button" waitInSecs="5"/&gt; &lt;/fields&gt; &lt;/input&gt; &lt;/clickElement&gt; &lt;fillPage seq="3"&gt; &lt;taskName&gt;FillLogin&lt;/taskName&gt; &lt;input&gt; &lt;fields&gt; &lt;field id="1" email="guestEmail" login_password="allxo123!"/&gt; &lt;field id="3" email="guestEmail3" login_password="allxo123!3"/&gt; &lt;field id="2" email="guestEmail2" login_password="allxo123!2"/&gt; &lt;/fields&gt; &lt;/input&gt; &lt;/fillPage&gt; &lt;clickElement seq="4"&gt; &lt;taskName&gt;Login&lt;/taskName&gt; &lt;input&gt; &lt;fields&gt; &lt;field id="btnLogin" submit="true" submitWait="120" waitInSecs="25" /&gt; &lt;/fields&gt; &lt;/input&gt; &lt;/clickElement&gt; &lt;/tasks&gt; </code></pre> <p>The error message shows </p> <blockquote> <p>A column named 'Value' already belongs to this DataTable.</p> </blockquote> <p>But there is no column with name 'Value'. The exception is thrown at the second line of <code>RadGrid2_UpdateCommand</code> function. I'm new to this. So please help. Thank you.</p>
37,129,365
0
Contenteditable, bizarre behaviour of child elements, and NOT whitespace independent? <p>I've been playing around with <code>contenteditable</code> fields, and have come across an odd behaviour that I cannot figure out.</p> <p>Check out <a href="https://jsfiddle.net/13u00nus/" rel="nofollow noreferrer">fiddle</a> for this particular problem.</p> <p>I have two <em>identical</em> <code>contenteditable</code> divs. Both of them have the same <code>&lt;span&gt;</code> child, followed by a single blank character (otherwise carrot issues ensue). The only difference between the two is that the second div has been "prettified", and made more readable by indenting the <code>&lt;span&gt;</code> on a new line.</p> <pre><code>&lt;div style="margin-bottom: 15px;" contenteditable="true"&gt;&lt;span class="lead" contenteditable="false"&gt;Something something&lt;/span&gt;&amp;#8203;&lt;/div&gt; &lt;div contenteditable="true"&gt; &lt;span class="lead" contenteditable="false"&gt;Something something&lt;/span&gt;&amp;#8203; &lt;/div&gt; </code></pre> <p>Try this in both of the divs...</p> <ol> <li>Place the carrot to the right-end of the content (i.e. after the blank character)</li> <li>Then hit backspace a couple times</li> </ol> <p>You'll notice that in the top (first) <code>contenteditable</code> div, you can delete the <code>&lt;span&gt;</code> element, as though it were one giant character. You should also notice that that in the second div, no amount of backspacing will ever clear it out. At least not in Safari.</p> <p>So what gives!? I thought HTML was whitespace independent - why the difference in behaviour of the two?</p> <p>Viewing the source, they have <em>slightly</em> different markup...</p> <p><a href="https://i.stack.imgur.com/4Qg9l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Qg9l.png" alt="contenteditable source"></a></p> <p>... but it still behooves me as to why there would be any difference.</p> <p>I would like it to be deletable, and so the solution is obviously just to use the former version, but it is still curious as to why this issue exists at all.</p> <p>Also! If you happen to be a <code>contenteditable</code> guru, I've been fighting with another issue <a href="http://stackoverflow.com/questions/37108671/html-css-js-contenteditable-div-with-permanent-leading-content">over here</a>. Any help on that one is welcome!</p>
4,906,065
0
<p>You can wrap <code>Wheel[4]</code> in new class by creating specific List.</p>
31,004,208
0
IE11 - flash (.swf) not working when not connected/offline using appcache (webcam.js) <p>we are running webcam.js to take pictures inside a html site. We are also using appcache to provide offline access to all of the files.</p> <p>Everything works fine in Chrome (43.0.2357.124) regardless of the connection (online/offline). When using the same site in Internet Explorer (11.0.9600.17842) we are expiriencing problems when using the webcam.js to take pictures.</p> <p>When the device is online, everything works as planned but as soon as the device goes offline, the execution/initialization of the flash plugin seems to fail (only a blank space and when you right click, it says 'could not be loaded). You can see in the network tab inside the developer tools that the webcam.swf has the status '(aborted)'.</p> <p>The status of the webcam.swf when the device is online is 304 - so it seems that it is loaded from cache, which is fine.</p> <p>We also created several testcases where we were using several different swf files and a stripped down appcache manifest, but couldn't get it to work inside IE 11 (Windows 8.1). Neither inside the metro or desktop version of the browser. We also tested on 3 different devices, but still no luck.</p> <p>Any ideas what is causing this problems in IE? Thanks in advance!</p>
30,148,228
0
<p>You're using <code>img</code> tags with <code>background-image</code>. I honestly don't know what browser support is for that, but it's a bad idea. Instead use divs. You'll also need to make the styles forcing it to inline block. Alternatively, you could go with something like font awesome/glyphicon's strategy of <code>::before</code> styling, usually used with spans.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; .outdoor { background-image: url(sprites.png); background-repeat: no-repeat; background-position: -14px -110px; width: 20px; height: 20px; display:inline-block; } .parking{ background-image: url(sprites.png); background-repeat: no-repeat; background-position: -15px -60px ; width: 20px; height: 20px; display:inline-block; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Hello Sprites.. Why are you appearing in Chrome, but not in Firefox? Please appear&lt;/h1&gt; &lt;div class="outdoor" &gt;&lt;/div&gt; &lt;div class="parking" &gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
26,729,511
0
<p>Just check once if it is only \037 or ,\037 in delimiter. And also check the same in session in set file properties for the flat file target. </p>
2,625,164
0
<pre><code>string newPassword = Membership.GeneratePassword(15, 0); newPassword = Regex.Replace(newPassword, @"[^a-zA-Z0-9]", m =&gt; "9" ); </code></pre> <p>This regular expression will replace all non alphanumeric characters with the numeric character 9.</p>
16,581,835
0
<p>I suggest you follow google plus more often for latest Android happenings. There are already plenty of discussion in their <a href="https://plus.google.com/u/0/communities/105153134372062985968" rel="nofollow">community</a> . Make sure you set JDK_HOME or JAVA_HOME appropriately, or look into <a href="http://www.ootpapps.com/2013/05/android-studio-wont-open-how-to-fix-android-studio/" rel="nofollow">this</a>.</p>
39,533,385
0
<p>As explained by @nos in a <a href="http://stackoverflow.com/questions/39532602/in-eclipse-how-to-know-which-parameter-is-the-cursor-on-a-java-method#comment66379722_39532602">comment</a>, pressing <code>ctrl+space</code> in Eclipse will popup a tooltip that highlights (in <strong>bold</strong>) the parameter where the cursor is, as illustrated in in image provided by @nos:<br> <a href="https://i.stack.imgur.com/x4AMG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x4AMG.png" alt="enter image description here"></a></p> <p>However, that still requires IDE support and is relatively cumbersome to use <em>(you have to position cursor and trigger it to use it)</em>, so you should consider other means.</p> <p>No method should take 24 parameters, but if you absolute must, then your should comment all parameter values that are not self-explanatory, e.g. <code>year</code> and <code>name</code> are probably explanatory enough, but values like <code>null</code>, <code>0</code>, <code>false</code>, <code>42</code>, <code>true</code>, etc. does not convey <em>meaning</em>, so you should comment them:</p> <pre><code>src.myFunction(year, name, /*address1*/null, /*address2*/null, /*city*/null, /*state*/"NY", /*zipcode*/null); </code></pre> <p>That way a casual observer will know exactly what the values mean.</p> <p>Another way to do this is to wrap all the parameter values in a POJO and use the builder pattern.</p> <pre><code>src.myFunction(new MyPojo() .setYear(year) .setName(name) .setState("NY")); </code></pre>
11,200,335
0
Invalid output with fscanf() <p>The language I am using is C I am trying to scan data from a file, and the code segment is like:</p> <pre><code>char lsm; long unsigned int address; int objsize; while(fscanf(mem_trace,"%c %lx,%d\n",&amp;lsm,&amp;address,&amp;objsize)!=EOF){ printf("%c %lx %d\n",lsm,address,objsize); } </code></pre> <p>The file which I read from has the first line as follows:</p> <pre><code> S 00600aa0,1 I 004005b6,5 I 004005bb,5 I 004005c0,5 S 7ff000398,8 </code></pre> <p>The results that show in stdout is:</p> <pre><code> 8048350 134524916 S 600aa0 1 I 4005b6 5 I 4005bb 5 I 4005c0 5 S 7ff000398,8 </code></pre> <p>Obviously, the results had an extra line which comes nowhere.Is there anybody know how this could happen? Thx!</p>
685,011
0
SQL Server 2008 Management Studio Snippets <p>Is there a snippets feature in SQL Server 2008 Management Studio?</p>
16,529,304
0
<p>You can try swapping backgrounds like so:</p> <p>Create CSS Class for each background and include transitions as part of the ruleset:</p> <pre><code>.background-1 { background: url('background-1.jpg'); -webkit-transition: background 500ms linear; -moz-transition: background 500ms linear; -o-transition: background 500ms linear; -ms-transition: background 500ms linear; transition: background 500ms linear; </code></pre> <p>}</p> <p>Add a script that will swap out the classes on a regular interval. (You would most likely wrap this script within $(document).ready) Since your transitioning backgrounds, you may not want the previous background immediately removed, so you can use a delay call to remove it after the transition would complete.</p> <p>The following example would start the background switch every two seconds, and remove the previous background after 1 second. Since in my CSS, I declared that the transition should take .5 seconds, the new background is already there before the old one is removed:</p> <pre><code>setInterval(function() { if($('#background').hasClass('background-1')) { $('#background').addClass('background-2'); setTimeout(function() { $('#background').removeClass('background-1'); }, 1000); } else if($('#background').hasClass('background-2')) { $('#background').addClass('background-1'); setTimeout(function() { $('#background').removeClass('background-2'); }, 1000); } }, 2000); </code></pre> <p>Note: The code that I've provided would require you to chain multiple if/else if statements together, there is probably a more efficient way to go about this. </p> <p>I've done something similar (background colors instead of images) as a teaser for an upcoming project of mine, you can check it out <a href="http://www.theaccordance.com" rel="nofollow">here</a>. </p> <p><strong>Update:</strong> Forgot to mention, make sure to declare one of the background classes in your Div element:</p> <pre><code>&lt;div id="background" class="background-1"&gt;&lt;/div&gt; </code></pre>
6,997,375
0
<p>well, i don't quite understand why your button don't respond, because i've came across similar problems but i've used different solutions. here's what i've done:</p> <pre><code>CGRect reuseableRect = CGRectMake(20, 290, 260, 37); self.actionButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; self.actionButton.frame = reuseableRect; [self.actionButton setTitle:@"Initialize" forState:UIControlStateNormal]; [self.actionButton addTarget:nil action:@selector(performAction) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:self.actionButton]; </code></pre> <p>Actually, i did this :</p> <pre><code>self.actionButton = [[UIButton alloc] initWithFrame:reuseableRect]; </code></pre> <p>but it didn't work. so i changed it into </p> <pre><code>self.actionButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; </code></pre> <p>the resueableRect is just a CGRect that I've used all through the view initialization.</p> <p>as for the three lines of your previous solution, the first one:</p> <pre><code>[self setSelectionStyle:UITableViewCellSelectionStyleNone]; </code></pre> <p>it's doing some configurations to the tableView and its cells, so it's not going to affect the button</p> <p>the second one:</p> <pre><code>cell.userInteractionEnabled = NO; </code></pre> <p>it's not configuring the button as well, what's more, since the cell is the super view of the button, this line prevents any user interactions.</p> <p>the third one is not doing anything to the button as well, so i recommend that you delete all of them if you were thinking about configuring the button</p>
6,314,327
0
I have installed Berkeley DB 5.1.25.msi Windows installer <p>I have installed Berkeley DB 5.1.25.msi Windows installer and now I want to connect to it with a Java API. How can I do that?</p>
1,217,690
0
<p>I'm probably showing my age, but I still love my copy of <a href="http://rads.stackoverflow.com/amzn/click/0201848406" rel="nofollow noreferrer">Foley, Feiner, van Dam, and Hughes</a> (The White Book).</p> <p>Jim Blinn had a great column that's available as a book called <a href="http://rads.stackoverflow.com/amzn/click/1558603875" rel="nofollow noreferrer">Jim Blinn's Corner: A Trip Down the Graphics Pipeline</a>.</p> <p>Both of these are quited dated now, and aside from the principles of 3D geometry, they're not very useful for programming today's powerful pixel pushers.</p> <p>OTOH, they're probably just perfect for an embedded environment with no GPU or FPU!</p>
24,426,871
0
Accessing a controller from a external library file codeigniter <p>I have added a external library controller in "<strong>application/libraries/Validate_login.php</strong>". </p> <p>When i load a controller in <strong>application/controllers/</strong> from external library controller, i'm getting error <code>Library verifylogin Not Found.</code></p> <p>Validate_login.php</p> <pre><code>class Validate_login extends CI_Controller { function __construct() { parent::__construct(); $this-&gt;load-&gt;model('loginuser'); $this-&gt;load-&gt;helper('url'); $this-&gt;load-&gt;library('verifylogin');// controller which is in application/controllers/ } } </code></pre>
12,552,139
0
<p>Because you work with statically allocated arrays you probably stumbled upon writing after the end of the array.</p> <p>You state that the file has exactly 21 entries but what happens with the eof condition? If you read the last entry, the stream still doesn't have the eof bit set. This only happens when you try to read and there is nothing. After the 21st entry, the loop still continues because the eof bit is not set. It reads garbage information and tries to store it into paInventory[21], but the array was only 21 in size.</p> <pre><code>//after last read x=21 and eof not set while (!InputInventory.eof () ) { //first read causes eof to be set InputInventory &gt;&gt; iTempPluCode &gt;&gt; sTempDescription &gt;&gt; dTempPrice &gt;&gt; iTempType &gt;&gt; dTempInventory; //Accessing paInventory[21] here which causes your error paInventory[x].setiPluCode(iTempPluCode); //...// } </code></pre>
2,836,845
0
<p>The extra "stuff" is there because you've passed the buffer size to <code>memcpy</code>. It's going to copy that many characters, even when the source is shorter.</p> <p>I'd do things a bit differently:</p> <pre><code>void copy_string(char *dest, char const *src, size_t n) { *dest = '\0'; strncat(dest, src, n); } </code></pre> <p>Unlike <code>strncpy</code>, <code>strncat</code> is defined to work how most people would reasonably expect.</p>
19,512,154
0
Yii CHtml submitButton Save function <p>I am using two buttons. The first one is a button to save all data in a form:</p> <pre><code>echo CHtml::submitButton("Save", array('id'=&gt;'btSubmit','class' =&gt; 'btn', 'name' =&gt; 'files', 'title' =&gt; 'Save the updates to these files')); </code></pre> <p>The second one is to complete a submission:</p> <pre><code>&lt;form action="/dataset/submit" method="post" style="display:inline"&gt; &lt;input type="hidden" name="file" value="file"&gt; &lt;input type="submit" value="Complete submission" class="btn-green" title="Submit changes to file details." onclick="btSubmit."/&gt; &lt;/form&gt; </code></pre> <p>When I click the complete submission button, I want the code to first run the save button function and then run the post submit function. However, I don't know how to use the CHtml::submitButton onClick in the other button. How can I solve this issue?</p>
14,809,694
0
<p>Ensure you are including the correct (latest) <strong>cordova</strong> file in your HTML. </p> <p>I had the same problem and I was including </p> <pre><code>cordova-1.8.0.js </code></pre> <p>rather than </p> <pre><code>cordova-2.4.0.js </code></pre>
14,359,504
0
<p>After wondering for hours through different advices, <a href="http://www.gigoblog.com/2011/01/27/add-mcrypt-to-mac-os-x-server/comment-page-1/#comment-3897">this one</a> worked for me (Installed via MacPorts):</p> <p>Courtesy of <strong>Chris Brewer</strong>:</p> <p>Download and install MacPorts from <code>http://macports.org.</code></p> <p>The following steps are performed in the Terminal:</p> <p>Force MacPorts to update (will only work if Apple's Xcode installed):</p> <pre><code>sudo port -v selfupdate </code></pre> <p>Now, install memcached:</p> <pre><code>sudo port install php5-mcrypt </code></pre> <p>Copy the newly created shared object for mcrypt into Mac OS X’s default PHP5 extension directory:</p> <pre><code>sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so /usr/lib/php/extensions/no-debug-non-zts-20090626/ </code></pre> <p>Next, you need to edit php.ini to add the extensions. Find the phrase Dynamic Extensions, and add:</p> <pre><code>extension=mcrypt.so </code></pre> <p>And finally, restart Apache:</p> <p><code>sudo apachectl restart</code></p>
26,879,181
0
Highcharts custom styling connect and label <p>How to I custom donuts in highcharts with, each start point connect label have a circle, and style the connect line, and hidden the lower value. I using highcharsjs</p> <p>like this one</p> <p><img src="https://i.stack.imgur.com/3Qqj5.png" alt="enter image description here"></p>
13,034,355
0
Web Deploy to 2 separate web servers? <p>I have an MVC3 application that I deploy to IIS 7.5 using the "Web Publish" feature in Visual Studio. I need to setup a 2nd server that will be hardware load-balanced and will mirror the setup on the 1st server.</p> <p>I am aware of the Web Farm Framework and that is an option, however I don't like the idea of the controller server being the weakest link in the chain. I think I would rather just use the hardware load balancer to direct traffic.</p> <p>Is it possible to write a manual Web Deploy script that will target 2 separate servers each time it is run? </p>