input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Android Layout creating problems while switching from portrait to landscape with relative and linear layout <p>I tried to create UI for login page with logo two edit text and login button, things were very nice in phone portrait mode but when i checked it in landscape and Tablet then the problem started.</p>
<p>i got ... | <p>The problem here is you are using <code>@mipmap/ic_launcher</code> image with width/height <code>"wrap_content"</code>.<br>
So the <code>ImageView</code> size will base on <code>ic_launcher</code> image size<br>
And the <code>ic_launcher</code> image size is smaller in landspace than portrait<br>
=> Your <code>Image... |
PorterDuffXfermode canvas with several rects intersecting <p>I am trying to draw 3 rects on canvas.<br>
First one is green and is going on the back. Second is red and is over the green one. Third is going over both of them, and it should "cut through" first two rects. Something like this:</p>
<p><a href="http://i.stac... | <p>I had to do it by creating a bitmap and redrawing it.</p>
<pre><code>canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
canvas.drawColor(colorBottom);
timeBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
timeCanvas = new Canvas(timeBitmap);
timeCanvas.drawArc(oval, 270, secRot, true, s... |
Git does not ask me for gpg passphrase and fails my commit <p>When I do <code>git commit -a -S -m "Commit Message"</code>, I get this error:</p>
<pre><code>You need a passphrase to unlock the secret key for
user: "Username (Gpg Key) <email-id>"
2048-bit RSA key, ID 2487BE7C, created 2016-10-03
error: gpg failed... | <p>If you are using OSX. It seems like a gpg update (of brew) changed to location of gpg to gpg1, you can change the binary where git looks up the gpg:</p>
<pre><code>git config --global gpg.program gpg1
</code></pre>
<p><em>See <a href="https://medium.com/jubianchi-fr/mac-osx-and-gpg2-d5f719fc596#.a9xhteo18" rel="no... |
Excel VBA Adding Adding Entry to next row <p>im kinda new with excel vba, i need some corrections with this one because im getting an error, in short i cant add any data into my next row in excel using userform</p>
<p>This is my code</p>
<pre><code>Private Sub CommandButton1_Click()
Dim ssheet As Worksheet
Set sshe... | <p>Please try this one: </p>
<pre><code> Private Sub CommandButton1_Click()
Dim ssheet As Worksheet
Set ssheet = ThisWorkbook.Sheets("Sheet1")
nr = ssheet.Range("A1048576").End(xlUp).Row + 1
ssheet.Cells(nr, 1) = 1
ssheet.Cells(nr, 2) = 2
ssheet.Cells(nr, 3) = 3
End Sub
</code></pre>
|
How to select an element from a ComboBox menu using Vaadin Testbench? <p>I am doing some integration tests with vaadin version 7.6.4 and Testbench (4.0.3).</p>
<p>I have a view with several comboboxes. One of them has this property <code>comboBox.setTextInputAllowed(false);</code> For testing purposes, I want to chang... | <p>Indeed, your scenario does not seem to work as expected, at least with Vaadin 7.7.3 & TB 4.1.0.alpha1 I had.
Looking at the <a href="https://github.com/vaadin/testbench/blob/master/vaadin-testbench-api/src/main/java/com/vaadin/testbench/elements/ComboBoxElement.java#L43" rel="nofollow">sources</a> (line 43 atm),... |
Which version of gcc is installed on Mac (Yosemite) <p>I am confused by what version of gcc is installed on my Mac, which is has OS X Yosemite (10.10.5) installed on it. I also have Xcode v6.3.1 installed.</p>
<p>Entering the commands below reveals the following info: </p>
<pre><code>gcc -v
Configured with: --prefix=... | <p>In newer versions of XCode gcc and clang are linked to the same binary in the SDK. clang will say that it's at least gcc 4.2, this is a little weird, but works for lots of software that checks for gcc and it is compatible in general.</p>
<pre><code>echristo@dzur ~> /usr/bin/clang -v
Apple LLVM version 7.3.0 (cla... |
Has Facebook Graph Search been recently entirely removed? <p>FB graph search used to work via direct links until today.</p>
<p>See example link:
<a href="https://www.facebook.com/search/str/anything/stories-keyword/intersect/stories-live" rel="nofollow">https://www.facebook.com/search/str/anything/stories-keyword/inte... | <p>I found the reason.</p>
<p>It's like a ban at facebook. When using another account and different IP everything works again. </p>
|
PHP - How can I round off the date <p>I am calculating the difference of two dates like this:</p>
<pre><code>$date1= $_POST['dob'];
$date2= $_POST['dor'];
$date1 = date_create($date1);
$date2 = date_create($date2);
$diff = $date1->diff($date2);
echo "<p> The difference is " . $diff->format('%y Years, %m... | <p>Just check if there is a month or a day and if it is just add one year:</p>
<pre><code>//.....
$diff = $date1->diff($date2);
$year = (int) $diff->format('%y');
if (((int)$diff->format('%m')) || ((int)$diff->format('%d'))) {
$year++;
}
echo "<p> The difference is " . $year . " years </p>";... |
Storing BMP in icon file <p>I have a program to combine graphics files in an icon. Sizes include 16,24,32,48,256 32bit. These use PNG and works. I have correct header and directory/index record list.</p>
<p>However, for 8 bit I am using BMP with the first 14 bytes of the header of a BMP stripped off. This part of ... | <p>Yes, you are right:</p>
<blockquote>
<p>Images with less than 32 bits of color depth follow a particular
format: the image is encoded as a single image consisting of a color
mask (the "XOR mask") together with an opacity mask (the "AND mask")[..]</p>
</blockquote>
<p>What results in:</p>
<blockquote>
<p>[... |
How to only display top 2 rows? <p>I have spent the last 2 hours searching for this, and every thing I have tried has not worked. I have a table_Sessions for which I want to return a BranchID and Average cost of each session. But I only want to show the top 2 averages. </p>
<p>I have literally tried everything i have ... | <pre><code>SELECT (BRANCHID,AVGPRICE
FROM (SELECT BRANCHID, AVG(SESSIONPRICE) as AVGPRICE
FROM SESSIONS
GROUP BY BRANCHID
ORDER BY AVG(SESSIONPRICE) DESC)
WHERE rownum <= 2;
</code></pre>
|
Iterate over two lists, execute function and return values <p>I am trying to iterate over two lists of the same length, and for the pair of entries per index, execute a function. The function aims to cluster the entries
according to some requirement X on the value the function returns.</p>
<p>The lists in questions ar... | <p>This is finding connected components of a graph, which is very easy and well documented, once you revisit the problem from that view.</p>
<p>The data being in two lists is a distraction. I am going to consider the data to be zip(e_list, p_list). Consider this as a graph, which in this case has 5 nodes (but could ha... |
How to Create pagination in codeigniter <p>Hi I have implemented Pagination in PHP Code But it is not Working while clicking on the pagination links.It is displaying the same data for all the pages.Here is the code.</p>
<p>Controller:</p>
<pre><code>class Testimonial extends CI_Controller {
function __construct() {
... | <p>I cant comment so I just make this an answer, </p>
<p>Here
<a href="http://bootsnipp.com/snippets/featured/rounded-pagination" rel="nofollow">http://bootsnipp.com/snippets/featured/rounded-pagination</a></p>
<p>This is what I use in making my pagination! and there is alot more of it! I also use CI as my framework!... |
How to get id attribute of clicked tr button element? <p>I'm binding a click event to buttons created dynamically in a table of <a href="https://github.com/hakimel/Ladda" rel="nofollow">class</a> <code>.lada-button</code>. </p>
<p>In the current setup creating a reference to the button using a class selector <code>Lad... | <p>You can use jquery <em>closest</em> function.</p>
<p>You can see a simple example here </p>
<pre><code>$("button").click(function(event) {
alert($(this).closest("tr").attr("id"));
});
</code></pre>
<p><a href="https://jsfiddle.net/0pxswgt6/2/" rel="nofollow">https://jsfiddle.net/0pxswgt6/2/</a></p>
|
How to call from function to another function <p>I am making a minesweeper game within python with pygame.</p>
<pre><code>import pygame, math, sys
def bomb_check():
if check in BOMBS:
print("You hit a bomb!")
sys.exit
def handle_mouse(mousepos):
x, y = mousepos
x, y = math.ceil(x / 40), math.ceil... | <p>Just use it as an argument:</p>
<pre><code>import pygame, math, sys
def bomb_check(check):
if check in BOMBS:
print("You hit a bomb!")
sys.exit
def handle_mouse(mousepos):
x, y = mousepos
x, y = math.ceil(x / 40), math.ceil(y / 40)
check = x, y
print(check)
bomb_check(check)
</code... |
I get "Invalid" result even with valid input, anyone know why? <p>When the input is invalid (empty, . , etc, it crashes.Any ideas?</p>
<p>I've tried various ways to re-arrange the code but i couldn't make it work.
When valid input is introduced the app works fine</p>
<pre><code>public class fourth extends AppCompatAc... | <p>First of all. Your string comparison is wrong. You should use <a href="http://stackoverflow.com/questions/767372/java-string-equals-versus">String#equals</a></p>
<p>Thus:</p>
<pre><code>if (text.equals(",") || text.equals("") || text.equals("-") || text2.equals(",") || text2.equals("") || text2.equals("-"))
</code... |
Build image classification library using weka <p>I am new to Weka and have a Project in which I have to give an image a class after processing it. A class is like a type of image. Like if it's tiger image after processing the image I have to say it's tiger class in animals. After some research I found that I have to bu... | <p>In ImageJ (Java) there exists an image classification plugin based on WEKA:</p>
<p><a href="http://imagej.net/Trainable_Weka_Segmentation" rel="nofollow">http://imagej.net/Trainable_Weka_Segmentation</a></p>
<p>The Java source code can be found here and maybe of help:</p>
<p><a href="https://github.com/fiji/Train... |
Bootstrap-table: How I modify style and icons of the table-toolbar <p>I do not find to modify the style of the table toolbar. In the definition of the table is: data-toggle='table' when I delete these words the toolbar disappears.</p>
<p>I have found in the file bootstrap-table.js there are definitions to the standard... | <p>If you want to modify bootstrap styles you can just overwrite them with your custom CSS. Look for the classes of the toolbar and apply your changes to these class.</p>
<p>If you have a Button toolbar, e.g. with the following markup:</p>
<pre><code><div class="btn-toolbar" role="toolbar" aria-label="...">
&... |
Apache Conditional Proxy pass <p>I don't have much experience with servers. So, this might be a stupid question.Currently in my Apache server vim /etc/apache2/sites-enabled/000-default.conf file, I have a proxypass as below.</p>
<pre><code> ProxyPass /phpmyadmin !
ProxyPass / http://localhost:8080/
P... | <p>Since ProxyPass can't go inside a If statement you will need to use mod_rewrite to proxy/redirect and use a RewriteCond to filter the query string.</p>
<p>Since query string does not change as it was requested, here is a rough example:</p>
<pre><code>RewriteEngine on
RewriteCond %{QUERY_STRING} ^_escaped_fragment_... |
How to let a textfield hover/float above a mapView <p>I'm making an app which uses MapView, now I've positioned the textfield above the mapview, like on the image.<a href="http://i.stack.imgur.com/uQmHp.png" rel="nofollow"><img src="http://i.stack.imgur.com/uQmHp.png" alt="Image"></a> But I really want to fullscreen th... | <p>Right, presumably your map view is pinned on all four sides to its superview? Setup your constraints as follows, not how the mapview is not pinned to the text field, but the superview.</p>
<p><a href="http://imgur.com/a/8YmXL" rel="nofollow">http://imgur.com/a/8YmXL</a></p>
<p>To add the drop shadow, set the follo... |
Concerting Tweets to python dictionary <p>I want to analyse twitter data.I have downloaded some tweets and saved them in a .txt file.</p>
<p>When I tried to extract useful information from the tweets data , i was not able to make any progress because for a beginner like me it seems very difficult to extract tweets , l... | <p>It seems you can just read your file line by line and unpickle it using <a href="https://jsonpickle.github.io/api.html#jsonpickle.decode" rel="nofollow"><code>jsonpickle.decode</code></a> method:</p>
<pre><code>tweets = []
with open(filename) as f:
for line in f:
tweets.append(jsonpickle.decode(line))
<... |
set value from filepicker to dialog that called it <p>i have a action button that calls an dialog that i've made:</p>
<pre><code>class MainPanelManager(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.actionLocation.triggered.connect(self... | <p>A simple solution would be declaring the <code>dialog</code> variable a property of <code>self</code> object. So, you can then use it class-widely in all methods.</p>
<pre><code>class MainPanelManager(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self... |
All UTF8 glyphs in Swift 3 <p>How to print all <a href="http://www.utf8-chartable.de/" rel="nofollow">utf8 glyphs</a> using swift 3?</p>
<p>using this would be too slow/time consuming :</p>
<pre><code>let G = "\u{0047}" // "G"
</code></pre>
<p>is there a shorter/more elegant way of doing so?</p>
| <p>You can use the UnicodeScalar type to create the string using a numeric value. And iterate the value for the range you are interested in. According to the Swift String documentation Unicode scalars are defined for the ranges U+0000 to U+D7FF and U+E000 to U+10FFF. See: <a href="https://developer.apple.com/library/co... |
Adding <!DOCTYPE html> ruins alignment <p>I forgot to add <code><!DOCTYPE html></code> to some projects so I went back and added it. This ruined the alignment/height of a few elements but I was able to fix it by adding in <code>px</code> or <code>%</code> where it was missing. </p>
<p>However, in one of my proje... | <p>percentage is work according to the height of the parent container, so you should mention height to the <code>#buttons</code> ( buttons container div).</p>
<p>see below css - </p>
<pre><code>#buttons {
height: 75%;
}
#buttonrow {
height: 20%; /* you have 5 rows, so it will be 20% */
}
#buttons button {
... |
Run-time error '424' Excel Macro <p>I recorded a macro in excel to automatically move the selected field into the correct category (column, row, values etc), but it always throws up the 424 error when I try to run the macro.</p>
<pre><code>Sub Macro1()
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Post... | <p>Ah so I found a fix.</p>
<p>It was due to that when "Sum of Period" and "Sum of Unit" were moved to a different area their names changed to just "Period" and "Unit".</p>
<p>By adjusting the code and changing the .PivotFields to reflect this change it no longer presented the 424 run-time error.</p>
|
Link two attributes to one form element <p>I want to be able to have one select which specifies the value of two model attributes. Therefore if you were to select "yes" on a drop-down it would set the value of attribute a and attribute b to "yes" when the form is submitted. Although the below doesnt work it might help ... | <p>You can not do that.</p>
<p>What you can do instead, is upon validating the object set the <code>free</code> attribute equal to <code>trial</code> (that was set by selecting from a dropdown).</p>
|
issue passing URL from json config file to python script <p>I'm currently writing a small python script to monitor all Urls within my teams pool of web apps. I have a python script that basically runs in an infinite loop and will check the urls every 60 min. My issue lies in pulling my url's from my json config. for so... | <p>As it says in the exception: nonnumeric port. The HTTPConnection class interprets everything after the ':' as the port, in your case: '7778/apt/server/login/#'. This can only be numeric. If you change it to '7778', the exception shouldn't occur.</p>
<p>The available parameters can be found in the python docs:
<a hr... |
How do you use a click funciton that has a lot of classes in jquery? <pre><code><div class="card-block">something</div>
<div class="card-block">something</div>
<div class="card-block">something</div>
<div class="card-block">something</div>
<div class="card-block">so... | <pre><code>$('.card-block').on('click', function() { var div = $(this); });
</code></pre>
<p>You can use this keyword to get clicked div. In case your element is added dynamically, then use this code: </p>
<pre><code>$('body').on('click', '.card-block', function() { var div = $(this); });
</code></pre>
|
Show items based on category using filter <p>I am learning reactjs by developing an app. I was doing quite well with no problem. However i encountered a problem now when trying to list the menus/meals based on categories like veg and non-veg. I am using filter function of lodash and in console i see my filter function ... | <p>Use <code>_.filter()</code> to make the constants <code>veg</code> and <code>nonVeg</code> and then to return the html view make a <code>_.map()</code> to iterate and get the proper <code>li</code> elements:</p>
<pre><code>const Menu = ({restaurant}) => {
const veg = _.filter(restaurant.meal, (meal) => {
... |
SQL - Append Identity Column in Existing Temp table <p>I want to update my temp table records. But my existing Temp table does not have any unique column. So I need to append Identity column and update all the records based on that Identity column.</p>
<p>For example, If my temp table has 1000 records without any uniq... | <p>There is no need to do an <code>UPDATE</code>. The identity column is going to be populated when it is created. All you need is:</p>
<pre><code>ALTER TABLE #temp
ADD Id INT Identity(1, 1)
GO
</code></pre>
<p><code>Id</code> field will be populated and it will hold values <code>1, 2, ..., 1000</code>.</p>
|
Type conversion confusion in C <pre><code>#include <stdio.h>
int main()
{
char c = 255;
if (c > 128)
{
printf("This is unsigned number %d\n", c);
}
else
{
printf("This is signed number %d\n", c);
}
}
</code></pre>
<p>What happens in this case when we initialize an ... | <p>This isn't well-defined behavior. The relevant part of the standard 6.3.1.3 §3:</p>
<blockquote>
<p>Otherwise, the new type is signed and the value cannot be represented
in it; either the result is implementation-defined or an
implementation-defined signal is raised.</p>
</blockquote>
<p>This means that the... |
How to add multiple Auth Interceptor in Restangular? <p>App developed in : ionic + Restangular</p>
<p>I am having one global configuration in Restangular for BaseUrl and Auth Interceptor.[Like for <a href="http://app" rel="nofollow">http://app</a>.**.com]</p>
<p>Now, my requirement is to have different set of these.[... | <p>You could add as many interceptor as you want by using <strong>addRequestInterceptor</strong> and put your logic to each interceptor.</p>
<p>In your case you can have one or two interceptor which can check baseurl and change header...</p>
<pre><code> RestangularProvider.addFullRequestInterceptor(function(element,... |
Trying to pass arguments to java application <p>So I have a program with an updater and I've made a mistake before releasing it. I totally forgot about by-passing the update so the user can update it later.</p>
<p>Now I'm trying to fix it and I thought that creating an argument with "-no_patching" is the best solution... | <p>Here is the mistake at line <code>args.toString().matches("-no_patching")</code>. </p>
<p>That should be</p>
<pre><code>else if(args[0].equals("-no_patching")){ // make sure args length is 1
System.err.println("patching OFF");
launchApp();
}
</code></pre>
<p><code>toString()</code>... |
IOS Swift 3 Alamofire 4.0.0 <p>Here is my code facing error at <code>NSMutable</code> line:</p>
<pre><code>import UIKit
import Alamofire
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://jsonplaceholder.typicode.com/users")... | <p>Try to use below code for Alamofire 4.0</p>
<pre><code>Alamofire.request("http://jsonplaceholder.typicode.com/users").responseJSON { (response) in
switch response.result {
case .success(let value) :
print(response.request) // original URL request
print(response.response) /... |
How to translate Japanese Kanji to Katakana <p>The requirement is to:</p>
<blockquote>
<p>As the user type his/her Japanese Kanji first and last names,
automatically fill in the corresponding Japanese Katakana first and
last names.</p>
</blockquote>
<p>I have been searching for a while now, but I couldn't yet f... | <p>It seems like there are several JavaScript solutions online to convert from Kanji, Romaji, Hiragana and Katakana. Check these out and see if they work for you:</p>
<ul>
<li><a href="https://github.com/ysawa/jquery-auto-kana-input" rel="nofollow">JQuery Auto Kana Input</a></li>
<li><a href="https://www.npmjs.com/pac... |
Jquery Autocomplete widget implementation <p>I am trying to convert a normal field to autocomplete and making a ajax call to get the data in JSON and then set it to that autocomplete.</p>
<p>I do not know much on JQUERY, I spent around 5-6 hours just to know I have to initialize before using any function on the auto c... | <p>I finally figured out what was the problem in my code.I actually was not able to add option to my input autocomplete.To make it work I needed to update my html with</p>
<p><strong>HTML</strong>
just replace <code><input class="nameClass" type="text" id="nameText" /></code></p>
<p>And the jquery part needed u... |
Jest test fails : TypeError: window.matchMedia is not a function <p>This is my first front-end testing experience. In this project, I'm using jest snapshot testing and got an error <code>TypeError: window.matchMedia is not a function</code> inside my component. </p>
<p>I go through jest documentation, I found "Manual ... | <p>Jest uses <a href="https://github.com/tmpvar/jsdom" rel="nofollow">jsdom</a> to create a browser environment. JSDom doesn't however support <code>window.matchMedia</code> so you will have to create it yourself.</p>
<p>Jest's <a href="http://facebook.github.io/jest/docs/manual-mocks.html" rel="nofollow">manual mocks... |
Thread runs after statements below are executed <p>I am showing a countdown while Realm <strong>dataBase</strong> is loaded from the <strong>asset</strong> file</p>
<pre><code> SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);
boolean isFirstRun = wmbPreference.getBool... | <p>If you want to show a countdown, you must copy the file manually.</p>
<ul>
<li>How to copy file from assets to internal storage: <a href="http://stackoverflow.com/questions/19218775/android-copy-assets-to-internal-storage">Android - Copy assets to internal storage</a></li>
<li>How to update a progress or countdown:... |
Using named injection in Guice <p>I'm using Guice for dependency injection and I'm a bit confused. There are two <code>Named</code> annotations in different packages:</p>
<p><code>com.google.inject.name.Named</code> and <code>javax.inject.Named</code> (JSR 330?).</p>
<p>I'm eager to depend on <code>javax.inject.*</co... | <p>As mentioned on the Guice wiki, <a href="https://github.com/google/guice/wiki/JSR330" rel="nofollow">both work the same</a>. You shouldn't worry about that. It is even recommended to use <code>javax.inject.*</code> when available, just as you prefer too (bottom of the same page).</p>
<pre><code>import com.google.in... |
Uploading a url image to s3 aws <p>I'm trying to upload an image but i keep getting an error with the export of the secret and key <code>SyntaxError: Unexpected reserved word</code>. here is what i've tried</p>
<p>first i require the aws dependencies.</p>
<pre><code>var AWS = require('aws-sdk');
export AWS_ACCESS_KEY... | <p><code>export</code> is not a correct way to add an environmental variable in node.js.</p>
<p>You should either</p>
<pre><code>process.env.AWS_ACCESS_KEY_ID='key'
...
var AWS = require('aws-sdk');
</code></pre>
<p>or, most likely, pass them to your script as</p>
<pre><code>export AWS_ACCESS_KEY_ID='key'
node serv... |
Login using cookies is not working in ASP.net <p>I am trying to make a login system based on cookies (not to sing out when the page closes or refreshed) </p>
<p>this is the code behind the Login.aspx.cs:</p>
<pre><code> string cmdText = "SELECT Username,Role FROM Login WHERE Username = '" + TextBox1.Text + "' AND Pa... | <p>Im kind new to cookies too, but after googled for some hours, im using Cookies this way, and its working, hope it helps you<br>
To Add Cookies:</p>
<pre><code>string UserData = _User + "/" + _Password;
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1 , _User , DateTime.Now, DateTime.Now.AddMinutes... |
Cannot display SVG used by <object> in browser <p>I'm trying to set up the vector web application on my server <code>https://vector.cnjabber.net/</code> , but I've found that the SVG used by <code><object></code> (I think they're generated by javascripts.) cannot be displayed in browser. However, the official app... | <p>I think your problem may lie with <code>type="xvg+xml"</code> which should be <code>type="image/svg+xml"</code>
Also, it should be structured like this:</p>
<pre><code><object type="image/svg+xml" src="yourimage.svg">
<img src="yourfallbackimage.png" alt="Your browser does not support SVG"/>
</ob... |
Google Map marker offset <p>I am using google maps version 3. I want to show a square marker. Currently google shows it like the following image. i.e. the point is taken at the bottom of the marker. My marker is suppose 20px X 20px. Currently google shows it at the red point.</p>
<p><a href="http://i.stack.imgur.com/m... | <p>Per <a href="https://developers.google.com/maps/documentation/javascript/reference#Icon" rel="nofollow">the documentation</a>, this works:</p>
<pre><code>var icon = {
url: "http://i.stack.imgur.com/FhryS.png", // 20px x 20px icon
// size: new google.maps.Size(20, 20), // size of icon is 20px x 20px (so this ... |
Vagrant Laravel Scotchbox - An error by vagrant up <p>A Laravel project with Scotchbox, I will run my server by vagrant up.
When I run Vagrant up, I get the following error:</p>
<p><a href="http://i.stack.imgur.com/gKRmd.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/gKRmd.jpg" alt="enter image description her... | <p>I think I solved this long ago by rebooting the computer, entering the BIOS and enabling a virtualitzation option.</p>
<p>Depending en your hardware your BIOS panel looks diferent. But you should somewhere find an option named virtualization, once found, enable it and reboot.</p>
<p><a href="http://druss.co/2015/0... |
When is it bad to store a user setting or information in the main users table? <p>I am still expanding and developing my app. </p>
<p>i currently have a user table with 35 columns. I searched about my question but i am still kinda confused if i am doing it right or wrong. Some say User table other say do relationships... | <p>From my experience, you should separate a lot of those thata in conected tables (if your table is going to have a lot of records). </p>
<p>For example, you should have one more table for address information and one more for contacts information (email, phone, fax etc.) so you can keep history of user changes inside... |
Add gradient in edit text border in android <p>I want to add gradient only to the border of my editText , I can add gradient but it takes the entire background . How can I apply gradient only to the border , and the rest should be transparent?</p>
<p><a href="http://i.stack.imgur.com/3xURY.jpg" rel="nofollow"><img src... | <p>Create your <strong>button_border.xml</strong> and keep it within drawable.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- view border color and width -->
<stroke
android:width="1dp"
... |
Django/Python: How to get the latest value from a model queryset? <p>I have created a model 'VehicleDetails' in which a user can fill the details of a vehicle and another model 'TripStatus' in which he can update the vehicle location. I wanted to get the latest location for which I did as in my below code. But when i r... | <p>Should just have to remove the .all():</p>
<pre><code>tripstatus = TripStatus.objects.latest('statustime')
</code></pre>
<p>Or maybe:</p>
<pre><code>tripstatus = TripStatus.order_by('-statustime').first()
</code></pre>
|
Possibility to reference "traditional" (old) .net libraries from .net core applications <p>There are a bit confusing information about the backward referencing possibility from .net core applications (e.g. ASP.Net Core) to the commonly used .net framework libraries. I got the following impression now:</p>
<ol>
<li>If ... | <p>For the moment this is not possible. </p>
<p>You have 3 options: </p>
<ol>
<li>attempt to convert your old project into a portable class library (PCL), which can then be referenced by your .net core app.</li>
<li>wrap your project into a nuget package (you already mentioned that)</li>
<li>Add the project as a clas... |
Python 3 Pandas Filter/Extract by multiple column values, including <> 0 <p>Working with a publicly available csv file from USASPENDING.gov. Able to extract data from Navy but do not know the right syntax to add a second filter to exclude all records with <code>Dollarsobligated = 0</code>. </p>
<p>Code is:</p>
<pre... | <p>I think you need replace <code><></code> to <code>!=</code> in <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing" rel="nofollow"><code>boolean indexing</code></a>, because <a href="https://docs.python.org/3.0/whatsnew/3.0.html#removed-syntax" rel="nofollow">in Python3, <> w... |
OneSignal location filters+ GameSparks <p><a href="http://hastebin.com/nekofuvono.cs" rel="nofollow">http://hastebin.com/nekofuvono.cs</a></p>
<p><a href="https://documentation.onesignal.com/reference#create-notification" rel="nofollow">https://documentation.onesignal.com/reference#create-notification</a></p>
<p>99% ... | <p>The issue is that you are missing a comma after the value for filters. Here is a corrected version of your code:</p>
<pre><code>// ====================================================================================================
//
// Cloud Code for trignotif, write your code here to customise the GameSparks pla... |
ibswiftCore.dylib: Permission denied, failed to run on simulator/device <p>After installing xcode8 I get the following 'compiling swift standard libraries' error:</p>
<p>Copying /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftRemoteMirror.dylib to /Users/ka... | <p>found it :)
Not sure why I had 'Other code signing flags' set to "-D DEBUG".
Removing it solved the problem</p>
|
iOS Call animateWithDuration inside dispatch_async <p>I've call an web API to get the result. After getting response I want to remove "visualIndicatorView" (UIView) with indication using animation function. Indication and View come to hidden state but not smoothly. </p>
<p><strong>Here is my code:</strong> </p>
<pre>... | <p><code>hidden</code> is not an animatable property. Try setting <code>alpha</code> to <code>0</code>:</p>
<pre><code>self.visualIndicatorView.alpha = 0.0
self.activityIndicator.alpha = 0.0
</code></pre>
|
Mule dynamic property file reference <p>we have a flow where we have property file reference as given below</p>
<pre><code>"context:property-placeholder location="httpdemo.${country}.properties"
</code></pre>
<p>now we want <code>${country}</code> value to be replaced by actual value at the time of deployment.</p>
<... | <p>We had a similar situation where we needed to have multiple versions of the same application running parallely. The solution we used for this was to package the property file along with the build and not have the dynamic element (environment based) to it. For eg; in this case we construct httpdemo.usa.properties and... |
Load multiple JS files sequently after page load <p>To speed up the page loading time, I want to load the JS scripts after the page content has loaded.</p>
<p>I found this helpful article which explains how to do this when you have a single JS file: <a href="https://varvy.com/pagespeed/defer-loading-javascript.html" r... | <p>If the scripts have dependencies towards each other you need to make sure that the dependencies loads first. You can nest the script loading like so:</p>
<pre><code>var jqueryElement = document.createElement("script");
jqueryElement.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js";
var mai... |
CMake: How to load interface classes of the main application in another cmake target? <p>How do I load the INTERFACE_INCLUDE_DIRECTORIES of the main application, in a library (plugin) target? I know how to load the INTERFACE_INCLUDE_DIRECTORIES of a library, but I don't know how to load them without linking a library.<... | <p>The <code>target_include_directories()</code> command populates <code>INTERFACE_INCLUDE_DIRECTORIES</code> with values given to the <code>PUBLIC</code> and <code>INTERFACE</code> keywords.</p>
<p>Targets may populate this property to publish the include directories required to compile against the headers for the ta... |
Angular2 - Get hold of dynamically created element <p>I am experimenting with dynamic element creation using Angular2 and I have the following code using Renderer:</p>
<p>Component</p>
<pre><code>export class DesignerComponent {
@ViewChild('builder') builder:ElementRef;
renderer: Renderer;
constructor(private... | <p>Got it solved.</p>
<p>updated HTML for the RowCompnent:</p>
<pre><code><div #row class="row" id="{{rowId}}">
<div class="s12 teal lighten-2">
<p class="flow-text">adicionando linha no html builder</p>
</div>
<div id="colunas" *ngFor="let col of colList; let colIndex = ind... |
Transform a parent child structure to child parent <p>I am working on a project where I need to be able to transform a complex parent child structure to its child parent equivalent, this is necessary as the querying and reporting on the data needs to be possible from either the parent or child pov. This may not make mu... | <p><code>GroupBy</code> color will basically give you the desired format:</p>
<pre><code>var colourUsage =
from ut in usageTypes
from c in ut.Colours
group ut.Usage by c.Name into g
select new { colour = g.Key, usages = g.ToList() };
</code></pre>
|
setting label.text based on its location property in a groupbox <p>I'm using C# and windows forms, i have a group box with 20 labels in it (10 in the top row and 10 in the bottom row).</p>
<p>I want to set Text property of these labels based on their location coordinates in the group box. Y co-ordinate of all labels i... | <p>This sounds like a good candidate for a User Control to me.</p>
<p>Design a user control with the groupbox and labels.
Expose the operations you need externally. Possibly a good moment to set naming conventions to something more meaningful to you. </p>
<p>Another way could be to generate the labels from code inste... |
Visual Basic. Method cannot be reflected <p>I have a problem using soap client in vb.net with Visual Studio 2015 Community. I want to use to soap client library, but I can't find it.</p>
<p>So, I found the <code>wsdl.exe</code> command in Visual Studio 2015 Community. I tried wsdl.exe. It generated the code in the fol... | <p>If you inspect the innerexception you can see the actual error is related to the SoapHeader class generated by wsdl.exe. </p>
<pre><code>Types 'System.Web.Services.Protocols.SoapHeader' and 'FullNamespaceToYourClass.SoapHeader' both use the XML type name, 'SoapHeader', from namespace 'http://ss.yahooapis.jp/V6'. Us... |
How to decode a numpy array of dtype=numpy.string_? <p>I need to decode, with Python 3, a string that was encoded the following way:</p>
<pre><code>>>> s = numpy.asarray(numpy.string_("hello\nworld"))
>>> s
array(b'hello\nworld',
dtype='|S11')
</code></pre>
<p>I tried:</p>
<pre><code>>>... | <p>If my understanding is correct, you can do this with <code>astype</code> which, if <code>copy = False</code> will return the array with the contents in the corresponding type:</p>
<pre><code>>>> s = numpy.asarray(numpy.string_("hello\nworld"))
>>> r = s.astype(str, copy=False)
>>> r
arra... |
What are the reasons for getting a Socket read timed out Exception in Java? <p>What are the reasons for getting a Socket read timed out Exception in Java?</p>
<p>I'm gettting:</p>
<pre><code> ### Cause: java.sql.SQLRecoverableException: IO Error: Socket read timed out
; SQL []; IO Error: Socket read timed out; nes... | <p>A timeout was set by the library and yet it didn't read anything before the timeout was reached. </p>
<p>This could happen if the other end it is reading from stop for a long time. The library determines what counts as a long time. I would look for any errors logged on the server it is connected to.</p>
|
TVOS : detecting touches with press began and functions (Swift Spritekit) <p>im trying to define touches in TVOS with press began but its not working.</p>
<p>i want to connect 3 functions </p>
<ul>
<li>Start Game </li>
<li>Play Pause Music</li>
<li>Restart Game</li>
</ul>
<p><strong>Game scene TVOS:</strong></p>
<p... | <p>You code has some problems.</p>
<p>1) This code is wrong in the restartGame method.</p>
<pre><code> GameViewController().TitleGameOver.isHidden = true
GameViewController().RestartButton.isHidden = true
...
</code></pre>
<p>You are creating a new instance of GameViewController on every line, you are not refer... |
Edittext list editing <p>In my app there's a large EditText field that contains barcodes separated by "\n". Barcodes can be added to this EditText field either programmatically(in onActivityResult returning from a scanning Activity) or manually. </p>
<p>Random example:</p>
<pre><code>010566510415
40541651654556
56151... | <p>you can update the array list based of index, example :</p>
<pre><code>private ArrayList<BarcodeObject> barcodes = new ArrayList<Object>();
barcodes.set(#indexposition#, #BarcodeObject#);
</code></pre>
<p>and add getter and setter in your BarcodeObject class, for update the object;</p>
|
Insert record with all values as AutoIncrement or Default <p>I have a table with 2 columns.</p>
<ol>
<li>key - Primary key, Auto Increment</li>
<li>timestamp - DateTime, Default -> CURRENT_TIMESTAMP</li>
</ol>
<p>I am trying to insert a value into this table with the help of SqliteOpenHelper object. But it throws an ... | <p>To insert a row with default values, specify at least one column with null value:</p>
<pre><code>ContentValues cv = new ContentValues();
cv.putNull(KEY_LOG_TIME_TIME);
db.insert(TABLE_LOG_TIME, null, cv);
</code></pre>
|
MATLAB: Color of sphere distorts color scheme values <p>I have the following MWE, showing a surf-plot and a sphere,</p>
<pre><code>figure(1)
[xx yy] = meshgrid(0:0.1:pi, 0:0.1:pi);
surf(xx, yy, zeros(size(xx)), 0.001*sin(xx), 'EdgeColor', 'none')
hold on
[xS,yS,zS] = sphere(50);
surf(xS+1, yS+1, zS+1,'FaceColor', 'k'... | <p>Set up manually the limits of your colorbar with <code>caxis</code></p>
<p>your colors are <code>C=0.001*sin(xx)</code></p>
<p>then, after the plotting, add <code>caxis([min(C(:)) max(C(:))])</code> and you will have the limits are you wish</p>
<p><a href="http://i.stack.imgur.com/bRfZJ.png" rel="nofollow"><img s... |
WebView detect button click event <p>I am loading a web URL in webview. Like below :-</p>
<pre><code> mWebView = (WebView)findViewById(R.id.id__web_view);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient());
mWebView.loadUrl("http://www.google.com")... | <p>Checkout below code.. its working fine for me</p>
<pre><code>@SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends Activity {
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.... |
Permiting users expand the app <p>I want to create an app which can be expanded by <code>modules</code> (or something else) by the users, allowing them to download only parts they need to use.</p>
<p>I think it can be done with <code>.aar</code> files but I'm not sure. May be there are better solutions. I would be gra... | <p>The following links will help you to understand and then implement your own module/library for android. </p>
<p><a href="https://developer.android.com/studio/projects/android-library.html" rel="nofollow">Android's documentation</a></p>
<p><a href="http://www.vogella.com/tutorials/AndroidLibraryProjects/article.htm... |
Python pandas check if the last element of a list in a cell contains specific string <pre><code>my dataframe df:
index url
1 [{'url': 'http://bhandarkarscollegekdp.org/'}]
2 [{'url': 'http://cateringinyourhome.com/'}]
3 Na... | <p>I think you can first replace <code>NaN</code> to <code>empty url</code> and then use <code>apply</code>:</p>
<pre><code>df = pd.DataFrame({'url':[[{'url': 'http://bhandarkarscollegekdp.org/'}],
np.nan,
[{'url': 'http://cateringinyourhome.com/'}],
... |
Python time error: mktime overflow <p>While working with Python's <code>time</code> module I got this error:</p>
<blockquote>
<p><code>OverflowError: mktime argument out of range</code></p>
</blockquote>
<p>What I have found concerning this was that the time might be outside of the epoch and therefore can not be di... | <p>You problem is that the timetuple created by <code>time.strptime(s, "%d %H %M %S ")</code> is: </p>
<pre><code>(tm_year=1900, tm_mon=1, tm_mday=20, tm_hour=3, tm_min=59, tm_sec=3, tm_wday=5, tm_yday=20, tm_isdst=-1)
</code></pre>
<p>...and the documentation for <code>time.mktime()</code> states (emphasis mine):</p... |
Google Places with Observables in Angular2 <p>I try to use <a href="https://developers.google.com/maps/documentation/javascript/places" rel="nofollow">Google Places</a> with Observables in Angular 2.</p>
<p>To do that, I included the Google scripts in the <em>index.html</em> and then I get some inspiration with Observ... | <p>I found an awful solution. In <em>app/google-search.component.ts</em>, I've added the following function : </p>
<pre><code>recursiveTimeout(ms: number = 1000): void {
setTimeout(() => {
this.recursiveTimeout(ms);
}, ms);
}
</code></pre>
<p>Then in the <code>ngOnInit</code> function, I call <code>recursi... |
Save Position of dragged items with Dragula Drag and Drop, React Version (react-dragula) <p>I am using react-dragula (<a href="http://bevacqua.github.io/react-dragula" rel="nofollow">react-dragula</a>) to drag and drop elements. How should I save the items positions after drop.</p>
<pre><code> dragDecorator = () =>... | <pre><code> dragDecorator = (componentBackingInstance) => {
if (componentBackingInstance) {
let options = {};
const dragula = Dragula([componentBackingInstance], options);
dragula.on('drop', (el, target, source, sibling) => {
const newColumnIndex = parseInt(get(target, 'id'));
... |
Why this PUT request is failing with unexpected EOF on google container engine while it works locally? <p><strong>EDIT: added status code received on client</strong></p>
<p>I have Spring Boot based REST API implementation that is giving a strange issue when deployed on Google Container Engine. Some key points about th... | <p><code>PUT</code> HTTP requests typically update an entire resource, whereas <code>PATCH</code> HTTP requests typical update <em>part</em> of a resource. The implication is that one has more overhead than the other. I have seen 504s before and the root cause was a connection <em>timeout</em> on the <em>backend server... |
Add view to constraintLayout with constraints similar to another child <p>I have a <strong>constraint layout</strong> (alpha9) with views spread all over it, and I have one particular ImageView that I need to replicate and add more of like it.
The layout is like so :
<a href="http://i.stack.imgur.com/1g2Zv.png" rel="no... | <p><code>ConstraintLayout.LayoutParams</code> cache its parameters, and is associated to the widget you use it on, so you cannot simply pass one widget's layoutParams to another.</p>
<p>You have to instead generate a new layoutParams for your new object, and copy the corresponding fields.</p>
<p>For example, if you h... |
Why using ngSubmit instead of onSubmit <p>Whats the reason for using <code>ngSubmit</code> to submit a form instead of using <code>onSubmit</code> at the submit button in angular 2.</p>
| <p><code>ngSubmit</code> is a in-built directive of Angular2 which is used to submit Angular2 form without clicking any submit button. You usually see it attached with <code>form</code> tag.</p>
<p>Why?</p>
<p>Consider, you have your login screen contains <code>username</code>, <code>password</code> & <code>logi... |
Visual Studio web testing <p>I come from a world of PHP (Laravel) and have faced no issues with testing the API or webpage like this before. Every time I would make a change I'd simply refresh the page, and it would show me the result of my changed actions.</p>
<p>This does not seem to be the case with my new experien... | <p>It doesn't have anything to do with VS. PHP is a script language, it doesn't get compiled before running like c# does. You have to do a build of the project in order for the DLLs to be up-to-date</p>
|
How to pass data between three different servers in asp.net C# <p>I am using ASP.NET MVC with C# .There is a requirement in one of my project to pass data between three servers.</p>
<p>Below is detailed explanation of scenario:</p>
<p>1) There is Server 1 (Webserver) where website has been hosted through IIS.</p>
<p... | <p>If you a loosely coupled communication style and also asyncronous then go for Queue and use Publish/Subscribe pattern.</p>
<p>Lets say you have a Queue named MessageingQueue and inside this queue there are 3 Topics</p>
<p>First one is Server1ToServer2
Second one is Server2ToServer3
Third one is Server3ToServer1</p... |
D3 V4 Rect bind data in stacked bar chart <p>In Normalized stacked bar I am trying to bind data in all rect in a bar but wrong value is passed. I adopted my code from this <a href="http://bl.ocks.org/mbostock/3886394" rel="nofollow">example</a> and made it horizontal. Below is my code and I have created a <a href="http... | <p>I think the best way to do this is to modify your subselection data-binding to include that information:</p>
<pre><code>var rect = serie.selectAll("rect")
.data(function (d) {
// return all the data you need as flat as possible
var rv = d.map(function(da){
return {p: da, key: d.key, state: da.data.S... |
Remove brackets from JSON array React <p>I am trying to remove the } { brackets from my outputted array in the browser, to make it look cleaner on my page, however I am unsure how to do so. I have the array already outputting correctly, on a new line per object which is correct, but I'd like to remove the brackets.</p>... | <p>You should not probably do it that way. Reasons:</p>
<ol>
<li><p>It's non natural way</p></li>
<li><p>Operations with strings (stringifying to json and replacing with regexp) is expensive.</p></li>
</ol>
<p>Instead you can map over your array:</p>
<pre><code><pre>
{this.state.result.map(item => {
r... |
iOS Local Notification Sound Not Working <p>I'm using a UILocalNotification to inform a user about some events. The problem is, if I choose a custom sound for that, the system's default sound is played nonetheless. The weird thing about that is that sometimes it still works with my sound and sometimes it doesn't. I hav... | <p>your notification sounds may not be longer than 30 seconds - if the file supplied is longer, nothing will sound.</p>
<p>Also,check the sound in some external player first, and best convert it to .caf format.</p>
<p>To convert a file to .caf, open up terminal, go to where you have your sound stored and type in:</p>... |
Irish font not coming correctly in asp.net dropdown <p>In dropdownlist irish font not appearing correctly expected - Ãire actual in attached image "�ire".
<a href="http://i.stack.imgur.com/Azo9s.png" rel="nofollow"><img src="http://i.stack.imgur.com/Azo9s.png" alt="Irish font"></a></p>
| <p>Use following setting in webconfig worked for me.(Western European encoding)</p>
<pre><code> <globalization culture="" responseEncoding="ISO-8859-1" uiCulture="" />
</code></pre>
|
Good C++ alternative to MATLAB's "fminunc"? <p>I am trying to convert some code written in MATLAB to C++. I'm having some (or actually quite a lot of) trouble finding an alternative to the "fminunc" function which is used in the MATLAB code that I can replace and use in the C++ code. I've been looking at the "dlib"-lib... | <p>There are a bunch of optimizers in dlib, some that use gradients and others than just work on black-box functions. You can see some examples here <a href="http://dlib.net/optimization_ex.cpp.html" rel="nofollow">http://dlib.net/optimization_ex.cpp.html</a> and more generally here <a href="http://dlib.net/optimizati... |
CSS: self-adjusting table with max width that clips to content width <p>I am struggling to make the adjustable parent div fit the content:
(I want the widening white space on the right to go away)
<a href="http://jsfiddle.net/TDq7T/42/" rel="nofollow">http://jsfiddle.net/TDq7T/42/</a></p>
<p>max-width: and width:fit-c... | <p>Use <code>display: flex;</code> on <code>#menu</code> (and erase <code>float: center</code>):</p>
<p><a href="http://jsfiddle.net/d3rp294u/" rel="nofollow">http://jsfiddle.net/d3rp294u/</a></p>
|
How to access "Comment" field using Adwords API <p>Adwords Editor allows to view/update "Comment" field. The same can be modified using CSV Export/Import. But, I am unable to get the same using Adwords API.</p>
<p>BTW, I want a way for my business user to "tag" certain Ad Group so that my script does alter those ads a... | <p>You cannot access "Comment" field outside Adwords Editor, because it is local field stored on the desktop. So accessing the same using API is out of question.</p>
<p>I am now using Labels to achieve my requirement.</p>
|
Android activity taking time to load <p>I have <code>3 activities</code> in my app. </p>
<p>The second one when swiped left/right shows other activities. The center activity (the second) has camera as background (background shows what camera sees).</p>
<p>When I navigate from this <code>activity</code> to another, th... | <p>You are loading camera in activity UI. Do loading of camera asynchronously.</p>
|
iOS app rejected when using GoogleTagManager <p>We submitted an iOS app which was rejected because of private API calls to </p>
<p>dispatchTime
setDispatchTime</p>
<p>Narrowing down the library that calls these functions, its seem its GoogleTagManager v3, which depends on GoogleAnalytics is the culprit, we were using... | <p>Google Tag Manager isn't calling a private API, but an internal class in Google Tag Manager has a selector with the same signature. We've seen several occurrences of this with Google Tag Manager, and there are other libraries reporting similar rejections (<a href="https://openradar.appspot.com/28252227" rel="nofollo... |
How to add multiple tags to a post in Tumblr using the API with PHP? <p>I am posting on Tumblr using its API. I can successfully post and add a single tag to any post but I am having trouble while adding multiple tags.</p>
<p>This is what they suggest on their guide:</p>
<pre><code>{
"response": {
"posts": [
{
... | <blockquote>
<p>This is what they suggest on their guide:</p>
</blockquote>
<p>No, it isn't. That's the JSON data structure you can expect to <em>get back</em> from the API when you <em>read</em> post information. In that case, the <code>tags</code> property will be an <em>array</em> of tags.</p>
<p>You want to <em... |
How I can cancel this white blank thing on the keyboard everytime when I click on a button <p>hey when I click on the custom keyboard it shows me this blank thing I don't want to appear on every single time I click on a button how can I remove this thing it's on the picture if u see it u will understand me more and tha... | <p>Set</p>
<pre><code>mKeyboardView.setPreviewEnabled(false);
</code></pre>
<p>after setting findViewById for your keyboardview</p>
|
How to use a @Singleton from an Akka actor? <p>I am new to Dependency Injection and now when I migrated my application to Play 2.5.x I need to learn.</p>
<p>I have a singleton service looking something like this:</p>
<pre><code>import javax.inject._
@Singleton
class WorkerService {
def doWork(work:String) {
... | <p>You probably should not create the actor in the Application class.</p>
<p>Try using a module to create your actor like this</p>
<pre><code>class ApplicationConfigModule extends AbstractModule with AkkaGuiceSupport {
override def configure(): Unit = {
bindActor[PollActor]("poll-actor")
}
}
</code></pre>
<... |
How can I create an ASP.NET Identity user that can sign in? <p>I have an ASP.NET web application that has internal individual user accounts. I want to create those user accounts from an external program. So I have a program that references <code>Microsoft.AspNet.Identity</code>. In it I create users:</p>
<pre><code>va... | <p>It turns out the culprit was <code>IdentityUser</code>. I don't know why (I'm guessing securitystamp has something to do with it), but you need to make <code>ApplicationUser</code>s. So I included a reference to the web application so I could make an <code>ApplicationUser</code> instead of an <code>IdentityUser</cod... |
Avoid code duplication by implementing two functions that differ by const <p>I have a generic <code>Matrix</code> class, and I have two version of <code>operator()</code>,
a const method that returns a const reference to the index,
and a non-const method that returns a non const reference to the index (which allows me ... | <p>Here, code duplication is the lesser of the two evils. Simply repeat the expression <code>_matrix[col + (_cols * row)]</code> in the non-<code>const</code> version. Don't fight the language.</p>
<p>To call the <code>const</code> version, you need to <code>const_cast</code> the <code>this</code> pointer. The express... |
Multiple providers web api <p>I am working on a ASP.NET WEB API multiple clients app. First client authenticates through username and password and the second one through a code (string type). </p>
<p>Is it possible to have multiple providers on same app?
Here is the code :</p>
<pre><code>public void ConfigureAuth(IA... | <p>I have both OAuth enabled and a custom cookie based solution. </p>
<p><strong>Web Api Config</strong></p>
<pre><code> app.UseWebLoginAuthentication(Container); // Custom cookie solution
ConfigureIdentityManager(app); // Identify manager
ConfigureAuth(app); // OAuth provider
</code></pre>
<p><strong>Authen... |
Tensorflow control_dependencies not working with list <p>I have a cost, which depends on two list of variables <code>a</code> and <code>b</code>.<br>
I want to :</p>
<ol>
<li>calculate both gradients of the cost at the current point, </li>
<li>update the loss w.r.t. the first list of variables (<code>a</code>)</li>
<l... | <p>Your <code>grad_cost_wrt_a</code> and <code>grad_cost_wrt_b</code> variables are lists, do something like <code>grad_cost_wrt_a[0], grad_cost_wrt_b[0]</code></p>
|
retrieve array from collection <p>The function <code>getError</code> populates a collection with arrays of type <code>variant</code>. How do I call one of the collection <code>ErrorValues</code> items to another function?</p>
<p>It is throwing an error saying Type mismatch: array or user-defined type expected when I c... | <p><code>Public Function chartUpdate(chartIdx, cond as variant, title)</code> I got to work</p>
|
Specify camel context shutdown order with multiple contexts <p>I have a Camel / Spring application with multiple contexts (say 3 - A, B & C). The contexts are designed to be started / stopped in a specific order. Startup: C, B, then A. Shutdown A, B, then C. There is a lot of documentation about specifying shutdown... | <p>A couple of approaches to explore:</p>
<ol>
<li><p>Use bundle run-levels in a Karaf-based container to ensure shutdown is reverse of startup</p></li>
<li><p>Design a convention where you can leverage the Camel controlbus and have one "master" route in charge of startup and shutdown. Configure all routes to <em>not<... |
How to load multi-line column data in hive table? Columns having new line characters <p>I have a column (not the last column) in Excel file that contains data which is spanning over few lines.</p>
<p>Some cells of column is blank and some have single lines entries.</p>
<p>When saving as .CSV file or a tab separated .... | <p><a href="https://cwiki.apache.org/confluence/display/Hive/CSV+Serde" rel="nofollow">From this link</a>, the provided SerDe cannot handle embedded new lines. My guess is that if you want embedded new lines, you will have to create a custom SerDe. Without looking too deeply into it, <a href="http://dev.bizo.com/2010/1... |
open whatsapp from webview controller xcode <p>I am using webview for my swift app and i have share on WhatsApp button in my website, which works fine on browser, But on iPhone app when i click on WhatsApp share button, nothing happens, I have also created a android app with same website and i added this code to my app... | <p>You can use URL schemas to open whatsapp from your app. </p>
<pre><code>class myViewController : UIViewController,UIWebViewDelegate{
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string:"m.wahstatus.com/ws/punjabi-status/")
let request = NSURLRequest (url: url! as URL)
webView.frame = self.vie... |
Excel - IF function using a wildcard <p>I have been working on a spreadsheet in excel and I have encountered a problem in which I am not able to solve. I have attempted everything to my knowledge and performed research on what I was able to find online. I am attempting to use an IF statement to automatically populate a... | <p>Your <a href="https://support.office.com/en-us/article/vlookup-function-adceda66-30de-4f26-923b-7257939faa65" rel="nofollow">VLOOKUP function</a> is an approximate match and the lookup column ('Locate-Dept-AcctNum'!$C:$C) must be in ascending order.</p>
<p>I would suggest changing error control to a wrapping <a hre... |
docker-compose can't find services or containers in Docker for Mac <p>I have a docker-compose set up that starts a Rails web application and a PostgreSQL DB container.</p>
<p>Both services start, but I need to run db:seed and db:migrate in the web application container (service = "web").</p>
<p>I try to do this with:... | <p>When you do <code>docker-compose run</code> it generates a random unique name for the running container, you'll have to specify that when using exec.</p>
<p><code>
$ docker-compose run bot
...
</code></p>
<p>In another terminal:</p>
<p><code>
$ docker ps
CONTAINER ID IMAGE COMMAND ... |
Set-ItemProperty: Cannot find path because it does not exist <p>I am trying to set a bunch of files to read-only. However when I call</p>
<pre><code>Set-ItemProperty -LiteralPath $path -Name IsReadOnly -Value $true
</code></pre>
<p>it tells me that my path does not exist. The path points to a file which I am sure is ... | <p>Try this:</p>
<pre><code>Set-ItemProperty -Path $path -Name IsReadOnly -Value $true
</code></pre>
<p>The parameter you are looking for is "Path" and not "LiteralPath".</p>
<p>Link to Microsoft documentation about Set-ItemProperty:
<a href="https://technet.microsoft.com/de-de/library/hh849844.aspx" rel="nofollow">... |
In C++, what is the difference between X x = X(); type declaration and X x; declaration where X is the class <p>In my code I encountered above kind of scenario. Under what circumstances we need to use above style of object creation? Cant we simply create object X x? What thing we have achieved in X x = X(); type declar... | <p>There is difference. <code>X x = X()</code> requires the copy constructor to be accessible.</p>
<p>For the following class:</p>
<pre><code>struct Foo
{
Foo() = default;
Foo(Foo const&) = delete;
void* ptr;
};
</code></pre>
<p>This will compile:</p>
<pre><code>Foo foo;
</code></pre>
<p>and this w... |
PyQt: How do I load a ui file from a resource? <p>In general, I load all my ui files via the <code>loadui()</code> method, and this works fine for me. This looks like this:</p>
<pre><code>#!/usr/bin/env python
#-*- coding:utf-8 -*-
'''
The modules for Qt are imported.
PyQt are a set of Python bindings for Qt.
'''
fro... | <p>It's not really much different from what you were already doing:</p>
<pre><code>from PyQt4.QtCore import QFile
from PyQt4.uic import loadUiType
import resources_rc
def loadUiClass(path):
stream = QFile(path)
stream.open(QFile.ReadOnly)
try:
return loadUiType(stream)[0]
finally:
str... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.