input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How does a Java if statement work when it has an assignment and an equality check OR - d together? <p>Why does this if statement, with an assignment and equality check, evaluate to false?</p>
<pre><code>public static void test() {
boolean test1 = true;
if (test1 = false || test1 == false) {
System.ou... | <p>Because of <a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html">operator precedence</a>. It is equivalent to this:</p>
<pre><code>boolean test1 = true;
if (test1 = (false || test1 == false)) {
...
}
</code></pre>
<p>The part in brackets evaluates to <code>false</code>.</p>
|
javascript only work in 1 data <p>I'm trying to get button hidden using javascript.
here the javascript code:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><script&... | <p>You can't have multiple elements with the same ID in one HTML document. IDs (identifiers) are supposed to be unique. Look into <code>name</code> or <code>class</code> and selecting multiple elements using <code>document.getElementsByName</code> or <code>document.getElementsByClassName</code>.<br>
Alternatively, if y... |
Setting up Boost 1.62 in CLion windows <p>I have been trying to set up boost 1.62 in CLion for past two days now. I have seen almost all the stack question but still couldn't do it.</p>
<p>My CMakeList.txt looks like this:</p>
<pre><code>cmake_minimum_required(VERSION 3.6)
project(DeSNN_CPP)
set(CMAKE_CXX_FLAGS "${C... | <p>You told it where to look for library files, but didn't tell it which ones to look for.</p>
<p>You need to add </p>
<pre><code>target_link_libraries(DeSNN_CPP ...list of boost libraries...)
</code></pre>
<p>to your CMakeLists.txt file</p>
|
Javascript load multiple csv and create global reachable array <p>I need to load a lot of csv files. Yet Im loading with this function.</p>
<pre><code>$.ajax({
url: 'my.csv',
dataType: 'text',
}).done(successFunction);
</code></pre>
<p>Then I run successFunction, with that I create array and with same code as abo... | <p>First off, I disrecommend using your own CSV parser. This problem has been solved, use <a href="https://github.com/gkindel/CSV-JS" rel="nofollow">a library</a>.</p>
<p>The other part of the problem is <em>"I need to load many files via HTTP with jQuery"</em>, and that's easy.</p>
<ol>
<li>Prepare a list of file ur... |
insert into database from angularjs using c# <p>i am creating a web app in which i need to insert into the table from my web app i am using angularjs for speeding up my app but i am not able to fire the insert query properly</p>
<p>here is my code</p>
<pre><code><body >
<div ng-app="myApp" ng-controller="cu... | <p>Try this:</p>
<pre><code>public void tadmin(string tid, string auserid, string bpass, string cname, string ddesignation, string eteam)
{
SqlCommand cmd = new SqlCommand("insert into admin(tid,userid,pass,name,designation,team) values(@tid,@userid,@pass,@name,@designation,@team)", con);
cmd.Parameters.AddWit... |
How is handled auto fill form in Vaadin Framwork <p>I need to fix error in form. when user enters a birth number. It based on this information fills textfields for sex/ date birth. It is created in Vaadin. Did i miss something. How does it know what is entered and how does it parse ? Is it doing parsing? </p>
| <p>My bad, i should have to check method for pre - validation first. At the time i asked this, i didn´t know how it is being implemented. Simple parser was used but one check method prevented that from execution. Thanks though.</p>
|
use notifyDataSetChanged(); after updating SQLite from other activity and inside the same activity <p>Good day,<br>
Summary : I am making a sample memo app with SQLite as its database. </p>
<p><strong>MainActivity</strong> </p>
<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCr... | <p>Listview doesnt update by updating DB. You need to update the list you gave the adapter and then call notifyDataChange().</p>
<p>So update the list you gave the listview's udapter everytime you change the DB data.</p>
<p>Just update the <code>memos</code> list then call notify data change.</p>
|
Setting font in Android <p>In android Using <code>setTypeface</code> method we can set the font to the control of our wish programmatically, but i want to know is there a way we can avoid this and set the font in layout XML file itself?</p>
<p>I Just want to specify the path of the file & font should get updated a... | <p>You can use <a href="https://github.com/chrisjenx/Calligraphy" rel="nofollow">Calligraphy</a> library where you can specify font in XML itself.</p>
<pre><code><TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fontPath="fonts/Roboto-Bold.ttf"/>... |
Nonstatic Member Reference with "std::cout" in Header <p>I'm sort of new to C++, and I've been making my way through a bit in my own project. I ran into an error with this header and .cpp file</p>
<hr>
<pre><code>// main.cpp
#include <iostream>
#include "Header.h"
int main() {
MyClass::TestFunction(); //'... | <blockquote>
<p>the issue comes from std::cout not being static and the declaration in main.cpp needs it to be static</p>
</blockquote>
<p>You either have to make your function static OR to intanciate an object of your class and hen call its function :</p>
<p>main.cpp</p>
<pre><code>int main() {
MyClass pony;
... |
Sending push notifications's token to the server. Alamofire error <p>I'm trying to send token which I got in <code>didRegisterForRemoteNotificationsWithDeviceToken</code> to the server. But I got an error while sending: <code>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type ... | <p>The <code>deviceToken</code> you are getting inside your project's appDelegate <code>didRegisterForRemoteNotificationsWithDeviceToken</code> is an <code>NSData</code> object. To extract the actual token String from that <code>NSData</code> object use this following code.</p>
<pre><code> let tokenChars = UnsafePoin... |
ImportError: No module named 'bs4' in django only <p>The same question has been asked a number of times but I couldn't find the solution.</p>
<p>After I install a package using pip, I am able to import it in python console or python file and it works as expected.
The same package when I try to include in django, it gi... | <p>You don't show either the code of your site or the command you ran (and the URL you entered, if any) to trigger this issue. There's almost certainly some difference between the Python environment on the command line and that operating in Django.</p>
<p>Are you using virtual environments? If so, dependencies should ... |
Android XML layout messed up? <p><a href="http://pastebin.com/T0HgiRTA" rel="nofollow">XML Link</a></p>
<p>I am designing an app with multiple buttons, but it isn't working properly. </p>
<p><strong>This is how it shows in Android studio</strong>
<a href="http://i.stack.imgur.com/lkf5P.png" rel="nofollow"><img src="h... | <p>Possible reason for this could be you have multiple layout files for various screen density / screen dimensions / android version.</p>
<p>Check your layout folder and ensure there is not multiple lauout files in multiple folders ;)</p>
|
Correct header for copying HTML on the clipboard <p>I have a complete HTML document and need to copy it on the clipboard so that it can be pasted into Microsoft Word and other applications. Now I figured out that the obvious way doesn't work and I need to add a special header before the HTML content. Unfortunately all ... | <p>Okay, so I figured out that the fragment thing is not required. The header has the following numbers:</p>
<ul>
<li>1 and 3: The length of the header itself (zero-padding is necessary to achieve predictable results, otherwise the header length changes after putting in the numbers, making the numbers invalid)</li>
<l... |
Make sure sub directories don't listen to mod rewrite <p>I am using some dynamic pages on every .html file in my root.</p>
<p>With the following line:</p>
<pre><code>RewriteRule ^(.*).html content.php?alias=$1 [L]
</code></pre>
<p>This works fine, but I also got some other websites on the same location, only a few f... | <p>Tweak your regex. Instead of <code>.*</code> which matches anything you should use <code>[^/]+</code> to match anything but <code>/</code>. This ensures, you don't select anything in sub-directories:</p>
<pre><code>RewriteRule ^([^/]+)\.html$ content.php?alias=$1 [L,QSA,NC]
</code></pre>
|
Disable tax programmatically for a specific user role <p>In my woocommerce web site, I have enable Tax in general WooCommerce settings.</p>
<p>I would like to disable tax for a specific user role programmatically ( with any hooks ), from my shop, checkout page and from order email.</p>
<p>How could I achieve this?</p... | <blockquote>
<p>You can't disable WooCommerce tax for a specific user role programmatically, <strong>but you can apply for a specific user role a zero tax rate.</strong></p>
</blockquote>
<p>First you need to have this specific user role set in worpress. If it's the case, let say that this custom user role is <stron... |
Laravel eloquent - filter by concatenation of multiple columns <p>I'm new to Laravel, and I got stuck trying to perform the following. I have a simple users table with the following columns: </p>
<ul>
<li><code>id</code></li>
<li><code>first_name</code></li>
<li><code>last_name</code></li>
</ul>
<p>I'm about to make ... | <p>I think you forgot the wildcards in the LIKE statement.</p>
<p>Instead of this</p>
<pre><code>$query->select(\DB::raw('CONCAT_WS(" ", `last_name`, `first_name`)
as `full_name`, id'))->having('full_name', 'LIKE',$input['filter_name']);
</code></pre>
<p>Try:</p>
<pre><code>$query->select(\DB::raw('CO... |
How to create toggleable sidenav layout in React.js? <p>I am porting my layout from jQuery to React.js. This is very common one that consists of:</p>
<ul>
<li>header with toggle button</li>
<li>sidenav with navigation links</li>
<li>content whose width adapts to sidenav state.</li>
</ul>
<p>As you can imagine to achi... | <p>Just add a <code>class</code> to the navbar on button toggle and animate the transition using css.</p>
<p>See the demo</p>
<p><a href="https://jsfiddle.net/kuLy0g8z/" rel="nofollow">https://jsfiddle.net/kuLy0g8z/</a> </p>
|
On redash how to create a chart that shows counts of types <p>I am trying to create something similar to the example here:</p>
<p><a href="http://demo.redash.io/embed/query/387/visualization/518?api_key=cc11cd75d4f3934b17de1f0621abd2f0c9cce713" rel="nofollow">http://demo.redash.io/embed/query/387/visualization/518?api... | <p>The steps are:</p>
<ol>
<li>You write the query, run it and get the results.</li>
<li>Click on "+ New Visualization" (next to the table header).</li>
<li>Define your chart/visualization.</li>
</ol>
<p>But it's really hard to understand what part you can't figure out - do you have problem getting the results? Defin... |
Format of a monetary number <p>I created a small currency converter. By cons I do not know how to give it a format with thousand separator. for example, the result is 10 000 000. 10 I would like to thank you if you can advise me. Below is my code</p>
<pre><code>class ChangeViewController: UIViewController {
@IBOutlet... | <p>Hello swift already has a currency UI style, for your case</p>
<p><strong>SWIFT 3</strong></p>
<pre><code> let amount = Int(usdamount.text!)
let numberFormatter = NumberFormatter()
numberFormatter.currencyCode = "USD"
numberFormatter.numberStyle = NumberFormatter.Style.currency
let newValue = numberFormatt... |
Explicitly set the storage path of an image clicked using Cordova API <p>I am extremely new to Cordova and am working on the Android platform. I need to store an image in a custom location.
The <code>navigator.camera.getPicture</code> method stores the clicked image in the cache, but I need to store that image in a cu... | <p>Camera plugin store data in Android/Data/my.package.com/ directory.This directory is always accessible from your app even if you didn't grant read/write permission in manifest file of Android.It is always safe to do this while developing a API.
If you still you want to change and store file at custom location then c... |
Fos Elastica remove common words(or, and etc..) from search query <p>Hello I`m trying to get query results using FosElasticaBundle with this query, I
can't find a working example for filtering common words like (and, or) if it is possible this words not to be highlighted also would be really good. My struggle so far :<... | <p>Do you want (and, or) to be ignored or not to have a value on your search?
If that's the case you may want to use stop words on your elasticsearch index.
Here's a reference.
<a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/using-stopwords.html" rel="nofollow">https://www.elastic.co/guide/en/elast... |
VBA Code - Skip some parts if some others are excecuted <p>I have written this piece of code but have gutted out the additional filler in between. Depending on time points selected, it will hide the appropriate rows.</p>
<p>Container 1 will always be filled, however, if another container is not selected, I want it to ... | <p>You need a routine to reactivate the screen and events, </p>
<pre><code>Sub Restart_Screen()
With Application
.EnableEvents = True
.ScreenUpdating = True
.StatusBar = vbNullString
End With
End Sub
</code></pre>
<p>Using <code>Exit Sub</code>, it could look like this :</p>
<pre><code>Sub test_vividillu... |
Retrieving data from file and storing in variable c# <p>I want to create a file in which I can write certain text and then store it in variables because I must change the text depending on the PC they are on.My question is what type of file should I write my text in? (.txt , .xml , .xls , .etc) I know you can do on any... | <p>Use XML, there is lots of support and documentation on how to do this online. Another arguably 'cleaner' result would be JSON. This uses a simple key value pair relationship which is similar to the example you posted. But both are good.</p>
<p>XML Example:</p>
<pre><code><?xml version="1.0"?>
<catalog>... |
Javascript - Create new Date using a UK format and moment.js <p>I have a date in UK format "DD/MM/YYYY HH:mm" and I want to create a new date with javascript. I'm trying the following using moment.js but it doesn't recognise the timepart and simply adds on the current time.</p>
<pre><code> var myDate = "11/10/2016 09:... | <p>Figured it out myself by doing the following:</p>
<pre><code>var myDate = "11/10/2016 09:00"
myDate = moment(myDate, "DD/MM/YYYY HH:mm").toISOString();
var newDate = moment(myDate).toDate();
</code></pre>
|
Database Selection Via ComboBox <p>I have a <code>combobox</code> that I would like to use to select the database from a selection available to the user. I have found plenty of information on populating the fields with table values but nothing on making a selection on which <code>.dbo</code> they can use. I'm guessing ... | <p>You need this query;</p>
<pre><code>string Sql = "SELECT * FROM sys.databases";
</code></pre>
|
Constraints getting changed when adding a view over window or navigation controller? <p>I had an application in which I need to display a custom status bar over all the application. For which I wrote this code in to the <code>didFinishLaunchingWithOptions:</code> method</p>
<pre><code>self.window.windowLevel = UIWindo... | <p>i think your problem is the view's width, make sure the width is right.</p>
<p>if the width is right and the problem is still here, please update your code and screenshot.</p>
|
Button of a Fragment inside ViewPager trigger onClickListener on wrong reference <p>Sorry about my dumb title, I will describe it clearly below:</p>
<p><strong>Situation</strong></p>
<p>I have a <code>ViewPager</code> with 4 <code>OnBoardingFragment</code>s inside. Each <code>Fragment</code> have exactly same layout ... | <p>Please refer the sample in the below link for using view pager with multiple fragments: <a href="https://guides.codepath.com/android/ViewPager-with-FragmentPagerAdapter" rel="nofollow">https://guides.codepath.com/android/ViewPager-with-FragmentPagerAdapter</a></p>
|
Private or Public Image Setting for Autoscale in SL <p>I am trying to set Operating System for autoscale.</p>
<p>In case of Operating System, I have set the code with API below.</p>
<pre><code> /**
* Operating System
*/
String operatingSystem = "WIN_2012-STD-R2_64";
virtualGuestMember... | <p>keep in mind that the configuration of the VM in autoscale group is almost the same like the configuiration when you create a new VM using the SoftLayer_Virtual_Guest::createObject so to set the image template you need to do it like this:</p>
<pre><code>{
"blockDeviceTemplateGroup": {
"globalIdentifie... |
How to escape dollar sign ($) in emmet? <p>As emmet use dollar sign ($) for numbering like:</p>
<pre><code>p#p${$}*3 //outputs <p id="p1">1</p><p id="p2">2</p><p id="p3">3</p>
</code></pre>
<p>it has its significant usefulness.</p>
<p>But, in case of currency, I am having strange... | <p>Could you try and use <code>&#36;</code>? This should escape it properly.</p>
<p>Source: <a href="http://www.fileformat.info/info/unicode/char/0024/index.htm" rel="nofollow">http://www.fileformat.info/info/unicode/char/0024/index.htm</a></p>
|
How to disable page element on certain articles in Joomla <p>I want to make a 100% clean bootstrap template for Joomla 1.5 (i know i know but it runs as intranet application so it's safe - i dont want to mess with this ;) ) and wonder how to disable template element (ex. div) on certain article pages (not associated to... | <p>First you need to get the article id from the request. I'm not sure if in Joomla 1.5 this is the correct way (on latest Joomla releases, JRequest is deprecated), but anyway, you'll need to use the JRequest class.</p>
<p><code>$id = JRequest::getInt('id');</code></p>
<p>Then use this id:</p>
<pre><code>if (($id !=... |
Prepopulate Dropdown with Object <p>I am trying to create a dropdown and want to prepopulate it with object.</p>
<pre><code><script>
angular.module("myapp", [])
.controller("MyController", function($scope) {
$scope.country = {
id: "2",
name: "USA"
};
$scope.countries = [{
... | <p>Remove <code>country as</code> and add <code>track by country.id</code> in <code>ng-options</code>.</p>
<pre><code><select ng-model="country" ng-options="country.name for country in countries track by country.id"></select>
</code></pre>
<p><a href="https://jsfiddle.net/DieuNQ/3gtvpa77/1/" rel="nofollow... |
How to fix Error ITMS-90513 caused by missing TVTopShelfImage.TVTopShelfPrimaryImageWide in your app's Info.plist <p>Detailed error description:</p>
<blockquote>
<p>ERROR ITMS-90513: "Missing Info.plist Key. Your app's Info.plist in
'Payload/xxx.app' must contain the
'TVTopShelfImage.TVTopShelfPrimaryImageWide' ... | <p>Starting with tvOS 10 you also have to provide wide version of TopShelfImage.</p>
<p>Find it in asset catalog right next to your icon and the old TopShelfImage.</p>
<p>Project settings / General / App Icons and Launch images / App Icons source / click the little right arrow on the right.</p>
|
PostgreSQL timeseries query with outer join <p>In PostgreSQL 9.5 database there is a table <em>metrics_raw</em> containing various metrics (<em>types: varchar</em>).<br>
Types are (for example): <em>TRA</em>, <em>RTC</em>.<br>
I'm executing following SQL to get year-to-date monthly aggregations:</p>
<pre><code>SELECT
... | <p>Thank @Nemeros, I fixed query to be:</p>
<pre><code>SELECT
"ticks"."ts" AS "timestamp"
FROM
generate_series('2016-01-01'::timestamp, '2016-10-10'::timestamp, '1 month'::interval) AS ticks(ts)
LEFT OUTER JOIN
(
SELECT *
FROM "metrics_raw"
WHERE "metrics_raw"."type" = 'TRA'
) as "metrics"
ON
"ti... |
How to pass a list of lists through a for loop in Python? <p>I have a list of lists :</p>
<pre><code>sample = [['TTTT', 'CCCZ'], ['ATTA', 'CZZC']]
count = [[4,3],[4,2]]
correctionfactor = [[1.33, 1.5],[1.33,2]]
</code></pre>
<p>I calculate frequency of each character (pi), square it and then sum (and then I calculat... | <p>I'm not completely clear on how you want to handle the 'Z' items in your data, but this code replicates the output for the sample data in <a href="https://eval.in/658468" rel="nofollow">https://eval.in/658468</a></p>
<pre><code>from __future__ import division
bases = set('ACGT')
#sample = [['TTTT', 'CCCZ'], ['ATTA... |
SQL INSERT INTO with Multiple SELECTS From Different Tables <p>I am attempting to Insert rows with data from 2 tables. The first table is my users AspNetUsers and the second table AspNetUserRoles. I want to give all users the same role. I have tried the following:</p>
<pre><code> INSERT INTO [MyDB].[dbo].[AspNetUserR... | <p>This should work:</p>
<pre><code>INSERT INTO [MyDB].[dbo].[AspNetUserRoles]
([UserId], [RoleId])
SELECT
Id,
(SELECT Id FROM [MyDB].[dbo].[AspNetRoles] WHERE Name = 'Intermediary') AS RoleId
FROM
[MyDB].[dbo].AspNetUsers
</code></pre>
<p>as long as <code>WHERE Name = 'Intermediary'</code> return 1... |
How to call a wizard from other wizard in Odoo8? <p>I have a wizard in which there is a one2many field. I made a button in each line of the one2many which calls another wizard made by me. This wizard is for modifying some values of the selected line.</p>
<p>My purpose is to return the first wizard, with the new change... | <p>First you need to browse current record of Wizard and it's line. Afterward write value as you want. </p>
<p>Return that current id with wizard object.</p>
<p>Try with following trick:</p>
<pre><code>#apply button method logic
def apply_data(self, cr, uid, ids, context=None):
if not context:
context = ... |
Binding a context to an objects this <pre><code>var test = function() {
console.log(this.x);
};
test.bind({x:777});
console.log(test()); // <--- I'm expecting the console to echo '777'
</code></pre>
<p>I have seem to have missed something here in understanding binding.</p>
| <p>Doh! Missed the equals.</p>
<pre><code>var test = function() {
console.log(this.x);
};
test = test.bind({x:777});
console.log(test());
</code></pre>
|
Why do I get different errors when I use a non-existing alias in realurl? 404 with postvarsets, 500 with fixedpostvars <p>I have two different configurations for two different extensions.
With news I use postvarsets:</p>
<pre><code>'postVarSets' =>
array (
'_DEFAULT' =>
array (
'news' =>
array (
... | <p>i am not sure but i think this is useful for you. add 'enable404forInvalidAlias' => 1, for getting 404 error. in fixedPostVars realURL configuration.</p>
|
One mail, multiple content depending the mail address <p>I don't know if it is possible or if it has already been asked.
But here's my problem.
I would like to send a mail to multiple address, and display in the mail, the mail address and some account information according the email address (not only the name).</p>
<p... | <p>You will have to send separate emails to send different content.</p>
<p>If you want to make your life easier, though, you ought to use a template with PHPMailer and provide the necessary data. There are plenty of <a href="http://stackoverflow.com/questions/38158181/send-html-emails-using-phpmailer-and-html-template... |
UserName - Password check function returning "false" <p>I'm having some trouble managing my login for a website. I've tried several different methods and queries which all seem to lead to the same problem: the method I use to check <code>username</code> and <code>password</code> always returns <code>false</code>.</p>
... | <p>I have changed a couple of things on here for you to try</p>
<p>I hope you are using a good hash for passwords <strong>NOT MD5</strong> use <a href="http://php.net/manual/en/function.password-hash.php" rel="nofollow">http://php.net/manual/en/function.password-hash.php</a> and <a href="http://php.net/manual/en/funct... |
indexeddb objectstore.add() keypath = 'id' <p>i have a few object stores, and split things up between them. and during initial install of chrome extension, i am adding data to the various object stores, and i am wanting to make sure the data aligns up correctly. so when things go out of sync during install. the "keypat... | <p>You're using two features together - in-line keys and key generators. I'll explain them both separately then how they compose.</p>
<p><strong>In-Line and Out-of-Line Keys</strong></p>
<p><em>In-line keys</em> have the key value appear in the record itself - a store with a keyPath uses in-line keys. By contrast, <e... |
Display route title inside root component <p>I have a root component and want to display route title inside special section in it.<br>I can detect which route is active in every component.<br>However, I don`t know how to do it inside root component. </p>
<p>This code shows title fine in ChildComponent1 :</p>
<pre><co... | <p>You could inject <code>Router</code> in your root component and then subscribe its <strong>events</strong>.
Example:</p>
<pre><code>constructor(private router : Router) {
this.router.events.subscribe((event) => {
if(event instanceof NavigationStart) {
console.log(event);
conso... |
Using the same thread for other database operations after it has finished processing <p>I am writing an hibernate application which involves batch processing on the records stored.</p>
<p>Assume there are 30000 records stored in database table and i am using 30 threads. Each thread processes 1000 records in parallel ... | <p>You could use a shared blocking queue, which is filled with the records you need to process (which means that you select those 30000 records somewhere outside of your <code>ExecutorService</code> threads).</p>
<p>Then, in your <code>Thread</code> code each thread gets top 1000 (<a href="https://docs.oracle.com/java... |
I'm trying to bind an address in the PowerShell script <p>I'm trying to bind an address in the PowerShell script so my testers can run wiremocks and it automatically points to the correct environment when they run it.</p>
<pre><code>echo "Running WireMock"
$WiremockFileName = "wiremock-standalone-2.1.12.jar"
$Port = ... | <p>beside the address binding...in line 20 I'm pretty sure it should be</p>
<p><code>$JAVA = $JavaExe.Definition</code></p>
<p>instead of </p>
<p><code>$JAVA = JavaExe.Definition</code></p>
|
Chef git sync using knife role create and new workstation setup <p>I have a simple question about keeping my chef-repo in sync with what's on the server.</p>
<p>Here is the steps I took to create a new role:</p>
<pre><code>cd /chef-repo/roles
knife role create windows_base
</code></pre>
<p>Then when I do:</p>
<pre>... | <p>The <code>knife * create</code> commands are issuing the create directly against the API. We don't offer generator commands (which live under <code>chef generate</code>) for roles, you'll just have to create the file yourself. In general you probably don't want to use the <code>create</code> commands, instead make t... |
I can't select Microsoft Git Provider <p>I was confused, when I click and select Microsoft Git Provider, the select option does not accept my selection, but if I select other option it's fine, I need to select Microsoft Git Provider to fix my error in team explorer. I tried to clear cache and restart but still the prob... | <p>Finally I fixed, just update Visual Studio. under tools/Extension and Updates/ visual studio update.</p>
|
How I add bracket in string variable in TCL file <p>I have written one TCL script but I have one problem when making a string variable as below:</p>
<pre><code>set a 100
set b "this is variable[$a]"
</code></pre>
<p>I want b to be assign with b = "<code>this is variable[100]</code>" but I got the error: </p>
<pre>
i... | <p>You just need to escape it:</p>
<pre><code>set a 100
set b "this is variable\[$a\]"
</code></pre>
|
Select Case to handle active TabPage <p>A program with a Form and a TabControl. I need to handle what happens when the user close the form according to the active TabControlPage</p>
<p>Is working with If - Then like this</p>
<pre><code>If PanelChooserTabControl.SelectedTab Is SelectionTabPage Then
'What I want
En... | <p>You can try something like:</p>
<pre><code>Select Case True
Case PanelChooserTabControl.SelectedTab Is SelectionTabPage
Case PanelChooserTabControl.SelectedTab Is EditionTabPage
...
End Select
</code></pre>
<p>or on tabPage index change save as an enum the page and use this enum in the case.</p>
|
Save User Settings ( switch Toggles ) Xamarin forms <p><a href="http://i.stack.imgur.com/UXt5m.png" rel="nofollow">page screenshot</a></p>
<p>Lets say we have a page in PCL xamarin forms application
I want to save the settings ( toggle switch choices ) for each users :
- save them locally and remotly</p>
| <p>Probably the fastest way to implement this is by using James Montemagno's <a href="https://github.com/jamesmontemagno/SettingsPlugin" rel="nofollow">Settings Plugin</a>. It's available as a NuGet package, just remember to install it in all of your projects both shared and platform.</p>
<p>It should be pretty self-e... |
Spring tool suite vs intellij running a spring boot project <p>I was using eclipse - sts , to launch my spring boot projects with option "run as -> spring boot app" and it is working fine , now I decided to switch into intellij IDE, but I'm not able to run my projects anymore, when I try to run my class with Springboot... | <p>You need to create the Run Configuration. Run -> Edit Configurations and add new configuration. Choose Spring boot and specify the main class and it should do it.</p>
|
Why componentDidMount gets called multiple times in react.js & redux? <p>I read <code>componentDidMount</code> gets called only once for initial rendering but I'm seeing it's getting rendered multiple times.</p>
<p>It seems I created a recursive loop.</p>
<ul>
<li>componentDidMount dispatches action to fetch data</li... | <p>A component instance will only get mounted once and unmounted when it gets deleted. In your case it gets deleted and recreated.</p>
<p>The point of the <code>key</code> prop is to help React find the previous version of the same component. That way it can update a previous component with new props rather than creat... |
What is the Regression algo to Use for this case? <p>Having this Data :</p>
<pre><code>clientId zipCode codeHeatingType countingType consumptionProfile householdCount squareFootage
01 75015 ELEC P012 A400 6 25
02 75002 GAZ P011 ... | <p>You need a regression algorithm that predicts a continuous variable. You can find the list of regression algorithms implemented in <code>spark.ml</code> <a href="http://spark.apache.org/docs/latest/ml-classification-regression.html#regression" rel="nofollow">here</a> with exemples.</p>
<p>Categorical predictors can... |
Windows IOT printer support <p>I want to make usb printer work with Windows IOT (Raspberry PI), so I need a universal print driver compiled for ARM architecture. But I haven't found any out of box solutions for this. Tried to write it, but can't find a good tutorial.</p>
<p>Is there any out of box solutions? If no, ma... | <h1>Suggestions:</h1>
<h2>GDI</h2>
<ol>
<li>Turn on your raspberry pi, and browse to the c:\windows\system32 folder as shown in the picture below<br>
<a href="https://i.stack.imgur.com/bWeUu.png" rel="nofollow"><img src="https://i.stack.imgur.com/bWeUu.png" alt="enter image description here"></a></li>
<li>Copy the gd... |
Hibernate CRUD with lists <p>If I have entitys:</p>
<ol>
<li>Entity1 has list with Entity2;</li>
<li>Entity2 has list with Entity3;</li>
<li>Entity3 has list with Entity4;</li>
</ol>
<p>What is operations in my code I have to do when I add new Entity4 in DB?</p>
<ol>
<li>Just set parent for Entity4 and save Entity... | <p>It really depends on whether the list maintained by <code>Entity3</code> is set to cascade operations such as <code>PERSIST</code>, <code>MERGE</code>, and <code>DELETE</code>. </p>
<p>If the list is configured to cascade, then all you'd need to do is:</p>
<ul>
<li>Set the parent of <code>Entity4</code>.</li>
<li... |
How to build a sandbox environment <p>Hi SecurityManager Experts out there ;-)</p>
<p>I have written a small plugin framework that loads plugins with separate isolated classloaders. For a successfull undeploy of a plugin it is important to make sure that no reference to classes loaded by the plugin classloader are hel... | <p>I found out that I was totally misunderstanding the Java security concept. I want to build a sandbox for plugin code so that it is always running in a restricted environment where I can control the permissions it has. The application should always run alongside with full access granted. </p>
<p>Here is how to build... |
sync threads to read different resources at exactly the same time <p>I have two cameras and this is important to read the frames with OpenCV exactly at the same time, I thought something like <code>Lock</code> but I cannot figure out the way I can implement this, I need some trigger to push and enable the threads to re... | <p>Consider getting FPS from VideoCapture. Also, note the difference between VideoCapture.grab and VideoCapture.retrieve frame. This is used for camera synchronization.</p>
<p>First call VideoCapture#grab for both cameras and then retrieve the frames. See <a href="http://docs.opencv.org/trunk/d8/dfe/classcv_1_1VideoCa... |
What happened to VMDepot? <p>I know that bitnami has moved all his images to the Azure Marketplace, but there was others VM on vmdepot. Now there is no simple way to share virtual machines on Azure.</p>
| <p>As you mentioned, Microsoft Azure decide to removed their old VM Depot Marketplace and all the Bitnami Images have been moved to their new Marketplace: </p>
<p><a href="https://azure.microsoft.com/en-us/marketplace/" rel="nofollow">https://azure.microsoft.com/en-us/marketplace/</a>.</p>
<p>You can create your a vi... |
Error:(90, 58) error: cannot find symbol variable drawable <p>I am a begginer in Java for Android development. I am reading a book called "Android Application Development for Dummies". In chapter 5 of the book, the following code snippet is given which is not working.</p>
<p>Can someone please help me know what I'm do... | <p><strong>Do something like this</strong></p>
<pre><code>private void toggleUI() {
ImageView imageView = (ImageView) findViewById(R.id.phone_icon);
if (imageView != null) {
int imageResId = mPhoneIsSilent ? R.drawable.phone_silent : R.drawable.phone_on;
imageView.setImageResource(imageResId);... |
Transpose result of hibernate query into list of POJOs <p>I got a generics class that contains runQuery method that has following code setup:</p>
<pre><code>public Object runQuery(String query) {
Query retVal = getSession().createSQLQuery(query);
return retVal.list();
}
</code></pre>
<p>I am trying ... | <p>You can find tutorials on ORMs ( <a href="http://stackoverflow.com/questions/7067860/what-is-object-relational-mappingorm-in-relation-to-hibernate-and-jdbc">What is Object/relational mapping(ORM) in relation to Hibernate and JDBC?</a> ). </p>
<p>Basically, you add annotation to your Check class to tell hibernate wh... |
How do I get the second Item in an Iteration? <p><strong>I get the first item like this:</strong></p>
<pre><code>{foreach $sArticle.sBlockPrices as $blockPrice}
{if $blockPrice@first}
First element
{else}
...
{/if}
{/foreach}
</code></pre>
<p>How do I get the second/third item?</p>
| <p>Use the index property of foreach referenced here: <a href="http://www.smarty.net/docsv2/en/language.function.foreach.tpl" rel="nofollow">http://www.smarty.net/docsv2/en/language.function.foreach.tpl</a></p>
<p>Try something like this: </p>
<pre><code>{foreach name=$sArticle.sBlockPrices item=$blockPrice name=bloc... |
shopt -s autocd missing when inside tmux? <p>It's very strange. I have <code>shopt -s autocd</code> set within my <code>.bashrc</code> file and if I run <code>shopt -p</code> in my shell I can see that it's available (and set).</p>
<p>But the moment I start up a tmux shell and run <code>shopt -p</code> the autocd opti... | <p><code>tmux</code> creates a login shell by default for each new window/pane. This means <code>.bash_profile</code> (or possibly <code>.profile</code> or <code>.bash_login</code>, depending on the available files) is executed, not <code>.bashrc</code>. See the man page for information on the <code>default-shell</code... |
SourceTree install behaving strangely <p>Hi we are in the process of transitioning to Git/SourceTree/Bitbucket and are a bit new to this. I installed Source Tree on a colleagues machine and few funny things happen which I don't remember happening on mine.</p>
<ol>
<li>SourceTree didn't have a version of Git installed ... | <p>I think this isn't really an issue, I reinstalled it and it started working. I've probably inadvertently done something without realizing it.</p>
|
SQL SUM() and ANGULAR.JS <p>I know how to connect, display, remove, add data from my database and display all of it on my website. Everthing works correctly. I see my results on my website and in my database. I do this with AngularJS, AJAX and PHP but my problem is I don't know how to dispaly MYSQL SUM() one of my col... | <p>change the <code>qryPop</code> in your code , to following code .</p>
<pre><code> $sql = "SELECT id,money , SUM(money) as sumMoney FROM `wcdrates` ORDER BY `id` DESC";
</code></pre>
<p>Hope you will get the answer</p>
|
Select left 4 characters without duplicates <p>I have a database table named <code>monthly</code>. One of the column names is <code>month</code>.</p>
<p>Inside <code>month</code>, there is these few datas - <code>201601, 201602, 201501, 201502</code>.</p>
<p>Now what I want to do is to get the first 4 characters from... | <pre><code>SELECT DISTINCT LEFT(month,4) AS `Year`
FROM monthly
</code></pre>
|
When to use static binding and when to use dynamic binding in Java? <p>Recently I am learning how to use Slf4j. And I know two new concepts:static binding and dynamic binding.In JCL(Jakarta Commons Logging) it use dynamic binding to choose the implementation while Slf4j is using static binding.
In this case we know Slf... | <p>Here : <a href="http://javarevisited.blogspot.com/2012/03/what-is-static-and-dynamic-binding-in.html" rel="nofollow">Link</a></p>
<p>Few important difference between static and dynamic binding</p>
<p>1) Static binding in Java occurs during Compile time while Dynamic binding occurs during Runtime.</p>
<p>2) privat... |
How to use different middlewares for different paths in GO? <p>Hi I am using <a href="https://github.com/justinas/alice" rel="nofollow">justinas/alice</a>, and I want to create different middlewares based on paths. i.e if I have path1 and path2, I want to apply m1,m2,m3 for path 1 and m1,m2 for path 2</p>
<p>I tried:<... | <p>You need to let set the handlers for <code>router</code> and <code>router</code> to the returned chain from <code>alice</code>.</p>
<pre><code>// define routers
router := mux.NewRouter() // assuming this is gorilla mux
router2 := mux.NewRouter()
// create alice chains
chain1 := alice.New(m1, m2, m3).Then(func1)
ch... |
App Crash on iPad after update to XCode 8 <p>I updated XCode like MacOS suggested to XCode 8. I run my App on Simulator and it worked fine. But when i tried to run the App on my iPad the App crashed unexpected. <br>
I was looking for the problem but couldn't find any place because it still runs on simulator. But then i... | <p>Your iPad allows permissions that may have
Been initiated, unlike iPhone. I am so done
With the pad I think I will burn it. Load new
iOS and run SOPHOS TRACE MODULE, my
Feeling is the auto access of many apps available
Is a bit more secure than the old iOS. Failure to connect by a few previous "wide open doo... |
Laravel Nested relationships using dot syntax querying each level <p>the goal here is to have my menu model create a tree with each related child and the child's related Page.</p>
<p>I'm generating a tree with my model like this...</p>
<pre><code> public static function tree()
{
return static::with(implode('.', a... | <p>UPDATE: it seems I've managed to fix this problem by doing this...</p>
<pre><code>public static function genRelationalArray()
{
$arr = [implode('.', array_fill(0, 100, 'children'))];
for($i = 0; $i < 10; $i++) {
$item = 'children.Pages';
$arr[] = $item;
$item = 'children.'. $item;
}
... |
create a multidimensional array in codeigniter controller <p>I'm having a controller to get users from DB and display every user in a table row</p>
<pre><code>Controller: [update] //only first page displays data correctly but pager +1 using
pagination displays user data only not getting orders as first page
when I pr... | <p>you can reduce the code a little but in controller like this:</p>
<pre><code>$this->data['users'] = $users; // correct data no problem here
$user_orders = array();
foreach ($users as $user){
$user_orders[$user->user_id] = $this->myMmodel>get_orders($user->user_id); //make user_id as key so that yo... |
Escape backslash in Python parameterized MySQL query <p>I am working on excel files and database storaging, precisely I am storaging excel data to MySQL database. At some point I am executing this query:</p>
<pre><code>query_for_id = ''' SELECT id FROM attivita WHERE attivita = '{0}' '''.format(attivita)
</code></pre>... | <p>I think that in your case better to use arguments to execute</p>
<pre><code>query_for_id = ''' SELECT id FROM attivita WHERE attivita = %(attivita)s '''
cursor.execute(query_for_id, { 'attivita': attivita })
</code></pre>
<p><a href="https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor-ex... |
R - string manipulation and extraction <p>I have a string <code>strEx <- "list(A, B, C, D)"</code> that I would like to store as a character vector:</p>
<pre><code>[1] "A" "B" "C" "D"
</code></pre>
<p>I'm not very good at regex (might be overkill as well, but I will need more of it in the future) which is probably... | <p>You could parse the expression like this:</p>
<pre><code>#parse the expression
pEx <- parse(text = strEx)[[1]]
</code></pre>
<p>Expressions are actually lists of symbols and can be treated as such. Here we turn everything except <code>list</code> into characters:</p>
<pre><code>vapply(pEx[-1], as.character, F... |
Create SOAP webservice(wsdl) client in c# <p>I have a soap based web service which has wsdl. and I have to create a windows form application client. can someone give me a small basic client? </p>
<p>Tips: that small web service has only a method named "</p>
<blockquote>
<p>CALL(id,name,address)</p>
</blockquote>
| <p>Having Drew's method in mind, </p>
<ol>
<li>Right click on the project and select "add a service reference' and click "Advanced.." in add service reference dialog box. Then click "Add web reference" in add service reference dialog box. Input your webservice address in the address bar and click go. then rename your ... |
Issue with transitioning between activities containing adapters sharing the same data set <p>Given 2 activities, A starts B for result.</p>
<p>Both activities have structures (A: RecyclerView, B: ViewPager) and adapters which connect to the same data set, stored in the Application object.</p>
<p>B finishes and posts ... | <p>Try to call notifyDataSetChanged() before calling getCount() in your adapter. </p>
<p>Something like this:</p>
<pre><code>@Override
public int getCount() {
notifyDataSetChanged();
return list.size();
}
</code></pre>
|
Get data from scope to another scope within one controller angularjs <p>I'm absolutely beginner in AngularJS. So, I'll be really appreciate for any help. I'm trying to build an app with charts in it using Ionic and Angular-nvD3 lineChart. I have data in json file. So, I've made factory and used getData(), $scope and s... | <pre><code> services.getData().then(function successCb(data) {
$scope.data = _.map(data.data);
});
$scope.selectedSin = function(prod) {
var sin = [];
angular.forEach(data, function (sin) {
sin.push({
x: data.Date,
y: data.low
});
return {
values: sin,... |
How do I customize the URL that Ember RESTAdapter calls? <p>In our Ember application, I have 3 different models:</p>
<ul>
<li>organizations</li>
<li>users</li>
<li>issues</li>
</ul>
<p>Issues are created by users who belong to an organization. Both <code>organizations</code> and <code>users</code> have an <code>issue... | <p>You need to customize your adapter (you can have an adapter per-model if you want, as far as I know).</p>
<p>In your specific example I think you want to customize the <a href="http://emberjs.com/api/data/classes/DS.JSONAPIAdapter.html#method_urlForFindAll" rel="nofollow"><code>urlForFindAll</code></a> method.</p>
... |
Unity Prime31 prompt for photo is crashing on iOS 10 and XCode 8 <p>Calling EtceteraBinding.promptForPhoto resulting in immediate crash on iOS 10.</p>
<pre><code>public void TakePhotoTapped() {
#if UNITY_IOS
EtceteraBinding.promptForPhoto(0.2f, PhotoPromptType.Camera, 0.8f, true);
#endif
}
</code></pre>
... | <p>This is related to new iOS 10 Privacy Settings requirement. You must declare ahead of time any access to private data or your App will crash.</p>
<p>You can add a usage key to your appâs Info.plist together with a purpose string or add a script that will do it for you in Unity for all your builds.</p>
<p>Xcode I... |
What's are the types of JOINS will support in Mysql?Is there any possible way to do this? <ul>
<li><p>How to do full joins in mysql.?and what are the types of joins will
support in mysql.
i'm beginner in mysql please help me solve this issue...</p>
<p>Thank you!</p></li>
</ul>
| <p>Before asking this question, I am assuming that you have not searched the net for anything at all, let alone MySQL documentation. Because I have asked stupid questions in the past (without researching enough), I am going to answer this one. By the way, this is a habit you must work upon. You should search for materi... |
Ordering Azure Active Directory Graph Results by Created Date <p>Does anyone know how to order the results of a query to the Azure AD Graph API using the nuget assembly (<a href="https://www.nuget.org/packages/Microsoft.Azure.ActiveDirectory.GraphClient/" rel="nofollow">https://www.nuget.org/packages/Microsoft.Azure.Ac... | <p>There is a restriction at the moment on the '$orderby' expressions that can be specified for a Graph API query. From the <a href="https://msdn.microsoft.com/library/azure/ad/graph/howto/azure-ad-graph-api-supported-queries-filters-and-paging-options" rel="nofollow">documentation</a> - </p>
<blockquote>
<p>The fol... |
Update ios Appstore app to allow only iPhone <p>I have my application in apple app store supporting, iPhone,iPad and iPod (Universal), Now I want to have my app compatible with only iPhone, How to achieve that.(In xcode device family I can check only iPhone and sumbit app sotre, will this make my app only supporting ip... | <p><strong>It is not possible</strong> with the original Bundle ID.</p>
<p>Citing from the doc below:</p>
<p><a href="https://developer.apple.com/library/content/qa/qa1623/_index.html" rel="nofollow">https://developer.apple.com/library/content/qa/qa1623/_index.html</a></p>
<blockquote>
<p>Bundles must continue to ... |
How to access the value of a ctypes.LP_c_char pointer? <p>I have defined a struct : </p>
<pre><code>class FILE_HANDLE(Structure):
_fields_ = [
("handle_bytes", c_uint),
("handle_type", c_int),
("f_handle", POINTER(c_char))
]
</code></pre>
<p>The struct is initialised :</p>
<pre><code>buf = create_string_... | <p>fh.f_handle is shown as LP_c_char because you defined the struct that way.</p>
<pre><code>buf = create_string_buffer(8)
print type(buf)
fh = FILE_HANDLE(c_uint(8), c_int(0), buf)
print type(fh.f_handle)
</code></pre>
<p>Will output</p>
<pre><code><class 'ctypes.c_char_Array_8'>
<class 'ctypes.LP_c_char'&... |
Maven enterprise application run with -1.0 in the end <p>Sometimes when i run my <strong>maven web application</strong>, the application run with <strong>-1.0</strong> in the end, and this make a problem, is there any explanation of this problem, and how we can solve it.</p>
<p>Normal url : <a href="http://localhost:8... | <p>Assuming the <code>1.0</code> is the project version in your <code>pom.xml</code> file, if you don't have the <code>build</code> element in your <code>pom.xml</code> add the following as a child of <code>project</code> element:</p>
<pre><code><build>
<finalName>projectmvn-web</finalName>
</b... |
Wordpress child theme style.css not working <p>I have created a file structure in the same format as my parent theme. My parent theme is called Alpine and within Alpine there is a functions.php and style.css file. There do not appear to be any additional style.css files.</p>
<p>I have created a directory called Alpine... | <p>Take a look at your <code><head></code> tag. More importantly look at the order of your stylesheets.</p>
<p>The styles from your child theme are being added first and then all the styles from your parent theme. This will cause the styles from the parent theme to override your child theme styles.</p>
<p>You c... |
Mod Rewrite: Leading slash followed by parameter after domain name <p>I'm trying to create a rewrite rule that changes a URLwith parameters into just a forward slash followed by a parameter.</p>
<p>The RewriteRule:
<code>RewriteRule ^(.*)$ send.php?url=$1&name=&submit=submit [NC,L]</code></p>
<p>The above rul... | <p>Try with:</p>
<pre><code>RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ send.php?url=$1&name=&submit=submit [NC,L]
</code></pre>
<p>This way you avoid to rewrite existing files and directories.</p>
<p>With <code>-f</code> you test for files, and with <code>-d</c... |
React-Native Fresh Install Compile Error <p>I've created a few react-native projects, and since updating to Sierra OSX and Xcode 8, upon opening each project, I get the error:</p>
<p><code>Application AppName has not been registered. This is either to due to a require() error during initialisation or a failure to call... | <p>I was having this error last night! All I did was to remove the node_modules, install then again and run the app again, it worked. â Crysfel</p>
|
What is NavigationServices.FirstOrDefault() of Template10 navigation service? <p>I want to navigate between pages in Template10. From the documentation,
<a href="https://github.com/Windows-XAML/Template10/wiki/Services#navigationservice" rel="nofollow">https://github.com/Windows-XAML/Template10/wiki/Services#navigation... | <p><code>FirstOrDefault()</code> is an extension method provided by LINQ. You need to add the line:</p>
<pre><code>using System.Linq;
</code></pre>
<p>at the top of your file to get it.</p>
|
How to insert a attachment and update a custom field in a post type in Wordpress <p>I have a custom post type named ['notifications'] with a custom field named ['attachment'] for all posts in ['notifications'] .</p>
<ul>
<li>I want a user to upload a attachment into the library from the front end</li>
<li>If upload is... | <p>You have a return statement in your function, before <code>update_post_meta</code> query. Try following code:</p>
<pre><code>function upload_user_file($file = array()) {
require_once(ABSPATH. 'wp-admin/includes/admin.php');
$file_return = wp_handle_upload($file, array('test_form' => false));
if (... |
Update nested structure of maps and vectors <p>I have a map with a vector of map like this:</p>
<pre><code>{:tags ["type:something" "gw:somethingelse"],
:sources [{:tags ["s:my:tags"],
:metrics [{:tags ["a tag"]}
{:tags ["a noether tag" "aegn"]}
{:ta... | <p>i would start bottom up, making transformation function for <code>:tags</code> entry, then for <code>:metrics</code> and then for <code>:sources</code>. </p>
<p>let's say our transform function produces ids just by counting tags (just for illustration, it could be easily changed later):</p>
<pre><code>(defn transf... |
2 separate controllers for the same end point in html and json or a single one? <p>I have the end points "/customers" and "/api/v1/customers", in html and json respectively for a list of customers. Do I have to create 2 different controllers and thus actions for them? Or can I return html or json from a single controll... | <p>You can have one controller and action for both endpoints, but I would advise against it.</p>
<p>You mentioned that those controllers need to do different stuff, so instead of adding stuff like "if json then check api key" make two separate controllers and extract common code of getting all the customers.</p>
<p>T... |
The two generate random numbers and their product is different <p>So im creating a program that generate 2 random numbers and need to multiply them:</p>
<pre><code>public static int thenumber(){
int number1=(int)(Math.random()*10+1);
return number1;
}
public static int thenumber2(){
int number2=(int)(Math.random()... | <p>A complete code example would be nice (see <a href="http://stackoverflow.com/help/mcve">How to create a Minimal, Complete, and Verifiable example</a>), but let me guess: You are first seeing the two random numbers (from printing them or some other way). Then you call your method. The method draws two <em>new</em> ra... |
Matlab - Scale down an image using an average of four pixels <p>I have just started learning image-processing and Matlab and I'm trying to scale down an image using an average of 4 pixels. That means that for every 4 original pixels I calculate the average and produce 1 output pixel.
So far I have the following code:<... | <p>In Matlab, an RGB image is treated as a 3D array. You can check it with:</p>
<pre><code>depth_size = size(img, 3)
depth_size =
3
</code></pre>
<p>The loop solution, as you have done, is explained in <a href="http://stackoverflow.com/a/39976574/6469393">Sardar_Usama's answer</a>. However, in Matlab it is rec... |
Cannot show cyrillic letters in PDF produced by apache fop <p>I have created PDF file from xsl file, but my cyrillic letters replaced by # symbol. What can I do? Please if you can give exact answers with exact examples. Thank you!!!</p>
<p>This is simple piece of my code that uses cyrillic letters:</p>
<pre><code> ... | <p>Just create .xml file</p>
<pre><code><?xml version="1.0"?>
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<directory>C:\Windows\Fonts</directory>
</fonts>
</renderer>
</renderers>
</fop>
</code></pre>
<p>An... |
How can I use Gradle to download dependencies and their source files and place them all in one directory? <p>I would like to use Gradle to download dependencies and their source files and place them all in one directory. I found this answer below that tells me how to do it for the dependencies themselves, but I would l... | <pre><code>apply plugin: 'java'
configurations {
runtimeSources
}
dependencies {
compile 'foo:bar:1.0'
runtime 'foo:baz:1.0'
configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { ResolvedArtifact ra ->
ModuleVersionIdentifier id = ra.moduleVersion.id
runtimeSources ... |
MySQL value of a parameter that reruns every entry <p>Is it possible to set value of a parameter such that in where clause it always results true?</p>
<p>As example consider a query:</p>
<pre><code>SELECT name FROM student WHERE class=@parameter;
</code></pre>
<p>Now my question is "is it possible to set a value of ... | <p>The typical method is:</p>
<pre><code>SELECT name
FROM student
WHERE (class = @parameter OR @parameter IS NULL);
</code></pre>
|
How to hide message window in MS SQL Server 2008? <p><a href="http://i.stack.imgur.com/pkCQo.png" rel="nofollow">enter image description here</a></p>
<p>Attached Picture</p>
| <p><kbd>CTRL</KBD> +<KBD>R</KBD></p>
<p>hides message window</p>
<p>you also can display results in seperate window like below</p>
<p>goto Tools | Option menu. On the option dialog, navigate into Query Results | SQL Server | Results to Grid or Results to Text
On the option dialog, check on [Display results in a sepa... |
Is there a way to add custom keyboard shortcuts to Vim for running numerous commands? <p>I'm having the following issue - whenever I finish writing some C++ code in Vim and want to compile and run it, I have to:</p>
<ol>
<li>Exit insert mode</li>
<li>Save the file using the command <code>:w</code></li>
<li>Write <code... | <p>You can use <code>map</code> to map keys to commands. <code>nmap</code> for normal mode, <code>imap</code> for insert mode etc</p>
<pre><code>map <key> command
</code></pre>
<p>the <code>cpp</code> compiling you mentioned should go like:</p>
<pre><code>autocmd FileType cpp nmap <buffer> <F5> :w&... |
block multiple request from same user id to a web method c# <p>I have a web method upload Transaction (ASMX web service) that take the XML file, validate the file and store the file content in SQL server database. we noticed that a certain users can submit the same file twice at the same time. so we can have the same c... | <p>Blocking on strings is bad. Blocking your webserver is bad. </p>
<p><code>AsyncLocker</code> is a handy class that I wrote to allow locking on any type that behaves nicely as a key in a dictionary. It also requires asynchronous awaiting before entering the critical section (as opposed to the normal blocking behavio... |
How do you email a query result as a csv using sp_send_dbmail stored procedure with SQL? <p>I would like to send an email containing the results of a query as a csv attachment.</p>
<p>So far I have this;</p>
<pre><code>EXEC msdb.dbo.sp_send_dbmail
@recipients='me@myself.com',
@subject='CSV Extract',
@pro... | <p>The problem is that Excel doesn't understand the columns. To fix this you need to send instructions to Excel explaining the csv file.</p>
<p>The instruction needs to be the first part of the file, before the data so you have to create an alias for the first field in the query that contains the Excel instructions al... |
ios - SocketMobile SocketScan Carrier Name <p>I implemented <code>socket scan API</code> in iOS to scan and get the bar code and that seems to be working fine. I wanted to know if there is a way to find out the carrier name via the <code>socket scan API</code> ?</p>
| <p>ScanAPI only provides the data that is encoded in the barcode and the barcode type. For example, the 12 digits of a UPC-A barcode - which are often printed below the barcode too.</p>
<p>However, different carriers use different barcode types or format the encoded data differently. For example, UPS uses Aztec barcod... |
Switch Derived class of a shared pointer to base class <p>I am currently trying to switch the type of a derived class stored in a shared pointer to base class.
The problem is that the Derived class inherit from the Base class and is also templated as follow:</p>
<p>Base class:</p>
<pre><code>#define PRINT(s) std::cou... | <p>You cannot change the runtime type of <code>sp_01</code> without re-assigning it because you cannot assign <code>Derived<e1></code> to <code>Derived<e0></code> (think of what would happen if these do not have the same size - you have allocated enough size for a <code>Derived<e0></code>, not for a <... |
How to integrate Typescript into Jenkins/SonarQube <p>Does anybody have experience integrating a project using typescript code in Jenkins and SonarQube? I would like to know if there are any plugins for the usual tasks, as I have been unable to find them. I am specifically interested in the following aspects:</p>
<ul>... | <p>No there is currently no support for Typescript projects in SonarQube. </p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.