input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Reading .CSV in Java containing Backslash <p>I'm having an issue when I read cells with '\' in it and then try to replace it to '\' because of java escape property.</p>
<p>For example: "Error: The provided P\jb credenti"</p>
<p>When I read this directly from a Cell using:</p>
<pre><code>if (type == TStream.Spreadshe... | <p>Even when I tried to insert with JSON Object it gave me errors, maybe I'm doing something wrong, but what I did and it worked now is to use the <code>.replace("\\","\\\\")</code> before the assignment to the JSON Object.</p>
<p>And it worked, I'm working with multiple applications and this applications contain mult... |
What exactly does soc.recv return? <p>According to the python documentation, python's socket recv() method returns an array of 'byte' types. </p>
<p>However, if you print out this array, things that don't look like bytes also appear:</p>
<pre><code>\xd9\x01\x01\xa4\xe9\xcbV6\x15\xed|>g5\xfa\xbd\xe9Q\x19@i\x18\xff\... | <p><code>recv</code> dose indeed return raw bytes. It's only in the printing that Python bytes assumes an ASCII encoding, if the value falls within the values that are ASCII printable it will print it as the ASCII character represented by that 8bit value. If not an ASCII printable it escapes the value with <code>\x</co... |
array.splice returining a value twice <p>I have this function that replaces an array element at indexOf(before) with a string called "after". This almost works fine except I'm getting two "after" values instead of just one </p>
<p>here is my code: </p>
<pre><code>function myReplace(str, before, after) {
var strArr ... | <p>Ah the problem here is rather unlucky! This is because after it finds element 4, indexOf returns -1 (its way of saying not found), and replaces the last (-1) from the array. </p>
<pre><code>function myReplace(str, before, after) {
var strArr = [];
strArr = str.split(' ');
for (var i = 0; i < strArr.length... |
python3 12 digits script each digit equal three time beore him? <p>Write a program that displays <strong>12 digits</strong>,</p>
<p>each digit is equal to three times the digit before him.</p>
<p>I tried to code like this </p>
<pre><code>a , b , c = 1 , 1 , 1
print(c)
while c < 12 : # for looping
c =... | <p>You can use <a href="https://docs.python.org/3/reference/expressions.html#the-power-operator" rel="nofollow">power operator</a> for that:</p>
<pre><code>from itertools import islice
def numbers(x, base=3):
n = 0
while True:
yield x * base ** n
n += 1
for n in islice(numbers(1), 12):
pr... |
pip show xml shows Null <p>I am using Python 2.7.12,tried</p>
<pre><code>import xml.etree # successfully imported,
</code></pre>
<p>tried</p>
<pre><code>import lxml.etree # successfully imported.
</code></pre>
<p>when i tried to get the version of xml through </p>
<pre><code>pip show xml #Result is Null
pip show ... | <p>Because <a href="https://docs.python.org/2/library/xml.html#module-xml" rel="nofollow"><code>xml</code></a> is a built-in package in Python 2.7. Built-in modules and packages are tied to the Python version; they're usually only upgraded whenever you upgrade your Python version.</p>
<p><code>pip version</code> only ... |
How to migrate an Oracle PL/SQL procedure to PostgreSQL <p>I need to migrate an Oracle stored procedure (PL/SQL) to PostgreSQL (pl/pgsql). I can't figure out how to do it.</p>
<pre><code>Procedure Check_File ( strLine in varchar2 , lngRecord in number ) is
type tab_str is table of varchar2(500) index by binary_integ... | <p>Seems pretty straightforward.</p>
<ul>
<li>Define a function with <code>RETURNS void</code> if you don't need to return anything.</li>
<li>Declate <code>tabline</code> as <code>text[]</code> (array of <code>text</code>). See the documentation <a href="https://www.postgresql.org/docs/current/static/arrays.html" rel=... |
How to change application name in NativeScript <p>I'm working with <strong>NativeScript</strong> from <strong>Telerik</strong> and I made an app with a debug name ("notiApp") but now I can't change the app's name in launcher and action bar.</p>
<p>I already tried configuring my <code>AndroidManifest.xml</code> in <cod... | <p>Go into app >> App_Resources >> Android >> values folder.</p>
<p>There should be a strings.xml file - if not create it.</p>
<p>The content should be</p>
<p><code><?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">DISPLAY APP NAME</string>
<string name... |
Avoid "Windows protected your PC" message for a authenticode cert signed install4j installer <p>Any clue how to avoid my installer triggering the <strong>Windows protected your PC</strong> message upon launch? I thought signing with Authenticode was supposed to fix this but alas not.</p>
<p>Whereas the unsigned insta... | <p>This is the Windows Smartscreen filter. It will stop reporting your certificate once it has been downloaded a number of times from different IP addresses.</p>
<p>The only way around this is an EV certificate which requires a hardware dongle.</p>
|
select data from table where name = list? <p>Let's say I have a table names like this :</p>
<pre><code>cust_id cust_name
1 John
2 Mary
3 Pete
</code></pre>
<p>and I create a list of customers and orders in python like this :</p>
<pre><code>{'Pete','pen','Mary','apple','Pete','penc... | <p>I am assuming all the required columns are already present in your current table say <code>MY_TABLE</code>. Your SQL query should be like:</p>
<pre><code>SELECT id_order, cust_id, orders from MY_TABLE where cust_name IN ('Pete', 'Mary', 'John');
</code></pre>
<p>Columns I am expecting in "MY_TABLE":</p>
<ul>
<li... |
Converting comma-separated value to in subquery <p>I have following query : </p>
<pre><code>Set @OrderStatuses = 'Cancelled,Complete'
Select *
From TableName
Where Status in (@OrderStatuses)
</code></pre>
<p>The <code>Status</code> is what I am receiving externally and it fails to fetch any result as, what we a... | <p>One method is dynamic SQL:</p>
<pre><code>declare @sql nvarchar(max);
set @sql = 'Select * from TableName Where Status in (@list)';
set @sql = replace(@sql, '@list', '@OrderStatuses');
exec sp_executesql @sql;
</code></pre>
<p>Note: You cannot pass a list in as a parameter.</p>
<p>You can also use <code>like<... |
Not able to display static images in android with react-native <p>I am trying to display static images in my react-native android and iOS apps. It's working fine with iOS app. But I am not able to display image in android app. Following is my code:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-cons... | <p>You need to define the <code>width</code> and <code>height</code> in your <code>imageStyle</code>.</p>
|
React: How do I access a component from another component? <p>I'm working on a project using react and I have a sign up modal and a login modal that are both separate components and I want to have two links ate the top of each modal to be able to switch from the sign up model to the login model. Each component model h... | <p>The best way to handle communication between components is through a state container for the application that all components "hook in to".</p>
<p>Here's a <strong>very</strong> simple illustration:</p>
<pre><code>// this state is defined somewhere in your application
// all of your components "hook in to" this sta... |
Yii2 Gridview : how to sort on multiple columns? <p>Say I have a number of colored balls created at different times that I wish to display in a GridView.</p>
<ul>
<li>Ball - id, color, created_at</li>
</ul>
<p>Populated as:</p>
<pre><code>1, red , 2010-10-09
2, blue , 2010-11-08
3, blue , 2010-09-01
4, red , 2... | <p>You could simply try :</p>
<pre><code>'sort' => [
'attributes' => [
'color' => [
'asc' => ['color' => SORT_ASC, 'created_at' => SORT_DESC],
'desc' => ['color' => SORT_DESC, 'created_at' => SORT_ASC],
],
'created_at',
],
'defaultO... |
How to replace components with each other in react js? <p>onClick in login component, I have to display <strong>Home</strong> component and onClick in home component I have to display login component. But Getting this error</p>
<pre><code>Uncaught Error: Element type is invalid: expected a string (for built-in
compone... | <p>You definitely need to take a look at <a href="https://github.com/ReactTraining/react-router" rel="nofollow">https://github.com/ReactTraining/react-router</a> to handle the navigation between pages. You should NOT manipulate the DOM directly, since this is against React's way of doing things, since React uses a virt... |
How does one switch OS users in a ruby script? <p>I have a ruby script always initiated by the root user. The script has a certain function called <code>fou()</code>. This function needs to be executed as the user 'otherguy' rather than 'root'. How do i switch users mid ruby script, execute the function and then switch... | <p>With <code>Process::Sys.seteuid(integer)</code> and <code>Process::Sys.setegid</code> you can change the effective <code>user id</code> and <code>group id</code>. Don't confound it with <code>Process::Sys.setuid(integer)</code> and <code>Process::Sys.setgid(integer)</code>. I think</p>
<pre><code>Process::Sys.seteu... |
Create hidden cell under UItableview in Swift <p>I am not sure if the title make any sense, but I do not how else to describe it in few words.
I have a simple task I want to do. I have a UItableview in my viewcontroller. I want to create a little nice effect, so when you get to the bottom of tableview and scroll a litt... | <p>You can use Footer view for your logo in table view.</p>
|
What's Unicode/ASCII's relevance to machine code? <p>Even though machine language varies according to, well, machine, as far as I've found out, Unicode/ASCII has specific values for characters(this whole concept is still a bit confusing). So, basically, is the binary value for the character, let's say, 'A' in Linux dif... | <p>Linux and Windows are different <em>operating systems</em>, which can very well run on the same <em>machine</em> (hardware). ASCII and Unicode (and the <em>Unicode encodings</em> like UTF-8) are standards independent of any specific operating system or machine. These standards define how <em>data</em> should be expr... |
What use does if_/3 have? <p>The predicate <strong><a href="http://stackoverflow.com/questions/27358456/prolog-union-for-a-u-b-u-c/27358600#27358600"><code>if_/3</code></a></strong> seems to be <a href="http://stackoverflow.com/search?q=%5Bprolog%5D+if_">fairly popular</a> among the few main contributors in the Prolog ... | <p>In old-fashioned Prolog code, the following pattern arises rather frequently:</p>
<pre>
predicate([], ...).
predicate([L|Ls], ...) :-
<b>condition(L)</b>,
then(Ls, ...).
predicate([L|Ls], ...) :-
<b>\+ condition(L)</b>,
else(Ls, ...).
</pre>
<p>I am using lists here as an example wh... |
running graphql example on command line resulting in unexpected token <p>Was trying out the sample code given for graphql on the following link:
<a href="http://graphql.org/graphql-js/running-an-express-graphql-server/" rel="nofollow">http://graphql.org/graphql-js/running-an-express-graphql-server/</a></p>
<p>When i t... | <p>I had the same issue in a windows machine.
resolved upgrading from the LTS version to the Current one. </p>
<p>Hope it helps</p>
|
How to generate checkboxes from string list in viewbag? <p>I have the following code in my controller method that returns the view:</p>
<pre><code>public ActionResult Create()
{
var allprivs = new SQLRolerecord().GetAllPrivsInApp();
ViewBag.AllPrivsInApp = allprivs;
return View();
}
</code></pre>
<p>where the <... | <p>If you are solely looking for a label for the checkbox, then this should work:</p>
<pre><code><table>
@{
List<string> privsInApp = ViewBag.AllPrivsInApp;
foreach (var priv in privsInApp)
{
<tr>
<td>@Html.Label(priv)</td>
<td>@Html.CheckBox(pr... |
How do I get a FULL build of OpenTK for Visual Studio? <p>I have OpenTK 2.0 installed via NuGet, but it seems that some classes (Point, Rectangle, etc) aren't available in the OpenTK namespace. I can replace them with System.Drawing.Point and Microsoft.Xna.Framework.Rectangle, but then I'm dodging namespace collisions... | <p>You could build from source manually to get the Rectangle class, but it appears the reason it isn't in the NuGet package is because of some build flags that appear to not be in place for the NuGet build.</p>
<p>From the current develop branch of the project's GitHub repo (<a href="https://github.com/opentk/opentk/b... |
button action with multiple parameter <p>I'm working with swift. I've this view controller:</p>
<p><a href="http://i.stack.imgur.com/b7d7U.png" rel="nofollow"><img src="http://i.stack.imgur.com/b7d7U.png" alt="enter image description here"></a></p>
<p>In this picture from 1.1.1 to 1.2.6 all are uibutton. This button ... | <p>I think, you should use <code>UITableView</code> hierarchy if you don't used <code>UITableView</code>, use <code>UITableView</code> and use <code>section</code> and <code>row</code> <strong>tag</strong> properties for managing your buttons. <code>didSelectRowAtIndexPath</code> function using for button clicks.</p>
|
How to save the edited .csv file in python <p>I have sensor readings stored in csv files and now I am adding some more values to these files. How can I save these files in new locations in csv format for future use. </p>
| <p>Take a look at this guide: <a href="http://www.pythonforbeginners.com/systems-programming/using-the-csv-module-in-python/" rel="nofollow">http://www.pythonforbeginners.com/systems-programming/using-the-csv-module-in-python/</a></p>
<p>Basically the <a href="https://docs.python.org/3.3/library/csv.html" rel="nofollo... |
Hide half of border with grid <p>How hide half of brush with opacity mask with no path element? I want to make site "transparent". </p>
<pre><code> <Border Height="32" Width="32" x:Name="b1" CornerRadius="50" BorderThickness="3" BorderBrush="Red">
</Border>
<Grid Height="32" Width="16" Horiz... | <p>You could simply put your border insize the grid, and use the default <code>ClipToBounds="True"</code> property of the grid to clip the border like this:</p>
<pre><code> <Grid Height="32" Width="16" HorizontalAlignment="Right" x:Name="hideHaf">
<Border Height="32" Width="32" x:Name="b1" CornerRa... |
CIFS mount for a non-privileged user <p>So im trying to mount a local folder to a network location. LIKE THIS</p>
<blockquote>
<p>sudo mount -t cifs -o username="nextgen" //192.168.100.3/nextgen/Production_data /home/PRODUCTION</p>
</blockquote>
<p>Now, This works out just fine. </p>
<p>The only problem is. It cha... | <p>You can use the <code>uid=daemon,gid=daemon</code> mount options to specify the user/group mapping of a CIFS filesystem. See the <a href="https://linux.die.net/man/8/mount.cifs" rel="nofollow">mount.cifs man page</a>.</p>
<p>To avoid having to use <code>sudo</code> for the mount, add it to <code>/etc/fstab</code>. ... |
Trying to figure out a spreadsheet equation to balance bills <p>Basically I have a spreadsheet to show what has been paid by each member of a household on monthly bills, and I want it to show how much is owed to each other tenant, so that each has paid an equal share.</p>
<p>e.g. if tenant 1 pays $100, 2 pays $200 and... | <p>I changed your layout slightly so I can copy the formula down.</p>
<p>I am using Excel but it Should work in Google Sheets:</p>
<pre><code>=IF(SIGN(VLOOKUP(A7,A:C,3,FALSE)-AVERAGE($C$2:$C$4))=-1,MIN(MAX(VLOOKUP(B7,A:C,3,FALSE)-AVERAGE($C$2:$C$4),0),AVERAGE($C$2:$C$4)-VLOOKUP(A7,A:C,3,FALSE)),0)
</code></pre>
<p><... |
cordova-plugin-network-information produces ClassNotFoundException with MobileFirst V8.0 <p>When building a Cordova application for MobileFirst Platform Foundation V8.0 in conjunction with the cordova-plugin-network-information plugin, a ClassNotFoundException is thrown when the app is started.</p>
<p>The product vers... | <p>This is a known issue and APAR <a href="http://www-01.ibm.com/support/docview.wss?uid=swg1PI68455" rel="nofollow">PI68455</a> has been created to address it. A fix has been developed and will be released in the next <a href="https://www-945.ibm.com/support/fixcentral/swg/selectFixes?parent=ibm~Other%2Bsoftware&... |
Ng Image cache not working <p>Using <a href="https://github.com/ghoullier/ng-image-cache" rel="nofollow">ng-image-cache</a> directive to save the image in cache.</p>
<p>In our scenario, assets contain a list of urls that need to be preloaded so that images are visible even without a internet connection.</p>
<p>html l... | <p>First of all, ngImageCache doesn't provide offline availability for the page. If you turn off your internet connection the browser can't display the page if dont explicitly implement offline mode via <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache" rel="nofollow">AppCache</a> o... |
Steps for a clustering project <p>I am working on demographics data to cluster them geographically using python. In the dataset I have some information as age, gender, income, education level, and home address. I am going to use a clustering algorithm, but I am not sure about the steps. </p>
<p>The steps I am consider... | <p>Here are my remarks :</p>
<p><strong>1.</strong> No need for a clustering algorithm for this step, just loop over the values and check in which intervals they are.</p>
<p><strong>2 & 3.</strong> Ok. </p>
<p><strong>4.</strong> If you apply a clustering algorithm at this step, you wont get any geographical inf... |
How to remove all child nodes from parent TreeIter from Gtk.TreeStore? <p>Given a TreeStore and TreeIter, how do you remove all of the child nodes from a parent WITHOUT deleting the parent? None of these are selected, just want to clear a set of nodes under a parent.</p>
<pre><code>ParentNode
+- Child 1
+- Child 2... | <p>Try this:</p>
<pre><code>while (this.game_store.Remove (ref i));
</code></pre>
<p><a href="http://api.gtkd.org/src/gtk/TreeStore.html" rel="nofollow">Documentation of Remove function says</a>:</p>
<p><em>"@iter is set to the next valid row at that level,"
"Return %TRUE if @iter is still valid, %FALSE if not."</em... |
Swig template shows output tag before rendering content <p>I'm working on an isomorphoc react/flux app and use swig to render the content.
However, when I open the site it first shows a blank page with the <code>{{ html|safe }}</code> output tag, before rendering the actual content into my index.html file.</p>
<p>In m... | <p>The index.html was the problem. Renamed it to "site.html" and now serverside rendering works on root route and no swig tags are visible.</p>
|
changing three DB names in a connection string <p>I need to edit a script to change three connection strings in an app config file. I have created a variable for the connection string giving server, dummy DB name, username and password. </p>
<p>So, the variable is <code>Server=serverName;Database=dummyDbName;User ID=... | <p>Yes you're on the right track. But since the name you want to replace is in a property of the <code><add></code> node you need to modify that property, not the node itself:</p>
<pre><code>$node = $appConfig.configuration.connectionStrings.add |
Where-Object {$_.name -eq "aspnetdb"}
$node.connectionStr... |
How to get the current task dynaform in Process Maker? <p>I am new to working with process maker and I cannot figure out how to get the form for the current task in a process using the <code>GET /cases/{app_uid}/current-task</code>. I am able to create new cases using <code>POST /cases</code>, which go in the draft. I ... | <p>You can use the Designer REST API to find the steps that are part of a given task. In particular, you might be interested in the <a href="http://wiki.processmaker.com/3.0/REST_API_Designer#Get_Steps_for_Activity:_.3C.2Fcode.3EGET_.2Fproject.2F.7Bprj_uid.7D.2Factivity.2F.7Bact_uid.7D.2Fsteps" rel="nofollow">/steps en... |
Angular SPA uses a lot of memory in browser <p>I have a single page application built with Angular and UI-router. When clicking around I noticed the site getting slower and since I installed the Firefox addon "Tab data" to monitor the memory of each tab I noticed a significant increase of memory usage building up (star... | <p>When you are developing code through Angular js then you will be using large number of external libraries with it.</p>
<ol>
<li>When you add those libraries to the source code then try to add the
minified version of those libraries.</li>
<li>Also you can use grunt or gulp to minify the whole front-end code to a sin... |
What to do when ECS-agent is disconnected? <p>I have an issue that from time to time one of the EC2 instances within my cluster have its ECS-agent disconnected. This silently removes the EC2 instance from the cluster (i.e. not eligible to run any services anymore) and silently drains my cluster from serving servers. I ... | <p>We had this issue for a long time. With each new AWS ECS-optimized AMI it got better, but as of 3 months ago it still happened from time to time. As mcheshier mentioned make sure to always use the latest AMI or at least the latest aws ecs agent</p>
<p>The only way we were able to resolve it was through:</p>
<ol>
<... |
Alamofire v4 extra argument method in call error <p>Once I updated to alamofire version 4 I get the error: <strong>extra argument method in call</strong></p>
<pre><code>Alamofire.request("www.blabla", method: .put, parameters: parameters, headers: headers, encoding: .JSON)
</code></pre>
<p>I already changed it to use... | <p>I had this issue upgrading to Alamofire 4 and solved it by moving the headers argument and making it the last argument in the call. Also <code>encoding: .JSON</code> should be <code>encoding: JSONEncoding.default</code>.</p>
<p>Call should look like this:</p>
<pre><code>Alamofire.request(url: myUrl, method: .put, ... |
How to make live streaming using php? <p>I have live-streaming link where its format extension is .m3u8.
and I want it to be live in to my page.
I tried this code but it does'nt work</p>
<pre><code><?php
$file = 'http://93.87.85.70/PLTV/88888888/224/3221226661/04.m3u8';
$fp = @fopen($file, 'rb');
$size = filesize... | <p><code>.m3u8</code> is a playlist file, not an MP4 video. It's commonly used with HLS streams.</p>
<p>An HLS stream is made up of a whole collection of files. There will be audio/video file segments every several seconds, possibly at several bitrates, with the playlist. The playlist is updated regularly.</p>
<p>... |
How to jump all dialog BOX by code? <p>Is there a way to jump all <em>Dialog Box</em> in standard code?</p>
<p>For example if in <code>TaxVatTable.validateWrite</code> call a class <code>TaxVATNumValidateES\validateVATNum</code> and here exist a BOX and I don't want to show, is there a solution?</p>
<p>Exist a way to... | <p>Yes you can, just modify the relevant methods in <code>\Classes\Box</code>.</p>
<p>The issue is those <code>Box</code> messages are a <strong>decision</strong> point being made by the user. So how do you know what they'll always choose? You can return the <code>_defaultButton</code> and probably be O-K in most case... |
When calling SonarQube API - /api/properties?format=json - results in a Ruby error <p>I'm attempting to set up the SonarLint IntelliJ IDEA plugin (plugin for SonarQube) and it's failing due to a 500 response when the plugin calls the following URL:</p>
<pre><code>/api/properties?format=json
</code></pre>
<p>When I go... | <p>JRuby is packaged within SonarQube. It conflicts with local installation of ruby. </p>
<p>Removing the environment variables GEM_PATH, GEM_HOME and RAILS_ENV when starting SonarQube fixes the issue as it hides the ruby installation.
Command is <code>unset GEM_PATH GEM_HOME RAILS_ENV</code>.</p>
|
Sitecore no layout found <p>I'm working on a Sitecore site that's part of a multi-site installation that uses a shared codebase (dlls, etc...) and my own code. Unfortunately I don't know much about the shared code as I didn't write any of it. </p>
<p>A recent build has caused my site to stop working. Whenever I try to... | <p>I often see this issue when Templates are missing from the Web database.</p>
<p>Preview generally works from the Master database, so it isn't affected by unpublished content in the Web database.</p>
<p>Try doing a full republish of the User Defined templates folder:</p>
<p><code>/sitecore/templates/User Defined</... |
Display title and content for each marker with infobox (Google maps) <p>Okay, third and last try with this question:</p>
<p>I have this code for InfoBox</p>
<pre><code>var contentString =
'<div id="infobox"><h1>'+(beaches[i][0];)+'</h1><p>'+(beaches[i][4];)+'</p></div>';
infobox ... | <p>I think you need to put the code for the infoBox inside the loop.</p>
<pre><code>for (i = 0; i < beaches.length; i++) {
var myLatLng = new google.maps.LatLng(beaches[i][1], beaches[i][2]);
marker = new google.maps.Marker({
position: new google.maps.LatLng(beaches[i][1], beaches[i][2]),
map: map
});... |
What is the purpose of this bitwise operation? (mWidth + 0x0000000F) & ~0x0000000F; <p>Here is the line of code I'm confused at:</p>
<pre><code> mMaskRowBytes = (mWidth + 0x0000000F) & ~0x0000000F;
</code></pre>
<p>~ is the <code>NOT</code> operator right?</p>
<p>Let's say <code>mWidth</code> is 960, or 11110000... | <p>'~' is the <em>bitwise complementation</em> operator.</p>
<p>For positive <code>mWidth</code>, all it does is round upwards to the next number that is a multiple of 16. (Since 960 already divides 16, it remains unchanged).</p>
<p>There are clearer ways of doing that, although the specifics would be down to your pa... |
Can wtforms be used to validate GET parameters? <p>I have a set of GET parameters that I want to validate. Can I use WTFORMS for that purpose? All examples I find are of POST requests.</p>
| <p>Pass <code>request.args</code> instead of <code>request.form</code> when instantiating the form. They both use the same data structure, but <code>args</code> contains query args instead of form data.</p>
<pre><code>form = MyForm(request.args)
</code></pre>
<p>Flask-WTF will pass <code>form</code> if nothing is sp... |
Django filter_horizontal filtering <p>I have 2 models related by M2M type of relationship. I use <strong><em>filter_horizontal</em></strong> in the admin for editing my entities.</p>
<p>However, I would like to have a control on what is presented in the left side of the <strong><em>filter_horizontal</em></strong> widg... | <p>I think I found it!</p>
<pre><code>class MyModelAdmin(admin.ModelAdmin):
def formfield_for_manytomany(self, db_field, request, **kwargs):
if db_field.name == "cars":
kwargs["queryset"] = Car.objects.filter(owner=request.user)
return super(MyModelAdmin, self).formfield_for_manytomany(db_field, reques... |
Which JIT is running my application <p>I am trying to investigate a performance problem where an application runs slowly when run in 64bit on one of our servers, while it runs fast in 32 bit on that same machine or 64 bit anywhere else.</p>
<p>I have seen that this could be related to the JIT compiler being used. Is t... | <p><strong>JIT Version</strong></p>
<p>You can follow Hans' steps to verify that RyuJIT is loaded into your application. [2]</p>
<blockquote>
<p>use the debugger to ensure you have the new version. First have a look-see at the runtime directory with Explorer, navigate to C:\Windows\Microsoft.NET\Framework64\v4.0.30... |
Optimizing the use of arguments inside a function <p>In an interview test, for the following code : </p>
<pre><code>void GetPosition(dummyClass& a, dummyClass& b) {
a = GetOrigin();
b = a + GetAxis().ToForward() * distance;
}
</code></pre>
<p>The interviewer wrote the following comment : </p>
<blockq... | <p>He's right but it's very much a micro-optimisation. If the references are to local variables they will be very close in the stack anyway and likely still in the cache, but they could be references to distant heap object.</p>
<p>In fact you should use pointers rather then references for returns, so that caller can i... |
Using Django outside of view.py <p>I have a twisted based script running that is managing IO, monitoring serial inputs, writing logs etc. It uses Twisted to run events every minute and every hour as well as interrupt on serial traffic.</p>
<p>Can Django be used to provide an interface for this, for example taking live... | <p>Why do you need Django for such a simple use case?
For simple Http requests you can you the included Python tool:</p>
<p><a href="https://docs.python.org/2/library/simplehttpserver.html" rel="nofollow">https://docs.python.org/2/library/simplehttpserver.html</a></p>
|
Bootstrap modal images not working - Multiple <p>I just followed w3school tutorial for this bootstrap modal image. I have two image cards in my page. So I need to popup that two images. But it's working with one image only. </p>
<p><a href="http://www.w3schools.com/howto/howto_css_modal_images.asp" rel="nofollow">Link... | <p>Id must be unique, See an example here. <a href="https://fiddle.jshell.net/wg5p60g7/" rel="nofollow">https://fiddle.jshell.net/wg5p60g7/</a></p>
|
Swift 3 - fatal error: unexpectedly found nil while unwrapping an Optional value with URLSession <p>I have this method that was working in Swift 2.2 but ever since I converted my code to Swift 3 it no longer works, what this method does is take a username and password login into a URL with Windows Authentication, if th... | <p>Change the URL declaration from</p>
<pre><code>let url: URL! = URL(string: requestString)
</code></pre>
<p>to:</p>
<pre><code>let url: URL = URL(string: requestString)!
</code></pre>
<p>That alone might fix it; or it will show that your <code>requestString</code> is bad.</p>
|
HowTo: correctly synchronize TFS branches with missing changesets? <h2>Background</h2>
<p>If I <em>merge</em> our <code>main</code> branch to our <code>development</code> branch, TFS will state that there are no changes to commit. And yet, a file level comparison (using <a href="https://www.visualstudio.com/da-dk/doc... | <p>When TFS does a merge, it bases the merge on prior merge history, not on the actual contents of the source and target files. </p>
<p>This issue may by caused by picking <code>keep target</code> when perform merge or at one time, a merge with the <code>discard</code> option performed (using the command line <code>TF... |
Selecting the Maximum Value of <p><strong>Problem:</strong></p>
<p>For a set of Personal IDs there are six conditions (5 binary and 1 continuous valued) stored in a dataframe.</p>
<p>Each condition can be thought of as a single observance of a characteristic. Every time a binary condition is observed for a Personal I... | <p>I understood that you want per individual the maximum value (if it is binary or continuous does not matter for the maximum).</p>
<pre><code>library(reshape2)
s1 <- df %>% group_by(ID, Condition) %>%
summarise(value = max(as.numeric(as.character(WT))))
s1 %>% dcast(ID ~ Condition)
</code></pre>
<p>... |
Bash: read file line by line, split line, pass as an command line arg <p>I am reading a test.txt file. Format:</p>
<pre><code>79033d0135a21e45c60e283785f5914b
dde8d97a40cd22667ccb3ca972197586
4fd5ea73cd51db256384fb3333b0eb3d
</code></pre>
<p>I am reading this file line by line and splitting as (eg. line 1: 79 03 3d 0... | <p>You need command substitution, <code>$()</code>, (and also <code>echo</code>):</p>
<pre><code>a=$(echo "$line" | cut -c1-2)
</code></pre>
<p>Here the STDOUT of the command <code>echo "$line" | cut -c1-2</code> will be saved as variable <code>a</code>.</p>
<p>Instead of creating an anonymous pipe, you can use a he... |
IOError: [Errno socket error] using BeautifulSoup <p>I am trying to get the data from US Census website using beautiful soup with Python 2.7. This is the code that I use:</p>
<pre><code>import urllib
from bs4 import BeautifulSoup
url = "https://www.census.gov/quickfacts/table/PST045215/01"
html = urllib.urlopen(url).... | <p>One workaround to this problem would be to switch to <a href="http://docs.python-requests.org/en/master/" rel="nofollow"><code>requests</code></a>:</p>
<pre><code>import requests
from bs4 import BeautifulSoup
url = "https://www.census.gov/quickfacts/table/PST045215/01"
response = requests.get(url)
soup = Beautiful... |
awk one liner that prints the whole line if certain field containts specific number <p>I have a huge log file test.log it contains 50 fields</p>
<p>I would like to use awk to match a number '0' in field 20 and only if it matches 0 then print the whole line</p>
<p>to further enhance this I would like to match 2 or mor... | <pre><code>awk '$20 == 0' your-file.txt
awk '$20 == 0 && $21 == 1' your-file.txt
</code></pre>
<p>Where $20 means field 20 and $21 means field 21.</p>
|
Include email signature when sending an email though MS Graph API <p>I have an enterprise UWP application in which I send emails using the Microsoft Graph API. </p>
<p>In these emails I would like to include the authenticated user's email signature.</p>
<p>I have tested using an Office365 account with the email signa... | <p>Email signatures arenât stored in a mailbox. Email signatures are stored and set in each client. For example, you might want to have a different email signature on your phone as it may make sense to let the email recipient know that you are composing on a device that doesn't lend to composing long emails. The expe... |
MYSQL Select group by and limit per group where created_at is within this week <p>Below is my database table.</p>
<pre><code>id user_id group_id created_at
1 1 1 2016-09-29
2 1 2 2016-10-02
3 1 3 2016-10-02
4 1 4 2016... | <p>Below is the working sql query. </p>
<pre><code>SELECT a.*
FROM myTable AS a
WHERE (
SELECT COUNT(*)
FROM myTable AS b
WHERE b.user_id = a.user_id AND b.created_at >= a.created_at
) <= 3
AND YEARWEEK(a.created_at) = YEARWEEK(NOW())
ORDER BY a.user_id ASC, a.created_at ASC
</code></pre>
|
Mesos marathon cannot destroy job <p>I have a dcos cluster that is running a website. The website runs on 20 docker instances. When I'm looking at my application I see that I have 24 instances. Where 2 instances have status started but <strong>health unknown</strong> and 2 have status <strong>staged</strong>. The old i... | <p>The Marathon version you're using (1.1.2) has known <a href="https://github.com/mesosphere/marathon/issues/4039" rel="nofollow">issues</a> with lost tasks. Once DC/OS 1.8 is available on Azure the best option is to upgrade. As a workaround, for now, you can manually delete a task using Marathon's <a href="https://me... |
Output a files contents with a filename stored in a variable <p>I have a script that gathers filenames under various directories, greps them for a specific pattern, and sends that output to another script. I am having a problem with getting the contents of the file, I either get nothing or "no such file or directory er... | <pre><code>$FILENAME="cat $FILENAME"
echo $FILENAME | grep "pattern"
</code></pre>
<p>Is wrong because we set a variable by omitting the '$' prefix. Furthermore you would be setting the <code>FILENAME</code> variable to the string <code>CAT $FILENAME</code>. Instead:</p>
<pre><code>FILENAME=$(cat $FILENAME)
echo $FIL... |
Oracle: How to find overlaps in rows <p>Suppose I have the following table:</p>
<pre><code>User_ID Activity_ID
123 222
123 333
124 222
124 224
124 333
125 224
125 333
</code></pre>
<p>I want to return a count users by the different combinations of overlaps such as the following:</p>
<pre>... | <p>Assuming you have an <code>activity</code> table with activity id's, and you want to count only DISTINCT users who had the same two activities (the same user having both activities twice wouldn't count):</p>
<pre><code>select a1.activity_id, a2.activity_id, count(distinct f.user_id)
from activity a1 inner join fa... |
Activate and desactivate with same button <p>I want to create a button to activate and deactivate 3 gameobjects, but I don't get it. This is the script I'm using. Can anybody help me?</p>
<pre><code>using UnityEngine;
using System.Collections;
public class OcultarPlayer : MonoBehaviour {
public GameObject objeto1;
p... | <p>Do something simpler like this:</p>
<pre><code>public Renderer objeto1;
public Renderer objeto2;
public Renderer objeto3;
bool enabled = false;
void OnMouseDown()
{
objeto1.enabled = enabled;
objeto2.enabled = enabled;
objeto3.enabled = enabled;
enabled = !enabled;
}
</code></pre>
|
Empty Bundle in the onSaveInstanceState method <p>I display pictures from moviesdb using volley in a gridview. The next step is have that gridview in the landscape mode too. So my logic behind this,is to store the list that contains the data as key value pair inside the onSaveInstantState method as:</p>
<pre><code> @O... | <p>then it seems like that, you <strong>Movie</strong> class did implemet Serializable interface. Implement that interface, hope that will work.</p>
<pre><code>public class Movie implemets Serializable {
}
</code></pre>
|
Is color intensity accumulative and will be converged to a certain value? <p>If I keep printing a dot with any certain color at the same position, will it turn out to be a black dot? Why?</p>
| <p>No! The dot will not turn out to be black.</p>
<p>Non-black printer ink only reflects light of its colour. The rest is absorbed.
Increasing the amount of ink on one spot will not affect the spectral reflectance of that spot.</p>
<p>You can only achieve a black spot by creating something that absorbs (nearly) all v... |
Upload video with API Dailymotion <p>After upload the video file i perform a post http request to <a href="https://api.dailymotion.com/me/videos" rel="nofollow">https://api.dailymotion.com/me/videos</a> and i give in this request the information title, channel and published. In the response i have title="Sans Titre" an... | <p>Can you give more details about your API request ?</p>
<p>You can read our upload guide here : <a href="https://developer.dailymotion.com/guides/upload" rel="nofollow">https://developer.dailymotion.com/guides/upload</a></p>
|
Python, QT and matplotlib scatter plots with blitting <p>I am trying to animate a scatter plot (it needs to be a scatter plot as I want to vary the circle sizes). I have gotten the matplotlib documentation tutorial <a href="http://matplotlib.org/examples/animation/rain.html" rel="nofollow">matplotlib documentation tuto... | <p>You need to add <code>return self.scat,</code> at the end of the <code>update</code> method if you want to use <code>FuncAnimation</code> with <code>blit=True</code>. See also this nice <a href="http://stackoverflow.com/a/9416663/4481445">StackOverflow post</a> that presents an example of a scatter plot animation w... |
Jsp will not display table with contents <p>I am working on a project with java servlets and JSP.</p>
<p>I have a java class that generates me a list of products, of type <code>List<Product></code> and I saved the list in variable Products.</p>
<pre><code>Ex: List<Product> products = ProductIO.selectProd... | <p><strong>EDITED</strong></p>
<p><code>p_IO.selectProducts()</code> may be a <code>List<Product></code> so you don't need to extract list within forEach. Try this:</p>
<pre><code>....
<c:forEach items="${p_IO.selectProducts()}" var="product" >
<tr>
<td><c:out value='${product.d... |
how to make div of fixed height inside div <pre><code><style type="text/css">
#displayHeader {
img {
width: 100%;
max-width: 100%;
max-height: 100%;
}
.header-img-inner {
max-height:100%;
}
}
</style>
<div id="displayHeader" style="height: 83.03px;">
<div class="header-inner">
<div clas... | <p>Why not use <strong>position: inherit;</strong> so as to make the image and whatever you want inside the div to inherit the position. This might help, give it a try.</p>
|
Changing the height/width when calling another graph as an in-page popup using PXPopupRedirectException <p>We added a button via a graph extension to the sales order page. When we click this new button (based on selected detail row) we call a PXPopupRedirectException calling another graph to represent the popup panel. ... | <p>Here's the current default fix: You can set the size of a popup window in the code-behind of the screen using your graph:</p>
<pre class="lang-cs prettyprint-override"><code>public partial class Page_CR301000 : PX.Web.UI.PXPage
{
protected void Page_Init(object sender, EventArgs e)
{
Master.PopupHe... |
combine SQLAlchemy Core and ORM get problems <p>How do I combine the two component of SQLAlchemy -- Core (SQL Expression) and ORM ?
I have some table that using ORM mapper and others just Table object, and I want <strong>one connection and one transaction for the two</strong>. </p>
<p>I have following two examples bu... | <p>After reading more about <code>session</code>, I have answer about it. </p>
<hr>
<p><code>session</code> has its working mechanisms, one is <code>unit of work</code> --</p>
<blockquote>
<p>"All changes to objects maintained by a Session are tracked - before
the database is queried again or before the curren... |
Alloy Analyzer: finding a model for a given instance <p>I am wondering if it is possible to generate a model specification for a given instance. My goal is to check whether an instance conforms to a model or not.</p>
<p>I have found a paper dealing with automatic specification of instances. It is called 'An Automated ... | <p>To check whether or not an instance conforms to a given model, you can programmatically check (using the Alloy api) that all atoms and tuples of the instance are typed by signatures and fields of the model, and that all facts declared in the model hold in the instance.</p>
<p>The paper you refered to describe an ap... |
How to properly handle errors while consuming messages? <p>I'm consuming messages with spring-integration-kafka, using a <code>message-driven-channel-adapter</code>:</p>
<pre><code><int-kafka:message-driven-channel-adapter
id="kafkaListener"
listener-container="container1"
channel="outputFromKafka"
... | <blockquote>
<p>It looks like the configured error-channel is not used.</p>
</blockquote>
<p>What makes you believe that?</p>
<p>I just ran a test with the error channel set to <code>errorChannel</code> (the default, with a logging adapter)...</p>
<pre><code>12:06:08.366 [container-kafka-consumer-1] ERROR o.s.i.ha... |
How do you get the HTTP host with Laravel 5 <p>I'm trying to get the hostname from an HTTP request using Laravel 5, including the subdomain (e.g., <code>dev.site.com</code>). I can't find anything about this in <a href="https://laravel.com/docs/5.3/requests#request-path-and-method" rel="nofollow">the docs</a>, but I wo... | <p>Good news! The Request documentation is a bit lacking, but it turns out this is actually pretty easy. If you're in a controller method, you can inject the request object, which has a <code>getHttpHost</code> method. This provides exactly what I was looking for:</p>
<pre><code>public function anyMyRoute(Request $req... |
How To Cube A Number In Factor? <p>I'm playing with Factor trying to get a little understanding of concatenative programming. Writing a word to square a number is trivial:</p>
<pre><code>: square ( n -- n ) dup * ;
</code></pre>
<p>But for the life of me I can't seem to figure out how to cube a number:</p>
<pre><co... | <p>In case anyone else runs across this and wants to know how to do this:</p>
<pre><code>: cube ( n -- n ) dup dup * * ;
</code></pre>
<p>The <code>dup dup</code> will add the value to the top of the stack twice and then the <code>* *</code> will multiply twice. I'd bet there's a less hacky way to do this but, as I ... |
Error with thrust::device_vector in Cuda using Visual Studio 2012 <p>I'm trying to compile and run the following simple cuda example in VS2012 with a makefile:</p>
<pre><code>#include <thrust/device_vector.h>
#include <thrust/device_ptr.h>
int main()
{
thrust::device_vector<double> my_new_vector(10)... | <p>I just needed to change the <code>--gpu-name</code> option. Now it works!</p>
|
Move data from pyodbc to pandas <p>I am querying a SQL database and I want to use pandas to process the data. However, I am not sure how to move the data. Below is my input and output. </p>
<pre><code>import pyodbc
import pandas
from pandas import DataFrame
cnxn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.... | <p>I was way over thinking this one!</p>
<pre><code>cnxn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\users\bartogre\desktop\CorpRentalPivot1.accdb;UID="";PWD="";')
crsr = cnxn.cursor()
for table_name in crsr.tables(tableType='TABLE'):
print(table_name)
cursor = cnxn.cursor()
sql = "... |
Table View don't bounce <p>My question is :</p>
<p>Why when I build and run the <strong>Table View created</strong> with different rows <strong>don't bounce</strong>, although I selected the checkbox Bounces and Bounce Vertically in Xcode 6 ?</p>
| <p>Try this code:</p>
<p>[eventTable setBounces:NO];
(OR)In Storyboard untick the Bounces.</p>
|
Bootstrap Icon inside input and button on left <p>Currently, I have this (icon inside input, on left side):
<a href="http://i.stack.imgur.com/433Gi.png" rel="nofollow"><img src="http://i.stack.imgur.com/433Gi.png" alt="enter image description here"></a></p>
<p>Ideally, I would like to achieve this:
<a href="http://i.s... | <p>to make the button glow with the input you can use this css</p>
<pre><code>.form-control:focus + .input-group-btn button{
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(10... |
Xamarin pass data to activity from dynamically created button <p>In my activity I am dynamically creating controls based off of sqlite data. Each item will have a button with a click event that needs to send that rows ID to the new activity.</p>
<p>I have looked at the following page and can get this to work on a but... | <p>The main issue is that you are adding an <strong><code>int</code></strong> to the extras:</p>
<pre><code>// item.Id is an int type
viewTask.PutExtra("TaskId", item.Id);
</code></pre>
<p>And then you are trying to get it as a <strong><code>string</code></strong>:</p>
<pre><code>var test = Intent.GetStringExtra("Ta... |
XML Schema Generation based on class in C# <p>I need XML schema generation like below:</p>
<pre><code><Fields xmlns:dt="urn:schemas-microsoft-com:datatypes">
<Field dt:dt="string"></Field>
<Field dt:dt="int" NULLABLE="1" READONLY="0"></Field>
</Fields>
</code></pre>
<p>I have cl... | <p>I use <a href="https://msdn.microsoft.com/en-us/library/x6c1kb0s(v=vs.110).aspx" rel="nofollow">xsd.exe</a> for purposes like this. You'll need to add the appropriate Xml <a href="https://msdn.microsoft.com/en-us/library/2baksw0z(v=vs.110).aspx" rel="nofollow">serialization attributes</a> to the the C# class to get ... |
Corrct method for inputting radio button value in PHP in a bootstrap 3 document <p>I'm having html5 serialization and improper attribute placement error on </p>
<blockquote>
<p>input</p>
</blockquote>
<p>element in the following code:</p>
<pre><code><fieldset class="form-group">
<legend>Choose ... | <p>Instead</p>
<pre><code>if(isset($_SESSION['form']['color']) == "Green")
</code></pre>
<p>Use</p>
<pre><code>if(isset($_SESSION['form']['color']) && $_SESSION['form']['color'] === "Green")
</code></pre>
|
How to display a certain value from nested hash <p>I am trying create an app where the user could transform his name or a word with chemical elements (like breaking bad logo). After couple of questions here, trying, and long reflexion I that I have kinda find the "ideal" solution... <em>( Humm I hope...)</em></p>
<p>... | <p>Symbols are one or two characters long right? You have to decide which of the two are you going to search first: let's say 2 character, then 1. </p>
<p>For "Hello"</p>
<p>Search the hash for the next unmatched pair: He, because is a hash, you don't have to loop, simply ask if the <code>symbols.include? 'He'</code>... |
Multiple modules in Angular 2 <p>I have an Angular 2 app (RC7) which started as a single component but is quickly becoming used throughout the project in various different (and sometimes completely unrelated) ways.</p>
<p>As a result of this, a single <strong>NgModule</strong> bootstrapping all the components seems li... | <p>I don't know if you can achieve the exact solution you want, but you could try to lazy-load some of your modules.</p>
<p>For instance, you create an AppModule (used in bootstrapping). In AppModule you only import your "home" module (I'm gonna call it HomeModule).</p>
<p>Than all the other modules can be lazy-loade... |
ionic 2 page change event <p>I want to execute some code every time the page changes.</p>
<p>I could add add an <code>ngOnDestroy</code> method to every page. It appears that I could use Ionic 2 page <a href="http://ionicframework.com/docs/v2/api/navigation/NavController/">lifecycle hooks</a> (e.g. <code>ionViewDidUnl... | <p>Another option would be to create a super class where you can use the <code>ionViewDidUnload</code> method (or any other lifecycle hook) like this:</p>
<pre><code>import { Events } from 'ionic-angular';
export class BasePage {
constructor(public eventsCtrl: Events) { }
ionViewDidEnter() {
this.eventsCtrl... |
Inserting into a MongoDB that doesn't exist yet <p>I am very new to mongoDB but so far enjoying it. I have a question that may be obvious to someone but I am having a hard time finding it in the search. I'll walk you through my steps and then as the question. If you first type:</p>
<pre><code>show dbs
</code></pre>
<... | <p>By default, when you open the mongo shell you will be connected to the <code>test</code> database.</p>
<pre><code>db.stores.insert({ _id: 1, name: "Java Hut", description: "Coffee and cakes" })
</code></pre>
<p>The above query inserts a document into the <code>stores</code> collection of the <code>test</code> db. ... |
Java: Mixing Generics and VarArgs <p>I have the following Interface that defines a certain type</p>
<pre><code>public interface BaseInterface {
}
</code></pre>
<p>This interface will be used to implement a couple of enumerations, as in:</p>
<pre><code>public enum First implements BaseInterface {
A1, B1, C1;
}
pu... | <p>You need to use the following definition:</p>
<pre><code>@SafeVarargs
private static final <T extends Enum<?> & BaseInterface> T parse(String name, Class<? extends T>... types) {
// add code here
}
</code></pre>
<p><code><? extends T></code> allows the compiler to infer a more gener... |
WooCommerce - Enabling "Zero rate" tax class to some specific user roles <p>In wy WooCommerce web site, I'm going to be selling to <strong>distributors</strong> AND <strong>resellers</strong>. The problem is that <strong>resellers</strong> are exempt from TAXES and therefore I need with a custom function to enable Zero... | <p>Try this customized function based on your code where I get first the current user roles. Then I use <strong><code>in_array()</code></strong> php conditional function in an if statement to compare your 2 targeted roles with the current user roles. This way I enable or not this 'Zero rate' tax class.</p>
<p>Here is ... |
Homebrew install: Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1 <p>I ran the following command on terminal (Mac El Capitan) </p>
<pre class="lang-none prettyprint-override"><code>$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
</co... | <p>After a few hours of research and brute force I learned the issue was due to git not being configured properly. Some articles suggested downgrading your git or reinstalling all together. However, I resolved the issue just by adding the following</p>
<pre><code>git config --global user.email yourgitemail@example.c... |
Why can't HtmlAgilityPack for .NET Core 1.5.0.1 find HtmlWeb? Is there a known workaround or a right/better way to do this? <p>I'm trying to use HtmlAgilityPack for .NET Core 1.5.0.1 since HtmlAgilityPack version 1.4.9.5 seems to be incompatible with my .NET Core v1.0 project, but I'm getting an error when trying to de... | <p>The <a href="https://www.nuget.org/packages/HtmlAgilityPack" rel="nofollow">original HtmlAgilityPack</a> is still at 1.4.9.5 and it does not support .Net Core.</p>
<p>The package you are using is a <a href="https://github.com/zulfahmi93/HtmlAgilityPack.NetCore" rel="nofollow">fork</a> by Simon Mourrier and Jeff Kla... |
HeaderStyle not found in type DataGridTextColumn <p>I am trying to center my Columns in my DataGrid by using:</p>
<pre><code><DataGrid x:Name="dgvMain" Margin="10,438,10,10" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" IsReadOnly="True" ItemsSource="{Binding}">
<DataGrid.Colu... | <p>Try this:</p>
<pre><code><DataGrid x:Name="dgvMain" Margin="10,438,10,10" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" IsReadOnly="True" ItemsSource="{Binding}">
<DataGrid.Columns>
<DataGridTextColumn>
<DataGridTextColumn.HeaderStyle>
... |
Entity Framework Core - update related collection <p>I'm trying to update collection of ProjectEmployees inside ProjectModel.
I want to remove all old values and set new.</p>
<p>My models:</p>
<pre><code>public class Project
{
...
public ICollection<ProjectEmployee> ProjectEmployees { get; set; }
}
pu... | <p>I think that the old objects are not really removed from the database. You are only calling Clear() which is not enough. Try doing this:</p>
<pre><code>[HttpPost("group")]
public async Task<IActionResult> CreateGroup([FromBody] ProjectGroupModel pro)
{
var dbProject = await _context.Project
.Inclu... |
Retrieving audio file using Spring and XMLHttpRequest() results in window.URL.createObjectUrl is not a function error <p>I'm trying to download an audio file using <code>XMLHttpRequest</code> from a Spring controller without any success. There are numerous SO posts that describe different ways to do this but obviously... | <p>You have asked for a working Ajax example, so here it is:</p>
<p><strong>The controller:</strong></p>
<pre><code>@Controller
public class AjaxController {
@RequestMapping("/register")
@ResponseBody
public String register(@ModelAttribute GameUser user){
System.out.println(user);
return ... |
dblookup mediator not executed if it is placed after an iterate mediator <p>Does anyone know why a dblookup mediator is not executed if it is placed after an iterate mediator and both of these mediators are enclosed within a filter mediator? See my code snippet and corresponding log below. Thank you in advance.</p>
... | <p>In iterate mediator, use attribute <code>continueParent="true"</code></p>
|
SQL for joining different tables <p>I have the following tables : </p>
<p><a href="http://i.stack.imgur.com/lsDwz.png" rel="nofollow"><img src="http://i.stack.imgur.com/lsDwz.png" alt="enter image description here"></a></p>
<p><a href="http://i.stack.imgur.com/dpO1K.png" rel="nofollow"><img src="http://i.stack.imgur.... | <pre><code>select
'group_a' as groupname
, max( case classname when 'C123' then group_a else null end) as c123
, max( case classname when 'C456' then group_a else null end) as c456
from table1
union all
select
'group_b' as groupname
, max( case classname when 'C123' then group_b else null end) as c123
, max( case ... |
How can I get socket room name in socket 1.4? <p>I'm looking for a method or a command line to get the socket room name if possible. Any ideas or tips are highly appreciated! For example if the name of the room is 'roomName', I'm looking to get this value, ty!</p>
| <p>A socket.io socket can be in multiple rooms. In fact, it is automatically placed into a room with the same name as the <code>socket.id</code> value when the socket first connects.</p>
<p>If what you're trying to do is get a list of all the rooms a socket is in on the server-side of the connection, you can use <cod... |
Separating number and unit in a string in C# <p>I have to write an equivalent of this in C++ in C#,</p>
<pre><code>string val_in;
float val;
char unit[100];
val_in = NoSpace(val_in);
int nscan = sscanf(val_in.c_str(), "%f%s", &val, &unit);
if (nscan < 2) {
return val_in; //do nothing if scan fail
}
<... | <p>Not very elegant, but can't you just look for the first letter in the string to know where your unit starts?</p>
<pre><code> static void SplitValAndUnit(string unsplitData)
{
for (int x = 0; x < unsplitData.Length; x++)
{
if (Char.IsLetter(unsplitData[x]))
{
string value =... |
Symfony 3 DateTimeType Incorrect records <p>Form Builder:</p>
<pre><code>->add('createdAt', DateTimeType::class, array(
'label' => 'admin.accountEdit.formCreatedAt',
'format' => 'yyyy-MM-dd HH:mm',
'html5' => false,
'widget' => 'single_text'
))
</code></pre>
<p>I enter the record : 2017... | <p>Try this instead:</p>
<pre><code>'format' => 'Y-m-d H:i'
</code></pre>
<p>It follows the PHP format:
<a href="http://php.net/manual/en/class.datetime.php" rel="nofollow">http://php.net/manual/en/class.datetime.php</a></p>
|
Class vs Local instantiation <p>Is there a difference in class and local instantiation when the first one is not obligatory (usually when i can finalize them)? Is there a "rule" i should follow?</p>
<p>I have developed the habit to always instantiate other classes using class instantiation and i don't really know if t... | <p>I would prefer initialize <code>someClass</code> in given method if it is used only in that method.</p>
<p>If you want to use <code>someClass</code> across all methods (more than one) and store object state, then choose solution 1.</p>
<p>First approach is better when you want optimization, because <code>someClass... |
How to delete grants on non-existent procedure? <p>I've done a </p>
<p><code>show grants for daemon@localhost</code></p>
<p>command in my database and it shows lines for schemas that where dropped:</p>
<blockquote>
<p>GRANT EXECUTE ON PROCEDURE <code>martin_fierro</code>.<code>lote_de_tuits</code> TO 'daemon'@'loc... | <p>There is no problem issuing a REVOKE EXECUTE ON PROCEDURE xxxx TO yyyy, although the procedure doesn't exist.</p>
|
Cannot get WPF binding error trace information to write to log file configured in code <p>I'm trying to debug what I believe is a WPF binding issue that is only happening on one machine in production -- I cannot repro on a developer machine. In order to do this, I've been trying to get the binding trace information to... | <blockquote>
<p>…there's no Listeners collection to which I can add my listener instance.</p>
</blockquote>
<p>Actually, there is: <a href="https://msdn.microsoft.com/en-us/library/system.diagnostics.presentationtracesources.databindingsource(v=vs.110).aspx" rel="nofollow"><code>PresentationTraceSources.DataB... |
How to write algorithm given a runtime <p>I'm currently taking an algorithm analysis course. One of the questions of a quiz was to write an algorithm with the runtime <code>T(n) = 4T(3n/4) + n^2</code> where the algorithm does not have to do anything significant.</p>
<p>I couldn't find any similar examples so I'm unsu... | <p>To simplify how to think about this kind of problem, just use an array of <code>n</code> elements to represent a problem of size <code>n</code>.</p>
<p>Then, the running time <code>T(n)</code> represents the algorithm run on the array.</p>
<p>The running time <code>4T(3n/4)</code> represents the algorithm run on 3... |
system calls undefined! Compiling kernel module <p>I am new to kernel module programming, and trying to create raw socket in my kernel module using 'sys_socket'. I am binding this socket to an interface using 'sys_bind' and 'sys_ioctl' (for fetching interface number).</p>
<p>While compiling my module, I get the follow... | <p><code>sys_bind()</code> and <code>sys_ioctl</code> (and <code>sys_socket</code>) are the (low-level) <strong>user-space</strong> interface to the kernel. You haven't shown us the code you've written, but you'll need to use a more suitable kernel-internal interface for your net access.</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.