pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
38,294,114
0
How can I cause visual studio to automatically include a using statement like using System.Diagnostics, in every project? <p>How can I cause visual studio to automatically include a using statement like using System.Diagnostics, in every project?</p> <p>I've been developing winforms applications and console applications and would like System.Diagnostics to be imported automatically with a using statement so I don't have to manually put the using statement in.</p> <p>How can I do that?</p>
23,639,763
0
<p>The problem is that you recreating your modalVC before you presenting it.</p> <p>EX: What you're doing</p> <pre><code>-(IBAction)presentModalVC:(id *)sender{ ModalVC *modalVC = [self.storyboard instantiateViewControllerWithIdentifier:@"modal"]; [self presentViewController:modalVC animated:YES completion:nil]; } </code></pre> <p>What you need to do:</p> <p>create property of your modalVC and initialize it in <code>viewDidLoad</code> method</p>
2,694,268
0
<p>You can create your own custom controls, inheriting from TextBox, for example. Create properties that store data in the ViewState. That is the fastest and simplest way for me to achieve the result you're needing.</p>
37,597,526
0
In jvectormap is there a way to show individual us states on page load? <p>I am new to using jvectormap. I was wondering if there was a way to show individual US states on page load? I have USA drill down map working but need to be able to show specific states such as Colorado for example without having to zoom in from the larger map of the USA. I know there are ways to create your own individual state maps from vector files but just thought I would ask here to see if it was possible to do that using the map that jvector provides for the US before I went through that process. Any help is much appreciated. (I do have the individual state map js files that have county infomation but have not yet figured out how to use them.)</p> <p>Below is the script I am using that is currently showing the default US map for drilling down to specific states:</p> <pre><code>$(function () { var map1; new jvm.MultiMap({ container: $('#map1'), maxLevel: 1, mapUrlByCode: function (code, multiMap) { return 'assets/us/jquery-jvectormap-data-' + code.toLowerCase() + '-' + multiMap.defaultProjection + '-en.js'; }, main: { map: 'us_lcc_en' } }); }); </code></pre>
32,817,121
0
<p>See <a href="http://stackoverflow.com/questions/32809769/how-to-pass-subroutine-names-as-arguments-in-fortran/32811182#32811182">How to pass subroutine names as arguments in Fortran?</a> for general rules.</p> <p>Don't use <code>external</code> here. It is incompatible with advanced features like array valued functions. Generally, <code>external</code> is only for old programs in FORTRAN 77 style. Make an interface block (see the link) or try </p> <pre><code> procedure(Function1) :: RandomFunction </code></pre> <p>instead (Fortran 2003).</p>
40,975,592
0
<p>If you are going to use PHP (*nix/Windows) then you are looking for the PHP <code>dio</code> (Direct I/O) extension: <a href="http://php.net/manual/en/book.dio.php" rel="nofollow noreferrer">http://php.net/manual/en/book.dio.php</a></p> <p>From PHP manual:</p> <blockquote> <p>PHP supports the direct io functions as described in the Posix Standard (Section 6) for performing I/O functions at a lower level than the C-Language stream I/O functions (fopen(), fread(),..). The use of the DIO functions should be considered only when direct control of a device is needed. In all other cases, the standard filesystem functions are more than adequate.</p> </blockquote>
32,195,657
0
<p>place the code in appdelegate.m</p> <pre><code>if ([viewController isKindOfClass:[UINavigationController class]]) { UINavigationController *nav = (UINavigationController *)viewController; [nav popToRootViewControllerAnimated:NO]; } </code></pre>
770,179
0
PHP / Curl: HEAD Request takes a long time on some sites <p>I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete.</p> <p>For example, requesting <code>http://www.arstechnica.com</code> takes about two minutes. I've tried the same request using another web site that does the same basic task, and it comes back immediately. So there must be something I have set incorrectly that's causing this delay.</p> <p>Here's the code I have:</p> <pre><code>$ch = curl_init(); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 20); curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // Only calling the head curl_setopt($ch, CURLOPT_HEADER, true); // header will be at output curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request is 'HEAD' $content = curl_exec ($ch); curl_close ($ch); </code></pre> <p>Here's a link to the web site that does the same function: <a href="http://www.seoconsultants.com/tools/headers.asp" rel="nofollow noreferrer">http://www.seoconsultants.com/tools/headers.asp</a></p> <p>The code above, at least on my server, takes two minutes to retrieve www.arstechnica.com, but the service at the link above returns it right away.</p> <p>What am I missing?</p>
15,528,355
0
<p>initialize the jlabels and textareas before <code>add</code>ing them </p>
28,945,503
0
<p>Instead of duplicating the code as you showed, just <a href="http://api.jquery.com/trigger/" rel="nofollow">trigger a click</a> by adding <code>.trigger('click')</code> to what you have when the document loads:</p> <pre><code>$(function() { $('button').click(function() { $.get('teas.txt', function(data) { var teas = data.split('\n'); random = teas[Math.floor(Math.random() * teas.length)]; $('p').text(random); }); }).trigger('click'); }); </code></pre>
22,863,405
0
<p>Well, just searched more. Found out that I didn’t override my onMeasure method correctly. Here is my new implementation if someone stumbles upon this question:</p> <p><strong>SeatStateView.java:</strong></p> <pre><code>@Override protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec){ // Background image’s size int desiredWidth = getBackground().getIntrinsicWidth(); int desiredHeight = getBackground().getIntrinsicHeight(); int widthMode = MeasureSpec.getMode(widthMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); // Final size int width, height; // Set width depending on mode if(widthMode == MeasureSpec.EXACTLY) { width = widthSize; } else if(widthMode == MeasureSpec.AT_MOST) { width = Math.min(desiredWidth, widthSize); } else { width = desiredWidth; } // Set height depending on mode if(heightMode == MeasureSpec.EXACTLY) { height = heightSize; } else if(widthMode == MeasureSpec.AT_MOST) { height = Math.min(desiredHeight, heightSize); } else { height = desiredHeight; } // Finally, set dimension setMeasuredDimension(width, height); } </code></pre> <p>For details, check this page: <a href="http://stackoverflow.com/questions/12266899/onmeasure-custom-view-explanation">onMeasure custom view explanation</a>.</p> <p>Sorry for bothering you.</p>
41,005,656
0
<p>Something like:</p> <pre><code>var TaskList = new List&lt;Task&gt;(); //list is populated here, however you're gonna do that //this is a boolean, in case that's not clear var isProjectWorkspaceUrlPopulated = TaskList.Any(q =&gt; !string.IsNullOrEmpty(q.ProjectWorkspaceUrl)); if(isProjectWorkspaceUrlPopulated) { //...something happens, one supposes } else { //.... maybe something else? } </code></pre>
40,145,870
0
<p>Found the answer. I referred the below link : <a href="http://www.gunaatita.com/Blog/Invalid-Token-Error-on-Email-Confirmation-in-Aspnet-Identity/1056" rel="nofollow">http://www.gunaatita.com/Blog/Invalid-Token-Error-on-Email-Confirmation-in-Aspnet-Identity/1056</a></p> <p>It was due to the machine key generated by Web API and MVC. Configuring the same machine key on both Web API and MVC solved the 'Invalid Token' issue.</p>
5,355,071
0
<p>It looks like the <a href="http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#id2550663" rel="nofollow">EWMH</a> properties <code>_NET_CURRENT_DESKTOP</code> and <code>_NET_DESKTOP_NAMES</code> are what you're looking for. With Xlib, you'd use the <a href="http://tronche.com/gui/x/xlib/window-information/XGetWindowProperty.html" rel="nofollow">XGetWindowProperty</a> function.</p>
38,473,118
0
is it possible to use inheritance in uiautomator? if so how? <p>When I try to instantiate <code>testAYLogout()</code> and run the application, <code>testAXEndTrip()</code> also runs. Why is that?</p> <pre><code>public class ApplicationTest extends UiAutomatorTestCase { public void testAYLogout() throws RemoteException, UiObjectNotFoundException { //Get the device state UiDevice myDevice = getUiDevice(); //menu button UiObject menuButton = new UiObject(new UiSelector().className(android.widget.ImageButton.class.getName()).index(0)); //logout button UiObject logoutButton = new UiObject(new UiSelector().className(android.widget.CheckedTextView.class.getName()).text("Logout")); //yes button UiObject yesButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("Yes")); //no button UiObject noButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("No")); UiObject loginText = new UiObject(new UiSelector().className(android.widget.TextView.class.getName()).text("Login")); if (!myDevice.isScreenOn()) { myDevice.wakeUp(); } //click menu button and wait for new window menuButton.clickAndWaitForNewWindow(); assertTrue(logoutButton.exists()); //click logout logoutButton.clickAndWaitForNewWindow(); //click no noButton.clickAndWaitForNewWindow(); menuButton.clickAndWaitForNewWindow(); logoutButton.clickAndWaitForNewWindow(); //click yes button yesButton.clickAndWaitForNewWindow(); assertTrue(loginText.exists()); } public void testAXEndTrip() throws RemoteException, UiObjectNotFoundException { //get device UiDevice myDevice = getUiDevice(); //pick up location feild UiObject okButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("Ok").index(0)); //end trip button UiObject endTripButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("END TRIP").index(1)); //no button UiObject noButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("No")); //yes button UiObject yesButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("Yes")); //submit button UiObject submitButton = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).text("Submit")); //rate button UiObject rateButton = new UiObject(new UiSelector().className(android.widget.ImageButton.class.getName()).index(4)); //feedback field UiObject feedback = new UiObject(new UiSelector().className(android.widget.EditText.class.getName()).index(1)); //map UiObject map = new UiObject(new UiSelector().className(android.view.View.class.getName()).index(0)); //wake up device if screen is off if (!myDevice.isScreenOn()) myDevice.wakeUp(); rateButton.waitForExists(5000); rateButton.clickAndWaitForNewWindow(); feedback.setText("ride or die ma niguh"); submitButton.clickAndWaitForNewWindow(); assertTrue(map.exists()); } } </code></pre> <p>Then this is my main class</p> <pre><code>public class MainTest extends ApplicationTest{ public static void TestMain() throws RemoteException, UiObjectNotFoundException { MainTest login = new MainTest(); login.testAYLogout(); } } </code></pre>
2,111,290
0
One active IB transaction the whole lifetime of a single user application <p>Are there any negative impacts when a single user application uses only one IB transaction, which is active as long the program runs? By using only CommitRetaining and RollbackRetaining.</p> <p>Background: I want to use IBQuery(s) and connect them to a DB Grid(s) (DevExpress), which loads all records into memory at once. So I want to avoid re-fetching all data after every SQL insert command. IBTransaction.Commit would close the dataset.</p>
31,734,894
0
<p>Designate an unused column to the right as a 'helper' column and use this formula,</p> <pre><code>=TEXT(--LEFT(A4, FIND("-", A4)-1), "000")&amp;TEXT(--MID(A4, FIND("-", A4)+1,9), "0000") </code></pre> <p>Fill down and sort on the 'helper' column.</p>
17,943,043
0
<p>There is nothing wrong with getting the same service in multiple methods in a controller.</p> <p>You can change your controller into a service ( <a href="http://symfony.com/doc/current/cookbook/controller/service.html" rel="nofollow">http://symfony.com/doc/current/cookbook/controller/service.html</a> and <a href="http://richardmiller.co.uk/2011/04/15/symfony2-controller-as-service/" rel="nofollow">http://richardmiller.co.uk/2011/04/15/symfony2-controller-as-service/</a> ) and then inject that service. While that follows the best practises, your current way is not wrong.</p> <p>You cannot request that service in the constructor, using the Symfony base <code>Controller</code> class, as the service container is set after initialization.</p>
21,654,691
0
Ejabberd webadmin access timeout <p>I just installed ejabberd on a remote server. Let's say remote server's ip is <code>123.123.123.123</code>, and its internal ip address is <code>10.0.0.10</code>.</p> <p>Then, I edited:</p> <h1><code>/etc/ejabberd/ejabberd.cfg</code></h1> <pre><code>%% ... more codes %% Options which are set by Debconf and managed by ucf %% Admin user {acl, admin, {user, "admin", "myexample.com"}}. %% Hostname {hosts, ["myexample.com"]}. %% ... more codes {5280, ejabberd_http, [ %%{request_handlers, %% [ %% {["pub", "archive"], mod_http_fileserver} %% ]}, %%captcha, http_bind, http_poll, web_admin ]} %% ... more codes </code></pre> <p>and, added <code>admin</code> as admin user by executing the following in the ssh at the server <code>123.123.123.123</code>:</p> <pre><code>root:# ejabberdctl register admin myexample.com adminpassword root:# service ejabberd restart </code></pre> <h1>THINGS NOT WORKING:</h1> <p>However, the admin console <code>myexample.com:5280/admin</code> is unreachable (timeout). I've also tried <code>123.123.123.123:5280/admin</code>, but failed.</p> <h1>THINGS WORKING:</h1> <p>However, from server's console, if I access <code>10.0.0.10:5280/admin</code>, it works. Also, I can confirm the user <code>admin</code> is registered by executing the following:</p> <pre><code>ejabberdctl registered_users </code></pre> <h1>QUESTION:</h1> <p>How do I make the access the webadmin (or more importantly, accessing any ports from its external ip or domain) work?</p>
6,890,750
0
<p>I can't comment on whether its more effective to use HEAD or trying to do something like drop to the system and do a ping; but I don't think either of them is the solution you should be doing. IMHO, it isn't necessary to poll your connection. There are a lot of situations where a connection could be dropped and I don't think polling will provide much in the way of mitigating the problem. Also, the user might be annoyed. I know that if I were using an application, and then started doing something else, and all of a sudden I got a "connection lost to 3rd party error" from an application I wasn't even paying attention to; I would be very annoyed.</p> <p>If your application depends on a connection being present, then I think its fair to handle this with exception handlers. I'm willing to be bet that whatever API you're using throws some kind of exception whenever you attempt a network action and you aren't able to establish a connection. So, what I would do is in whatever class you're initializing the network action, I would follow this paradigm:</p> <pre><code>try { performNetworkAction(); } catch (NoConnectionFoundException e) { // handle the situation here } </code></pre> <p>Your application shouldn't be able to determine when a connection was lost, just how to react when you attempt a network action and no connection is found.</p> <p>That being said - you still may disagree with me. If that is the case then the frequency of polling allowed/recommended might be documented in the API for the service you're using. Also, if the resource from the 3rd party is static, you should cache it as opposed to getting it over and over again.</p>
20,100,120
0
Google Glass Live Card not inserting <p>Glass GDK here. Trying to insert a livecard using remote views from service. I'm launching service via voice invocation. The voice command works, however it appears my service is not starting(no entries in log). Service is in android manifest. Below is code:</p> <pre><code>public class PatientLiveCardService extends Service { private static final String LIVE_CARD_ID = "timer"; @Override public void onCreate() { Log.warn("oncreate"); super.onCreate(); } @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { publishCard(this); return START_STICKY; } @Override public void onDestroy() { unpublishCard(this); super.onDestroy(); } private void publishCard(Context context) { Log.info("inserting live card"); if (mLiveCard == null) { String cardId = "my_card"; TimelineManager tm = TimelineManager.from(context); mLiveCard = tm.getLiveCard(cardId); mLiveCard.setViews(new RemoteViews(context.getPackageName(), R.layout.activity_vitals)); Intent intent = new Intent(context, MyActivity.class); mLiveCard.setAction(PendingIntent .getActivity(context, 0, intent, 0)); mLiveCard.publish(); } else { // Card is already published. return; } } private void unpublishCard(Context context) { if (mLiveCard != null) { mLiveCard.unpublish(); mLiveCard = null; } } </code></pre> <p>}</p> <p>Here is AndroidManifest.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; </code></pre> <p></p> <pre><code>&lt;uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" &gt; &lt;/uses-permission&gt; &lt;uses-permission android:name="android.permission.RECORD_AUDIO" &gt; &lt;/uses-permission&gt; &lt;application android:name="com.myApp" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.myApp.MyActivity" android:label="@string/app_name" android:screenOrientation="landscape" &gt; &lt;/activity&gt; &lt;service android:name="com.myApp.services.MyService" android:enabled="true" android:exported="true"&gt; &lt;intent-filter&gt; &lt;action android:name="com.google.android.glass.action.VOICE_TRIGGER" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="com.google.android.glass.VoiceTrigger" android:resource="@xml/voice_trigger_get_patient" /&gt; &lt;/service&gt; &lt;/application&gt; </code></pre> <p></p>
37,004,893
0
<p>If you're using Apache the simpler way is to define a global variable http_proxy. On RedHat like edit /etc/sysconfig/httpd and adjust these two lines to your environment:</p> <pre><code>export http_proxy="http://proxy:8080/" export https_proxy="http://proxy:8080/" </code></pre>
7,457,885
0
<p>All of the answers you've gotten so far are overly complicated and/or slightly misleading.</p> <p>In the first construction/initialization:</p> <pre><code>T a(10); </code></pre> <p>The very obvious thing happens. The second construction/initialization is more interesting:</p> <pre><code>T aa = 10; </code></pre> <p>This is equivalent to:</p> <pre><code>T aa(T(10)); </code></pre> <p>Meaning that you create a temporary object of type T, and then construct <code>aa</code> as a copy of this temporary. This means that the copy constructor is called.</p> <p>C++ has a default copy constructor that it creates for a class when you have none explicitly declared. So even though the first version of <code>class T</code> has no copy constructor declared, there still is one. The one the compiler declares has this signature <code>T(const T &amp;)</code>.</p> <p>Now in your second case where you declare something that looks like a copy constructor, you make the argument a <code>T &amp;</code>, not a <code>const T &amp;</code>. This means that the compiler, when trying to compile the second expression, tries to use your copy constructor, and it can't. It's complaining that the copy constructor you declared requires a non-const argument, and the argument it's being given is const. So it fails.</p> <p>The other rule is that after the compiler has converted your initialization to <code>T aa(T(10));</code> it is then allowed to transform it to <code>T aa(10);</code>. This is called 'copy elision'. The compiler is allowed, in certain circumstances, to skip calls to the copy constructor. But it may only do this after it verifies that the expression is correctly formed and doesn't generate any compiler errors when the copy constructor call is still there. So this is an optimization step that may affect exactly which parts of a program run, but cannot affect which programs are valid and which ones are in error (at least from the standpoint of whether or not they compile).</p>
11,035,849
0
<p>You can use the <code>Insert</code> transformation:</p> <pre><code> &lt;resizer&gt; &lt;plugins&gt; &lt;add name="AzureReader" connectionString="DataConnectionString" xdt:Transform="Insert" /&gt; &lt;/plugins&gt; &lt;/resizer&gt; </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/dd465326.aspx">Web.config Transformation Syntax for Web Application Project Deployment</a></p>
12,832,239
0
MS Identity and Access Tool MVC 4 <p>This VS 2012 extension is meant to allow me to add a local Development STS to my MVC application <a href="http://visualstudiogallery.msdn.microsoft.com/e21bf653-dfe1-4d81-b3d3-795cb104066e" rel="nofollow">http://visualstudiogallery.msdn.microsoft.com/e21bf653-dfe1-4d81-b3d3-795cb104066e</a></p> <p>I follow the very simple instructions e.g. Right Click the project name and select Identity and Access in the menu. Select your Identity Provider and the OK to apply the settings to your web.config.</p> <p>I run my MVC 4 application and it redirects immediately to login.aspx </p> <p>I'm guessing there are <strong><em>special</em></strong> instructions for MVC 4. </p> <p>What are they? </p> <p>Where do I find them?</p> <p><em>EDIT</em></p> <p>To be clear I have created a ASP.MVC 4 Internet application in visual studio 2012. Then I am using the Identity &amp; Access Tool to add a local development STS to Test my application.</p> <p>I am running the site on a local IIS Express</p> <p>When I debug the application I am redirected to </p> <blockquote> <p>localhost:11378/login.aspx?ReturnUrl=%2f</p> </blockquote> <p>This occurs even if I remove forms authentication as suggested in advice already given.</p>
4,015,901
1
Can I include sub-config files in my mercurial .hgrc? <p>I want to keep my main <code>.hgrc</code> in revision control, because I have a fair amount of customization it in, but I want to have different author names depending on which machine I'm using (work, home, &amp;c.).</p> <p>The way I'd do this in a bash script is to source a host-local bash script that is ignored by Mercurial, but I'm not sure how to do this in the config file format Mercurial uses.</p>
30,884,194
0
<p>This looks like a case of duplicate attributes in the <code>AssemblyInfo.cs</code> file. You could delete the AssemblyInfo file and compile your project again.</p>
33,843,526
0
<p>Sure! My existdb version is 2.2.</p> <pre><code>xquery version "3.0"; declare boundary-space preserve; declare namespace exist = "http://exist.sourceforge.net/NS/exist"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "text"; declare option output:indent "yes"; import module namespace file="http://exist-db.org/xquery/file"; let $log-in := xmldb:login("/db", "admin", "admin") for $k in (35,36,37) let $AppletName := fn:doc(fn:concat('/db/project/AppletA_',$k,'.xml'))//APPLET/@NAME/string() let $collection := fn:concat('xmldb:exist:/db/project/Scripts_',$k) let $node :=(&lt;APPLET_SCRIPTS&gt;{ for $i in fn:doc(fn:concat('/db/project/AppletA_',$k,'.xml'))//APPLET_SERVER_SCRIPT let $MethodName := $i/@NAME let $MethodScript := string($i/@SCRIPT) let $file-name := fn:concat($MethodName,'.js') let $store := xmldb:store($collection,$file-name, $MethodScript) return &lt;div&gt;{$MethodScript}&lt;/div&gt; }&lt;/APPLET_SCRIPTS&gt;) return $node </code></pre> <p>A fragment of xml is:</p> <p><a href="http://i.stack.imgur.com/nAHKQ.png" rel="nofollow">screenshot xml fragment</a></p> <p>The content of file created is this one line string:</p> <p>function Prova() { try { var sVal = TheApplication().InvokeMethod("LookupValue","FS_ACTIVITY_CLASS","CIM_FAC18"); var recordFound = searchRecord(sVal); if(!recordFound) { this.InvokeMethod("NewRecordCustom"); this.BusComp().SetFieldValue("Class",sVal); this.BusComp().WriteRecord(); } } catch(e) { throw(e); } finally { sVal = null; } }</p>
30,915,333
0
ANgularJS use data from previous page <p>Is there a way to use data from previous page?</p> <p>I have two pages: '/users' and '/users/:id'</p> <p>'/users' template:</p> <pre><code>&lt;div ng-controller="userCtrl"&gt; &lt;div ng=repeat="(k,v) from data"&gt; &lt;span&gt;{{v.name}}&lt;/span&gt; &lt;a ng-href="/users/{{k}}"&gt;View details&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>'/users/:id' page</p> <pre><code>&lt;div ng-controller="userCtrl"&gt; &lt;span&gt;{{ data[currentId].name}}&lt;/span&gt; &lt;div&gt;{{additional_data}}&lt;/div&gt; &lt;/div&gt; //Controller userCtrl $scope.currentId = $stateParams.id || false; $scope.data = {}; $http.get('/users').then(function (response) { $scope.data = response; // returns // $scope.data[1] = {name: 'Alex'}; // $scope.data[2] = {name: 'Masha'}; } $scope.additional_data = 'Some data'; </code></pre> <p>On clicking on 'View detail' button we are going to another page with other template. But controller is the same.</p> <p>Is there a way to save data and not call request again? Just render old data on new page?</p>
36,058,205
0
Session data storing and fetching fails in Chrome <p>The site's form has to use obfuscated names for account and password input fields. So CodeIgniter's controller generates obfuscated names (by <code>strtolower(random_string('alpha', '12'))</code>) each time it makes a form and stores them (<code>$fields_name</code> array) in session (originally <code>flashdata</code>, now in <code>tempdata</code>) to retrieve them upon the following/next <code>POST</code> request with user data (account and password values). The log writes empty <code>$this-&gt;input-&gt;post($fields_name['account'])</code> and <code>$this-&gt;input-&gt;post($fields_name['password'])</code> since they can't be properly fetched from session. </p> <p>The form works normally (properly storing obfuscated names in session and recovers them back next request) in FireFox, Safary, yet <strong>fails in Chrome</strong>!!! IE makes each second request to work.</p> <p>I've set normal input names (<code>acc</code> and <code>pass</code>) for debugging purposes. </p> <p>I've joggled with 3 session data types: <code>flashdata</code>, <code>userdata</code> and <code>tempdata</code>. <a href="https://www.codeigniter.com/user_guide/libraries/sessions.html#how-do-sessions-work" rel="nofollow noreferrer">Docs</a>. </p> <h2>Controller to generate and save name fields in session (in debug mode):</h2> <pre><code>public function index() { // upon POST if ($this-&gt;input-&gt;server('REQUEST_METHOD') === 'POST') { echo '&lt;h4&gt;In POST:&lt;h4&gt;&lt;pre&gt; $this-&gt;session-&gt;&lt;b&gt;flashdata&lt;/b&gt;[fields_name]: '; print_r($this-&gt;session-&gt;flashdata('fields_name')); echo '&lt;br&gt; $this-&gt;session-&gt;&lt;b&gt;userdata&lt;/b&gt;[fields_name]: '; print_r($this-&gt;session-&gt;userdata('fields_name')); echo '&lt;br&gt; $this-&gt;session-&gt;&lt;b&gt;tempdata&lt;/b&gt;[fields_name]: '; print_r($this-&gt;session-&gt;tempdata()); echo '&lt;/pre&gt;'; //$fields_name = $this-&gt;session-&gt;flashdata('fields_name'); $fields_name = $this-&gt;session-&gt;tempdata('fields_name'); echo "&lt;pre&gt; fields_name from session af", print_r($fields_name, true); echo PHP_EOL; echo "&lt;/pre&gt;"; $this-&gt;form_validation-&gt;set_rules($fields_name['account'], '', 'required|is_natural'); $this-&gt;form_validation-&gt;set_rules($fields_name['password'], '', 'required|min_length[8]'); if ($this-&gt;form_validation-&gt;run()) { $this-&gt;accounts_model-&gt;unset_account_session_data(); echo 'Form is valid. To auth now...'; /* auth performing here */ exit; } else { log_activity('login', 'wrong validation - ' . $this-&gt;input-&gt;post($fields_name['account'])); echo 'failed $this-&gt;form_validation-&gt;run()'; exit; $this-&gt;session-&gt;set_flashdata('error_message', $this-&gt;lang-&gt;line('messages_wrong_clint_id_or_password')); redirect(lang_url()); } } if ($this-&gt;session-&gt;userdata('client_logged_in') === true) { redirect(lang_url('accounts/lists')); } $fields_name = array( 'account' =&gt; 'acc', //strtolower(random_string('alpha', '12')), 'password' =&gt; 'pass' // strtolower(random_string('alpha', '12')) ); $this-&gt;session-&gt;set_flashdata('fields_name', $fields_name); $this-&gt;session-&gt;set_userdata('fields_name', $fields_name); $this-&gt;session-&gt;set_tempdata('fields_name', $fields_name, 300); echo '&lt;pre&gt;$fields_name array: '; print_r($fields_name); echo '&lt;br&gt;before opening view - $this-&gt;session-&gt;&lt;b&gt;flashdata&lt;/b&gt;[fields_name]: '; print_r($this-&gt;session-&gt;flashdata()); echo '&lt;br&gt;before opening view - $this-&gt;session-&gt;&lt;b&gt;userdata&lt;/b&gt;[fields_name]: '; print_r($this-&gt;session-&gt;userdata()); echo '&lt;br&gt;before opening view - $this-&gt;session-&gt;&lt;b&gt;tempdata&lt;/b&gt;[fields_name]: '; print_r($this-&gt;session-&gt;tempdata()); echo '&lt;/pre&gt;&lt;/b&gt;'; $this-&gt;view-&gt;set('data', array( 'fields_name' =&gt; $fields_name, )); $this-&gt;view-&gt;render('homepage2'); } </code></pre> <h2>View with input names taken from the data passed into the view:</h2> <pre><code>&lt;input type="text" name="&lt;?php echo $data['fields_name']['account']; ?&gt;" &gt; &lt;input type="password" name="&lt;?php echo $data['fields_name']['password']; ?&gt;" </code></pre> <h2>See the outputs in FF</h2> <p><a href="https://i.stack.imgur.com/TKWlJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TKWlJ.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/44VYS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/44VYS.jpg" alt="enter image description here"></a></p> <h2>See the outputs in Chrome:</h2> <p><a href="https://i.stack.imgur.com/UvK87.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UvK87.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/dOelt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dOelt.jpg" alt="enter image description here"></a></p>
36,097,978
0
<p>you'll probably find it easier to query sizes if you work with the gtable,</p> <pre><code>--- title: "Untitled" header-includes: - \usepackage{lipsum} output: pdf_document: fig_caption: yes fig_crop: no keep_tex: yes geometry: width=5in --- ```{r setup, include=FALSE} library(ggplot2) library(dplyr) library(grid) library(knitr) general_fig_width &lt;- 5 ``` ```{r plot, fig.show=FALSE} p &lt;- diamonds %&gt;% sample_frac(0.3) %&gt;% ggplot(aes(x = carat, y = price, color = price)) + geom_point() + theme_dark() + theme(plot.margin = unit(c(0,0,0,0), "pt")) g &lt;- ggplotGrob(p) if(getRversion() &lt; "3.3.0"){ g$widths &lt;- grid:::unit.list(g$widths) g$widths[4] &lt;- list(unit(general_fig_width, "in")) } else { g$widths[4] &lt;- unit(general_fig_width, "in") } fig_width &lt;- convertWidth(sum(g$widths), "in", valueOnly = TRUE) left_width &lt;- convertWidth(sum(g$widths[1:3]), "in", valueOnly = TRUE) ggsave('plot-tmp.pdf', width=fig_width, height=2) ``` \begin{figure}[!hb] \hspace{`r -left_width`in}\includegraphics[width=`r fig_width`in]{plot-tmp} \end{figure} \lipsum[2] </code></pre> <p><a href="https://i.stack.imgur.com/jplWa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jplWa.png" alt="enter image description here"></a></p>
40,979,989
0
How do i override the submission url when i place order in magento. <p>so i have recently started using magento 1.9. and i have a specific problem i am not sure how to solve. I created a custom payment module, that shows up in the payment options, and when the user places the order , it redirects to my custom checkout success message. However this is not exactly what i want. I want to be able to redirect the user to my custom url if ANY payment option is selected, eg paypal or creditcard.</p> <p>In my custom controller, I want to append some info to the form, then forward it to the gateway. </p> <p>I guess the question is similar to this. But i dont want to edit magento's core code, I would like to override from my custom module. <a href="https://stackoverflow.com/questions/7749748/magento-place-order-redirection-for-payment-gateway">Magento &quot;place order&quot; redirection for payment gateway</a></p> <p>is there anyone that can help or point me in the right direction? </p>
18,624,768
0
<p>If you are already familiar (and comfortable) with</p> <ul> <li>linear algebra</li> <li>basic calculus</li> <li>Newton's laws of motion</li> </ul> <p>then <a href="http://www.museful.net/2011/system-modelling/6dof-rigid-body-dynamics" rel="nofollow">6DoF Rigid Body Dynamics</a> is what you are looking for. It's a brief article written [disclaimer: by me] when I once had to develop a helicopter flight simulator.</p> <p>Using a rotation matrix allows for extremely simple modelling equations, but there exists a simple mapping to and from a quaternion if you <a href="http://www.museful.net/2011/system-modelling/expressing-3dof-rotation" rel="nofollow">prefer that representation for other reasons</a>.</p>
16,016,720
0
<p>It depends for what you want to do with the Acess Token.</p> <p>If you want an acess token to access an user data. You can use the "setExtendedAccessToken" method, how the luschn said in his answer.</p> <p>But, if you want an acess token to access some public information, like an a feed from a public group, or a page. So you can uses an App Access Token. Which you gets here <a href="https://developers.facebook.com/tools/access_token/" rel="nofollow">https://developers.facebook.com/tools/access_token/</a></p>
482,276
0
How can I test an NSString for being nil? <p>Can I simply use</p> <pre><code>if(myString == nil) </code></pre> <p>For some reason a string that I know is null, is failing this statement.</p>
3,465,330
0
<p>Another answer assuming IEEE <code>float</code>:</p> <pre><code>int get_bit_index(uint64_t val) { union { float f; uint32_t i; } u = { val }; return (u.i&gt;&gt;23)-127; } </code></pre> <p>It works as specified for the input values you asked for (exactly 1 bit set) and also has useful behavior for other values (try to figure out exactly what that behavior is). No idea if it's fast or slow; that probably depends on your machine and compiler.</p>
33,876,999
0
Click doesn't work on this Google Translate button? <p>I am creating an Tampermonkey userscript that would automatically click the "star" button on Google Translate website and save my searches so that I can later view them and rehearse.</p> <p>This is the button that I am targeting: <a href="https://i.stack.imgur.com/KnVg0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KnVg0.png" alt="enter image description here"></a></p> <p>This is what I've got so far:</p> <pre><code>// @match https://translate.google.com/#en/de/appetit/ var el = document.getElementById("gt-pb-star"); setTimeout(function(){ el.click(); },4000); </code></pre> <p>I encountered 2 problems.</p> <ol> <li><code>@match</code> should be every translate.google.com search and not just appetit. How do I specify the whole domain?</li> <li>I tried clicking the "star" button with click() method but it doesn't work. Not sure why.</li> </ol> <p>Can you please help me finish this userscript?</p> <p>Edit: it seems that setting <code>match</code> to <code>https://translate.google.com/</code> handles the first question. Still don't know why click() doesn't work.</p>
19,383,247
0
Casting (converting) number in a format with multiple dots (a version number) to string <pre><code>#define EXTERNAL_API_VERSION 1.12.1 std::string version = boost::lexical_cast&lt;std::string&gt;(EXTERNAL_API_VERSION); </code></pre> <p>This code generates a compilation error:</p> <pre><code>error C2143: syntax error : missing ')' before 'constant' error C2059: syntax error : ')' </code></pre> <p>Are there any simple alternatives for casting number in such format (more then one dot) to string?</p>
22,622,319
0
Scala Future not Awaitable? <p>I am trying to use scala Futures to implement a threaded bulk get from a network service key/value store.</p> <p>roughly</p> <pre><code>import scala.concurrent._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration._ def bulkGet(keys: List[String]) val listFut = keys.map( future{ "network get request here" } ) val values = Future.sequence(listFut) Await.result(values, Duration(10, SECONDS)) </code></pre> <p>gives me a compile error</p> <pre><code>[info] Compiling 1 Scala source to .../target/scala-2.10/classes... [error] .... type mismatch; [error] found : scala.concurrent.Future[List[String]] [error] required: scala.concurrent.Awaitable[scala.concurrent.Future[List[String]]] [error] Await.result(values, Duration(10, SECONDS)) ^ </code></pre> <p>what am I doing wrong.<br> I am following the docs re: how to block on a result<br> <a href="http://docs.scala-lang.org/overviews/core/futures.html" rel="nofollow">http://docs.scala-lang.org/overviews/core/futures.html</a></p> <p>Is a scala.concurrent.Future not by definition Awaitable? How do I coerce it to be?</p>
3,906,533
0
The opposite of 2 ^ n <p>The function a = 2 ^ b can quickly be calculated for any b by doing <code>a = 1 &lt;&lt; b</code>. What about the other way round, getting the value of b for any given a? It should be relatively fast, so <strong>logs are out of the question</strong>. Anything that's not O(1) is also bad.</p> <p>I'd be happy with <em>can't be done</em> too if its simply not possible to do without logs or a search type thing.</p>
9,950,737
1
How to avoid circular dependencies when setting Properties? <p>This is a design principle question for classes dealing with mathematical/physical equations where the user is allowed to set any parameter upon which the remaining are being calculated. In this example I would like to be able to let the frequency be set as well while avoiding circular dependencies.</p> <p>For example:</p> <pre><code>from traits.api import HasTraits, Float, Property from scipy.constants import c, h class Photon(HasTraits): wavelength = Float # would like to do Property, but that would be circular? frequency = Property(depends_on = 'wavelength') energy = Property(depends_on = ['wavelength, frequency']) def _get_frequency(self): return c/self.wavelength def _get_energy(self): return h*self.frequency </code></pre> <p>I'm also aware of an update trigger timing problem here, because I don't know the sequence the updates will be triggered:</p> <ol> <li>Wavelength is being changed</li> <li>That triggers an updated of both dependent entities: frequency and energy</li> <li>But energy needs frequency to be updated so that energy has the value fitting to the new wavelength!</li> </ol> <p>(The answer to be accepted should also address this potential timing problem.)</p> <p>So, what' the best design pattern to get around these inter-dependent problems? At the end I want the user to be able to update either wavelength or frequency and frequency/wavelength and energy shall be updated accordingly.</p> <p>This kind of problems of course do arise in basically all classes that try to deal with equations.</p> <p>Let the competition begin! ;)</p>
16,818,943
0
<p>If I'm not mistaken, scikit.audiolab is merely for reading/writing audio files but I think in addition you'll want to look at the signal processing libraries in scipy to actually build your feature vectors.</p> <p><a href="http://docs.scipy.org/doc/scipy/reference/signal.html" rel="nofollow">http://docs.scipy.org/doc/scipy/reference/signal.html</a></p>
32,749,999
0
<p>We use a custom form framework (called ShockOut SPForms) that allows us to display content based on group membership. We make the form as a .aspx file in the site (using sharepoint designer). <a href="https://github.com/jbonfardeci/ShockoutForms" rel="nofollow">Click here</a> to check out the framework. Using this custom framework allows us to make very customized forms by using some html and a little javascript. </p> <p>You asked how to write the access control into the workflow, so my answer may not be right on target. However, the workflow does not control access to the list data. </p> <p>Column level permissions are not included in SharePoint to my knowledge. You may need to split the information into separate lists to enable access control. </p> <p>Using a custom form and some queries to the REST or SOAP api, you could accomplish your result. (Note: this last suggestion is for SharePoint experts).</p>
6,239,807
0
<p>It sounds like you want to compare a short term (5-day) moving average to a longer-term moving average (e.g., something like 90 days).</p> <p>As a refinement, you might want to do a least-squares linear regression over the longer term, and then compare the shorter term average to the projection you get from that.</p>
17,824,370
0
<p>I would use the provided utility sqldump to do this. It will dump out the table you want direct to a CSV file suffixed with .dsql. Works on all platforms. The table parameter works with wildcards so you can select to dump out all tables at once (change the PUB.ABCCode to PUB.% in example below. </p> <p>In my testing this is 80% faster than using EXPORT command in 4GL code.</p> <pre><code>c:\program files\epicor\&gt;sqldump -u XXXX -a XXXX -t PUB.ABCCode progress:T:l </code></pre> <p>ocalhost:9450:mfgsys</p> <pre><code>OpenEdge Release 10.2A0329 as of Thu Apr 19 10:02:30 EDT 2012 Table : PUB.ABCCode Dump file : PUB.ABCCode.dsql Dumped 10 Records, 1647 bytes, 1 seconds. Dumped 1 Tables c:\program files\epicor\&gt; </code></pre>
40,201,607
0
<p>It happens because of the padding. If you don't use <code>box-sizing:border-box;</code> and add background to that bootstrap column, the background applies to the padding as well. I've added this global rule to your jsfiddle:</p> <pre><code>* { box-sizing: border-box; } </code></pre> <p>and it all works how you intended. Read up on box-sizing, I always use border-box when I build my sites, this way there is no surprises when it comes to sizes of the elements when I add padding or border.</p> <p><a href="https://jsfiddle.net/e1vx1mhb/1/" rel="nofollow">https://jsfiddle.net/e1vx1mhb/1/</a></p>
26,149,978
0
<p>Qualify the final line with the namespace of where the protocol was defined. I kept thinking to try to call the <code>whatever</code> method in the <code>other</code> namespace since it was defined there.</p> <pre><code>(what/whatever (-&gt;Other)) </code></pre> <p>Thanks goes to @soulcheck and everyone else who took time to help.</p>
24,429,143
0
<p>To keep it flexible you may use macrodef with nested element attribute for 1-n filesets, f.e.<br> a macrodef that creates a dirlisting in xmlformat for nested filesets :<br></p> <pre><code>&lt;macrodef name="dir2xml"&gt; &lt;attribute name="file" description="xmlfile for filelisting"/&gt; &lt;attribute name="roottag" description="xml root tag"/&gt; &lt;attribute name="entrytag" description="xml tag for entry"/&gt; &lt;element name="fs" description="nested filesets for listing"/&gt; &lt;sequential&gt; &lt;pathconvert property="files.xml" dirsep="/" pathsep="&amp;lt;/@{entrytag}&amp;gt;${line.separator} &amp;lt;@{entrytag}&amp;gt;" &gt; &lt;!-- 1-n nested fileset(s) --&gt; &lt;fs/&gt; &lt;/pathconvert&gt; &lt;!-- create xmlfile --&gt; &lt;echo message="&amp;lt;@{roottag}&amp;gt;${line.separator} &amp;lt;@{entrytag}&amp;gt;${files.xml}&amp;lt;/@{entrytag}&amp;gt;${line.separator}&amp;lt;/@{roottag}&amp;gt;" file="@{file}"/&gt; &lt;/sequential&gt; &lt;/macrodef&gt; </code></pre> <p>Usage :<br></p> <pre><code>&lt;dir2xml file="filelistant.xml" entrytag="antfile" roottag="antfilelist"&gt; &lt;fs&gt; &lt;fileset dir="." includes="**/*.xml"/&gt; &lt;fileset dir="../ant_xml" includes="**/*.xml"/&gt; &lt;/fs&gt; &lt;/dir2xml&gt; </code></pre>
21,732,797
0
Provide Custom message on Camel Validation <p>I am trying to provide a custom message upon validation failure as oppose to the sending the stack trace to the user. It seems I am not understanding how to do this. My route is as follows:</p> <pre><code> &lt;route&gt; &lt;from uri="restlet:/foo"/&gt; &lt;onException&gt; &lt;exception&gt;org.apache.camel.ValidationException&lt;/exception&gt; &lt;transform&gt; &lt;simple&gt;Validate your stuff&lt;/simple&gt; &lt;/transform&gt; &lt;stop/&gt; &lt;/onException&gt; &lt;validate&gt;&lt;constant&gt;false&lt;/constant&gt;&lt;/validate&gt; &lt;to uri="mock:result"/&gt; &lt;/route&gt; </code></pre> <p>I tried to place the onException before or after the validation. Neither works. What I want to return to the user is 'Validate your stuff' as opposed to the complete stack trace. </p> <p>Any clue?</p>
5,359,321
0
<p>I finally found the answer myself.</p> <p>It is possible to query the "like" table using the comment "xid" as a "post_id".</p> <pre><code>SELECT post_id, user_id FROM like WHERE post_id = &lt;comment xid&gt; </code></pre>
18,960,152
0
<p>This is quite hacky, but should work:</p> <pre><code>:path =&gt; @path.as_json.merge(:questions =&gt; @path.questions.as_json) </code></pre> <p>Eventually you can override as_json inside your model:</p> <pre><code>def as_json(options={}) includes = [*options.delete(:include)] hash = super(options) includes.each do |association| hash[self.class.name.underscore][association.to_s] = self.send(association).as_json end hash end </code></pre> <p>And then just call: <code>:path =&gt; @path.as_json(:include =&gt; :questions)</code></p> <p>Note it will also add <code>:include</code> option to to_json method. </p>
22,407,806
0
<p>You need to reference the image relative to your pages. For example, if your site is structured built in a folder called public_html and your page your image is to be located on is index.html and you've placed an image called example.jpg in a folder called img within public_html, you could reference that image from index.html with the following:</p> <pre><code>&lt;img src="img/example.jpg" alt="" /&gt; </code></pre> <p>For security purposes, you can't reference local images, they need to be uploaded somewhere. Say you uploaded the image to the root of example.com you would change the src to "<a href="http://www.example.com/example.jpg" rel="nofollow">http://www.example.com/example.jpg</a>"</p> <p>Since you want it as your background image, you should use some css such as:</p> <pre><code>body {background:url('img/example.jpg') repeat;} </code></pre>
4,368,012
0
<p>Look into <a href="http://dev.mysql.com/doc/refman/5.0/en/join.html" rel="nofollow">joins</a> for selecting data from multiple tables:</p> <pre><code>SELECT * FROM Prices LEFT JOIN (Vendors, Products) ON (Products.product_id=Prices.product_id AND Vendors.vendor_id=Prices.vendor_id) </code></pre>
13,195,822
0
<p>You could take a dictionary but make sure that you prevent duplicate key insertion. Keys of dictionary would serve as the unique numbers you need</p>
11,567,649
0
<p>You likely have a retain loop. Use the Allocations tool in Instruments with <a href="http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/" rel="nofollow">Heapshot</a> to find it.</p>
12,284,387
0
<p>Take a look at this link <a href="https://developers.google.com/analytics/resources/articles/gdata-migration-guide" rel="nofollow">https://developers.google.com/analytics/resources/articles/gdata-migration-guide</a>. Look at section "Create a Project in the Google APIs Console" it will walk you through the whole process. This is what I used and it helped.</p>
34,461,270
0
<p>Don't bother with splicing the array, just create a new one:</p> <pre><code>var newArray = []; $('#clearChecked').click(function() { $('#keyWords &gt; input').each( function (n, obj) { if ($(obj).is(':checked')) { newArray.push($(obj).val()); } } }); localArray = newArray; </code></pre>
36,595,895
0
<p>This should work (though not recommended)</p> <pre><code>^(55[0-5]|5[0-4][0-9]|[1-4][0-9][0-9]|[1-9][0-9]|[5-9])$ </code></pre> <p><strong><a href="https://regex101.com/r/mX2eE9/3" rel="nofollow">Regex Demo</a></strong></p> <p><strong><a href="http://ideone.com/gM4waF" rel="nofollow">Proof of correctness</a></strong></p>
22,219,282
0
<p>It is probably because you are not calling the method from UI thread. Try using Dispatcher.BeginInvoke:</p> <pre class="lang-cs prettyprint-override"><code>Dispatcher.BeginInvoke(()=&gt; { tbl1.Text = ""; tbl1.Visibility = System.Windows.Visibility.Collapsed; }); </code></pre>
2,212,998
0
How to restrict renaming a file in VB.NET? <p>Is it possible to restrict renaming a exported file in <a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET" rel="nofollow noreferrer">VB.NET</a>?</p>
11,474,265
0
<p>Do you know what type of server your using? If IIS, you need to make sure that it's set up to work with your file extensions.</p>
3,018,906
0
<blockquote> <p>But what if you wanted to model Mt. Everest?</p> </blockquote> <p>You'd use something else. Clearly, if every engine you've encountered uses heightmaps, it works just fine for them. No need to overcomplicate things if the simple solution works for you.</p>
36,922,012
0
<p>Okay, I think my issue was forgetting how multinomial regression works. The prediction formula for multinomial regression is</p> <p><a href="https://i.stack.imgur.com/IX4xO.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IX4xO.gif" alt="enter image description here"></a></p> <p>So you need a set of coefficients for every class.</p>
8,773,966
0
<p>The <code>readlines()</code> method of a file object returns a list of the lines of the file <em>including the newline characters</em>. Your checks compare with strings not including newline characters, so they always fail.</p> <p>One way of getting rid of the newline characters is</p> <pre><code>lines = (line.strip() for line in open("out2.txt")) </code></pre> <p>(Note that you don't need <code>readlines()</code> -- you can directly iterate over the file object itself.)</p>
5,106,441
0
<p>Literal bytes, shorts, integers and longs starting with <code>0</code> are interpreted as being <a href="http://en.wikipedia.org/wiki/Octal" rel="nofollow">octal</a></p> <blockquote> <p>The integral types (byte, short, int, and long) can be expressed using decimal, octal, or hexadecimal number systems. Decimal is the number system you already use every day; it's based on 10 digits, numbered 0 through 9. The octal number system is base 8, consisting of the digits 0 through 7. The hexadecimal system is base 16, whose digits are the numbers 0 through 9 and the letters A through F. For general-purpose programming, the decimal system is likely to be the only number system you'll ever use. However, if you need octal or hexadecimal, the following example shows the correct syntax. The prefix 0 indicates octal, whereas 0x indicates hexadecimal.</p> </blockquote> <p>from <a href="http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html" rel="nofollow">Primitive Data Types</a></p>
16,374,870
0
Fancybox gallery with images in different places <p>I have a (html) page with an image gallery (all images together) and one separate image.</p> <p>I put all the images from the image gallery in a</p> <pre><code>&lt;div id="imageGallery"&gt; </code></pre> <p>I put the separate image in a</p> <pre><code>&lt;div id="separateImage"&gt; </code></pre> <p>and I have javascript</p> <pre><code>$('#imageGallery a').fancybox(); $('#separateImage a').fancybox(); </code></pre> <p>Fancybox works fine on both, the image gallery and the separate image. I can cycle through the image gallery, however, the separate image is not part of the cycle. How can I make it so that it cycles through all the images: those from the image gallery and the separate image?</p> <p>I tried adding</p> <pre><code>rel="gallery" </code></pre> <p>to the anchors as explained at <a href="https://www.inkling.com/read/javascript-jquery-david-sawyer-mcfarland-2nd/chapter-7/advanced-gallery-with-jquery" rel="nofollow">https://www.inkling.com/read/javascript-jquery-david-sawyer-mcfarland-2nd/chapter-7/advanced-gallery-with-jquery</a></p> <p>but apparently this only works if all images are in the same div (id)!?</p>
10,393,734
0
<p>The second one is a completely different selector. <code>tr .c</code> with a space in between looks for an element with class name "c" that has an ancestor <code>&lt;tr&gt;</code> element. The first one <code>tr.c</code> looks for a <code>&lt;tr&gt;</code> element that has the class name "c".</p> <p>This has nothing to do with specificity, but instead your understanding of CSS.</p>
18,535,855
0
<blockquote> <p><em>Is there some kind of "interpolate string" function, where I can add hash k-v pairs to an existing hash.</em></p> </blockquote> <p>No need for <em>interpolation</em>.</p> <p>Do this:-</p> <pre><code> merge(attribute_name =&gt; stuff) </code></pre> <blockquote> <p><em>Another thing, what happens in this function is that I have an empty array called "scores", fill it up with the candidate+score hashes, and return the array scores at the end, is there some kind of syntactic sugar or something for this?</em></p> </blockquote> <pre><code>attribute_name = "key_i_want" candidates.each_with_object([]) do |candidate,scores| scores.push candidate.attributes.merge(attribute_name =&gt; stuff) end </code></pre>
3,876,002
0
<p>Smalltalk's keyword-like syntax for method calls inherently defines the arity of the method. There's no <code>&amp;rest</code> pattern like in Common Lisp.</p> <p>You can of course have a method take a list, like <code>BlockClosure&gt;&gt;valueWithArguments:</code> but that's hardly the same thing.</p> <p>You might modify <code>Compiler</code> to support variadic method calls. Maybe the call would simply have <code>with:</code> between each of the variables:</p> <p>(condition) ifTrue: aBlock elseIf: aBoolean with: aSecondBlock with: anotherBoolean with: aThirdBlock</p>
31,539,404
0
Way to Attach to an Oxyplot render exception <p>I have an oxyplot plot that is occasionally throwing an exception and displaying it to my users, but it does not bubble up to my application. Is there a way to attach to an event that occurs when this exception is thrown? Or some other way to bubble the exception up so I can see what it is and deal with it appropriately?</p>
11,952,461
0
<p>Check out e.g. the <a href="http://en.cppreference.com/w/cpp/string/byte/strtok" rel="nofollow"><code>strtok</code></a> function. Use it in a loop to split at the <code>'&amp;'</code> to get all the key-value pairs into a vector (for example). Then go though the vector splitting each string (you can use <code>strtok</code> again here) at the <code>'='</code> character. You can put the keys and values in a <code>std::map</code>, or use directly.</p> <p>For an even more C++-specific method, use e.g. <a href="http://en.cppreference.com/w/cpp/string/basic_string/find" rel="nofollow"><code>std::string::find</code></a> and <a href="http://en.cppreference.com/w/cpp/string/basic_string/substr" rel="nofollow"><code>std::string::substr</code></a> instead of <code>strtok</code>. Then you can put keys and values directly into the map instead of temporary storing them as strings in a vector.</p> <p><strong>Edit:</strong> How to get the last pair</p> <p>The last key-value pair is not terminated by the <code>'&amp;'</code> character, so you have to check for the last pair <em>after</em> the loop. This can be done by having a copy of your string, and then get the substring after the last <code>'&amp;'</code>. Something like this perhaps:</p> <pre><code>char *copy = strdup(data); // Loop getting key-value pairs using `strtok` // ... // Find the last '&amp;' in the string char *last_amp_pos = strrchr(copy, '&amp;'); if (last_amp_pos != NULL &amp;&amp; last_amp_pos &lt; (copy + strlen(copy))) { last_amp_pos++; // Increase to point to first character after the ampersand // `last_amp_pos` now points to the last key-value pair } // Must be free'd since we allocated a copy above free(copy); </code></pre> <p>The reason we need to use a copy of the string, if because <code>strtok</code> modifies the string.</p> <p>I still would recommend to you use C++ strings instead of relying on the old C functions. It would probably simplify everything, including you not needing to add the extra check for the last key-value pair.</p>
11,949,181
0
<p>To get speedups with GPUs, you want to have lots of computation per data element because data transfer is so slow. You usually want 2 or 3 nested for loops running on the GPU with at least a 1000 threads.</p>
21,071,922
0
<p>Youre question is confusing on the output you are trying to achieve but,</p> <p>you could use a <code>list</code> like this:</p> <pre><code>list1 = [1,2,3,4] return list1 </code></pre> <p>then you can acsess those values from on variable</p> <p>More on <a href="http://docs.python.org/release/1.5.1p1/tut/lists.html" rel="nofollow">lists</a></p>
24,562,320
1
math domain error (linalg) in statsmodels.tsa.api.VAR <p>I am trying to use Vector Auto Regression (VAR), but I got this error: ValueError: math domain error</p> <p>Here is my code: (and also I don't know how to give it only one dimensional data)</p> <pre><code> Y = [data[0,:] , data[1,:]] import statsmodels.tsa.api Vmodel = statsmodels.tsa.api.VAR(Y) results = Vmodel.fit(2) results.summary() results.plot() results.plot_acorr() </code></pre> <p>Here is the Error message:</p> <pre><code>Traceback: \AppData\Local\Continuum\Anaconda\myproj\mainProg.py", line 190, in AR results = Vmodel.fit(4) \AppData\Local\Continuum\Anaconda\lib\site-packages\statsmodels\tsa\vector_ar\var_model.py", line 443, in fit return self._estimate_var(lags, trend=trend) \AppData\Local\Continuum\Anaconda\lib\site-packages\numpy\linalg\linalg.py", line 1837, in lstsq nlvl = max( 0, int( math.log( float(min(m, n))/2. ) ) + 1 ) </code></pre> <p>My data type is numpy array of floats.</p> <p>Thanks for your help.</p> <p>Update: Solved by transposing the input data!</p>
9,258,689
0
tap event not working in view <p>Please check the code below, what I am doing wrong? I want to output to console when tap event on body.</p> <pre><code> Ext.define('iApp.view.LoginView', { extend: 'Ext.Panel', xtype: 'loginViewPanel', config: { style: "background-color: #3f3f3f;", html: 'hello world', listeners: { el: { tap: function() { console.log('tapped'); } } } } }); </code></pre> <p>no output to console...</p>
30,741,920
0
<p>Use the query to store the raw quotients and adjust the field's <em>Format</em> property afterward.</p> <pre class="lang-sql prettyprint-override"><code>SELECT ([DB].[Number1] / DB.[Number2]) AS [New Column Name] INTO newTable FROM [OldTable] as DB; </code></pre> <p>You can open the table in Design View and choose <em>"Percent"</em> for the field's <em>Format</em>. If you want to do the same thing with VBA, I tested this in Access 2010:</p> <pre class="lang-vb prettyprint-override"><code>Dim db As DAO.Database Set db = CurrentDb With db.TableDefs("newTable").Fields("New Column Name") .Properties.Append .CreateProperty("Format", dbText, "Percent") End With </code></pre> <p>Another way to approach this would be to create the table, set the field format, and then use an "append query" (instead of a "make table query") to load your data into the table. </p>
10,060,450
0
RedirectToAction returns to calling Action <p>Inside my Index action I call my NotFound Action. I follow in debug and the if condition tests true, it goes to the "return RedirectToAction("NotFound");" statement, it then goes to Dispose and then returns to the Index Action not the NotFound Action. If I Redirect to the Details Action it works fine. These are all in the same controller. The NotFound View just contains text.</p> <pre><code>if (condition tests true) { return RedirectToAction("NotFound"); } public ActionResult NotFound() { return View(); } </code></pre> <p>I've also tried the NotFound as a ViewResult. It still fails.</p>
21,239,182
0
<p>In MapReduce, have the first line of your mapper parse the line it is reading. You can do this with custom parsing logic, or you can leverage pre-built code (in this case, a CSV library).</p> <pre><code>protected void map(LongWritable key, Text value, Context context) throws IOException { String line = value.toString(); CSVParser parser = new au.com.bytecode.opencsv.CSVParser.CSVParser(); try { parser.parseLine(line); // do your other stuff } catch (Exception e) { // the line was not comma delimited, do nothing } } </code></pre>
5,127,017
0
Automatic Numbering of Headings H1-H6 using jQuery <p>I read <a href="http://stackoverflow.com/questions/535334/html-css-autonumber-headings">related</a> posts, but didn't find a solution for IE, so I ask for a jQuery-solution for this problem:</p> <p>I've some nested hierarchical Headings like this</p> <pre><code>&lt;h1&gt; heading 1&lt;/h1&gt; &lt;h2&gt; subheading 1&lt;/h2&gt; &lt;h1&gt; heading 2&lt;/h1&gt; &lt;h2&gt; subheading 1&lt;/h2&gt; &lt;h2&gt; subheading 2&lt;/h2&gt; </code></pre> <p>I need some automated headings output like this:</p> <pre><code>1. heading 1 1.2 subheading 1 2. heading 2 2.1. subheading 1 2.2. subheading 2 </code></pre> <p>Is there a way how this can be achieved using jQuery or alike, working in IE6+?</p>
38,747,747
0
<p>Try this code : </p> <pre><code>YourViewControllerClass *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewController"]; // instanciate your viewcontroller [(UINavigationController *)[self sideMenuController].rootViewController pushViewController:viewController animated:YES]; //push your viewcontroller [[self sideMenuController] hideRightViewAnimated:YES completionHandler:nil]; //hide the menu </code></pre>
38,428,975
0
Why can't I see HttpUtility.ParseQueryString Method? <p>I am developing a simple app to consume a web API using this new fantastic .Net core framework. In one of my previous projects I use HttpUtility.ParseQueryString to parse the query string. But I couldn't find any reference to this method in new Asp.Net core RC2 assemblies and packages. It may happen that there is new method available which I don't know yet. I my current project, I have referenced following packages-</p> <pre><code>Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final", "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final", "Microsoft.AspNetCore.Mvc.WebApiCompatShim": "1.0.0-rc2-final", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final", "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final", "Microsoft.AspNetCore.WebUtilities": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final", "Microsoft.NETCore.App": { "version": "1.0.0-rc2-3002702", "type": "platform" }, "System.Collections.Specialized": "4.0.1-rc2-24027", "System.Net.Http": "4.0.1-rc2-24027", "System.Runtime.Serialization.Json": "4.0.1" </code></pre> <p>Is there any other package that I need to reference in order to access this Method? </p>
39,641,416
0
vuforia SDK for an IBM MobileFirst <p>I need to implement a few vuforia functionalities in an IBM MobileFirst existing project.</p> <p>However I see that vuforia has provided SDKs only for android, iOS, UWP and unity.</p> <p>How do I integrate vuforia SDK into my existing IBM MobileFirst project?</p>
11,849,808
0
<p>This will omit integer values represented as strings:</p> <pre><code>if(is_numeric($num) &amp;&amp; strpos($num, ".") !== false) { $this-&gt;print_half_star(); } </code></pre>
303,680
0
<p>In C# depending on how the class is used, you could define one class within the scope of the other.</p> <pre><code>public class CBar { CBar() { m_pFoo = new CFoo(); } CFoo m_pFoo; private class CFoo { CFoo() { // Do stuff } } } </code></pre>
27,629,843
0
Sql Server Insert Into table with values stored proc output with other values <p>Say there is a table</p> <pre><code>CREATE TABLE [Fruit]( [FruitId] [int] NOT NULL Identity(1,1), [Name] [nvarchar](255) NOT NULL, [Description] [nvarchar] (255) NOT NULL, [Param1] [int] NULL, [Param2] [int] NULL) </code></pre> <p>and stored proc where it takes an input and has an output parameter called @description. I cannot modify this stored proc.</p> <pre><code>EXECUTE usp_GetFruitDescription @Name, @Description OUTPUT </code></pre> <p>Now I want to do insert into the [Fruit] table, something like the following.</p> <pre><code>INSERT INTO [Fruit] Values( basket.Name ,EXECUTE usp_GetFruitDescription basket.Name ,basket.Param1 ,basket.Param2) FROM [FruitBasketEntry] basket WHERE basket.type is not null and basket.id &gt; 6 </code></pre> <p>How can this be achieved? I've seen examples of INSERT INTO [table] EXECUTE usp_proc, but I haven't seen it with inserting with other values not from stored proc output. Thanks!</p>
16,177,890
0
<p>Had the same problem. You have to define the <code>_gaq</code> array. Just add this after your Google Analytics script in the header:</p> <pre><code>var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-X']); _gaq.push(['_trackPageview']); </code></pre>
36,121,369
0
<p>I'm too have same issue and all developers have it. The reason because of new Google play store in the new design the user should click a small button " Top charts" then swipe to reach " top new free" but in the old design the user only swipe to reach " top new free" so old design is more simple to the user also there is another reason preventing the user from reaching " top new free" because in Google play store first page ( homepage) there is tons of apps and games so the user will be busy surfing it and rarly click the small " top charts" button then swipe to reach " top new free" so the problem is entirly from Google play store new design </p>
13,438,616
0
<p>If the backing field isn't static, how are you going to obtain an instance for that field when you use it in a static property accessor? Remember that the <code>static</code> modifier on a member means that this member is associated with the <em>type itself</em>, rather than with a particular <em>instance</em> of that type. For a static property to work, it has to have a backing field that is itself static so that it can be implemented accordingly.</p> <p>It's for the same reason that you can't access any non-static members within static methods without having an instance to work with.</p>
19,216,953
0
I thought I had the program ready to run but when I run it nothing happens <p>So I thought I had this code being able to work but it is not working. I do not know what to do and I have tried looking at everything everyone has suggested but I just do not know what to do so any help would be greatly appreciated!</p> <pre><code>import java.awt.*; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JLabel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class memory extends JPanel{ /** * */ private static final long serialVersionUID = 1L; @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(new Color(156, 93, 82)); g.fill3DRect(21,3,7,12, true); g.setColor(new Color(156,23,134)); g.fillOval(1,15,15,15); g.fillOval(16,15,15,15); g.fillOval(31,15,15,15); g.fillOval(7,31,15,15); g.fillOval(22,31,15,15); g.fillOval(16,47,15,15); setVisible(false);} public memory() { GridLayout h =new GridLayout(3,3); final JFrame frame = new JFrame(); final JPanel pan = new JPanel(h); frame.add(pan); pan.setBackground(new Color(130,224,190)); pan.setFont(new Font("Serif", Font.BOLD, 28)); JButton button1= new JButton(); pan.add(button1); final JLabel label1= new JLabel("hi"); label1.setVisible(false); pan.add(label1); JButton button2= new JButton(); pan.add(button2); final JLabel label2= new JLabel("hi"); label2.setVisible(false); pan.add(label2); JButton button3= new JButton(); pan.add(button3); final JLabel label3 = new JLabel("hi"); label3.setVisible(false); pan.add(label3); JButton button4 = new JButton(); pan.add(button4); final JLabel label4 = new JLabel("hi"); label4.setVisible(false); pan.add(label4); JButton button5= new JButton(); pan.add(button5); final JLabel label5= new JLabel("hi"); label5.setVisible(false); pan.add(label5); JButton button6= new JButton(); pan.add(button6); final JLabel label6= new JLabel("hi"); label6.setVisible(false); pan.add(label6); JButton button7= new JButton(); pan.add(button7); final JLabel label7= new JLabel("hi"); label7.setVisible(false); pan.add(label7); JButton button8= new JButton(); pan.add(button8); final JLabel label8= new JLabel("hi"); label8.setVisible(false); pan.add(label8); JButton button9= new JButton(); pan.add(button9); final JButton button10= new JButton("Exit"); pan.add(button10); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Memory Game"); frame.setSize(500,500); frame.setVisible(true); setLayout(new BorderLayout()); add(pan,BorderLayout.CENTER); add(button10, BorderLayout.SOUTH); setSize(600,600); setVisible(true); final JLabel label9= new JLabel("hi"); label9.setVisible(false); pan.add(label9); button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { label1.setVisible(true); } }); button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { label2.setVisible(true); } }); button3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { label3.setVisible(true); } }); button4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { label4.setVisible(true); } }); button5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { label5.setVisible(true); } }); button6.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { label6.setVisible(true); } }); button7.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { label7.setVisible(true); } }); button8.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { label8.setVisible(true); frame.getContentPane().add(new memory()); setVisible(true); }}); ; button9.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { label9.setVisible(true);}} ); button10.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (button10.getSize() != null) { System.exit(0);}} });}; public static void main(String args[]) { new memory(); }; } </code></pre>
20,668,832
0
<p>You can use:</p> <pre><code>is_page( 'page' ); </code></pre> <p>where <code>'page'</code> is the post title</p>
30,659,591
1
Write text data to array between boundaries <p>I have a problem which i hope you can help me solve! I have a txt that looks like:</p> <pre><code>A100 1960 3 5 6 7 8 9 10 11 12 13 A200 1960 3 5 6 7 8 9 10 11 12 13 14 15 A300 1960 3 5 6 7 8 9 10 11 12 13 14 15 16 17 </code></pre> <p>I want to search for the keyword for example <code>A200 1960</code>. Now I want to save all numbers between <code>A200 1960</code> and <code>A300 1960</code> in an <code>array(x, y)</code>.</p> <p>I managed to skip to the line I want. The problem now is to write to the array until line <code>A300 1960</code>. Also the length of the array can variate.</p> <pre><code>def readnumbers(filename,number,year): number_year = np.asarray([]) f = open(filename) lines = f.readlines() f.close() strings_number = 'A'+ str(number) strings_year = ' ' + str(year) STARTER = strings_number+ '' + strings_year start_seen = False for line in lines: if line.strip() == STARTER: start_seen = True continue if start_seen == True: parts = line.split() </code></pre>
15,400,725
0
<pre><code>27 struct timeval tv; 28 struct ExpandedTime etime; 29 gettimeofday(&amp;tv, NULL); 30 localTime(&amp;tv,&amp;etime); </code></pre> <p>This code isn't inside of any function. It's sitting bare naked out in the global scope wilderness. It needs to be shown back home, back inside a function, any function. There are wolves out there.</p>
23,672,937
0
How to show 1 value from 2 values in combobox xaml? <p>Hi I have a ComboBox with show 2 values name and code I want that when I press the drop down in the ComboBox show the 2 values but when I select from the drop down I want the code only return to combo box then the name return in other TextBox. </p> <pre><code>&lt;ComboBox ItemsSource="{Binding StoreList,Mode=TwoWay}" VerticalAlignment="Center" Grid.Column="1" Name="ItemAutoComplete" SelectedItem="{Binding TransactionHeader.StorePerRow,Mode=TwoWay}" Margin="0,0,105,6" Grid.ColumnSpan="3" IsEnabled="{Binding TransactionHeader.inter, Mode=TwoWay }" SelectedValue="iserial" Grid.Row="2" Height="44"&gt; &lt;ComboBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding ENAME}"&gt;&lt;/TextBlock&gt; &lt;TextBlock Text="{Binding code}"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/ComboBox.ItemTemplate&gt; &lt;/ComboBox&gt; </code></pre> <p>I want to return the ename in text box </p> <p>and show the code only when I choose from list</p>
30,628,975
0
<p><a href="http://stackoverflow.com/a/4636735/579148">This SO answer shows a way to convert a float array into a byte array</a>. Then you can use <a href="https://msdn.microsoft.com/en-us/library/system.io.file.writeallbytes(v=vs.110).aspx" rel="nofollow">File.WriteAllBytes() method</a> to write it out to a file. How MatLab reads it, though, will be the issue.</p> <p>I found <a href="http://www.mathworks.com/help/matlab/ref/fread.html" rel="nofollow">some documentation for MatLab for the <code>fread</code></a> command. It looks like is has some arguments that will allow you to define the precision of the read. You may be able to use "float" as the precision value. Though, the is a bit of an educated guess as I am not very familiar with MatLab.</p>
21,631,670
0
RabbitMQ best practice for creating many consumers <p>We are just starting to use RabbitMQ with C#. My current plan is to configure in the database the number and kind of consumers to run on a given server. We have an existing windows service and when that starts I want to spawn all of the RabbitMQ consumers. My question is what is the best way to spwan these from a windows service? </p> <p>My current plan is to read the configuration out of the database and spawn a long running task for each consumer. </p> <pre><code> var t = new Task(() =&gt; { var instance = LoadConsumerClass(consumerEnum, consumerName); instance.StartConsuming();//blocking call }, TaskCreationOptions.LongRunning); t.Start(); </code></pre> <p>Is this better or worse than creating a thread for each consumer?</p> <pre><code> var messageConsumer = LoadConsumerClass(consumerEnum, consumerName); var thread = new Thread(messageConsumer.StartConsuming); </code></pre> <p>I'm hoping that more than a few others have already tried what I'm doing and can provide me with some ideas for what worked well and what didn't.</p>
33,734,803
0
Overriding x-frame-options at page level <p>I am working on a .net application. There is an X-frame-options header included in the web.config file which is set to same origin. I want to override this for some specific pages to allow framing from some particular websites. Is there a way i can do this? If i set the header in html meta tag will that override the global setting? I have referred a similar question <a href="http://stackoverflow.com/questions/6666423/overcoming-display-forbidden-by-x-frame-options">Overcoming &quot;Display forbidden by X-Frame-Options&quot;</a> but this was posted way back in 2011 and there was a comment in the thread that mentioned this does not work any longer.</p>
19,981,768
0
<p>Which theme are you using? Isn't there a sidebar block you can position the contact details in? You shouldn't need to do any floating to achieve this, but rather the positioning of the blocks should be happening at the theme layout and template level.</p>
16,191,858
0
How to speed up svm.predict? <p>I'm writing a sliding window to extract features and feed it into CvSVM's predict function. However, what I've stumbled upon is that the svm.predict function is relatively slow.</p> <p>Basically the window slides thru the image with fixed stride length, on number of image scales. </p> <ul> <li>The speed traversing the image plus extracting features for each window takes around 1000 ms (1 sec).</li> <li>Inclusion of weak classifiers trained by adaboost resulted in around 1200 ms (1.2 secs)</li> <li>However when I pass the features (which has been marked as positive by the weak classifiers) to svm.predict function, the overall speed slowed down to around 16000 ms ( 16 secs )</li> <li>Trying to collect all 'positive' features first, before passing to svm.predict utilizing TBB's threads resulted in 19000 ms ( 19 secs ), probably due to the overhead needed to create the threads, etc.</li> </ul> <p>My OpenCV build was compiled to include both TBB (threading) and OpenCL (GPU) functions. </p> <p>Has anyone managed to speed up OpenCV's SVM.predict function ? </p> <p>I've been stuck in this issue for quite sometime, since it's frustrating to run this detection algorithm thru my test data for statistics and threshold adjustment.</p> <p>Thanks a lot for reading thru this !</p>
26,988,117
0
<p>You may create a trigger like this: on updating dbo.Parts table update dbo.part_numbers table and vice versa. Here is a MSDN article about triggers: <a href="http://msdn.microsoft.com/en-us/library/ms189799.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms189799.aspx</a></p>
7,274,585
0
Linux find out Hyper-threaded core id <p>I spent this morning trying to find out how to determine which processor id is the hyper-threaded core, but without luck. </p> <p>I wish to find out this information and use <code>set_affinity()</code> to bind a process to hyper-threaded thread or non-hyper-threaded thread to profile its performance.</p>