input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Search from the string array and ignore that exact matched string <p>how can I ignore the exact matched from the string array with linq query</p>
<p>here is my code whats wrong with it</p>
<pre><code>public string GetItems(string SearchText, Int64 userID, Int64 orgID, Int64 locationID, string[] selectedProductName)
{... | <p>Your use of the <code>.Any</code> is incorrect:</p>
<ol>
<li>In your current use you are checking if <code>any</code> of the <code>char</code>s that
construct <code>a.name</code> match some predicate.</li>
<li><code>.Any(a.Name != selectedProductName)</code> - you need to form a properly formatted lambda expression... |
how to pass enum values from TCL script to C++ class using Swig <p>I am using following code </p>
<p>1) File : example.i </p>
<pre><code>%module example
%{
/* Put header files here or function declarations like below */
#include "example.h"
%}
%include "example.h"
</code></pre>
<p>2) File example.h</p>
... | <p>According to the <a href="http://www.swig.org/Doc1.3/Tcl.html#Tcl_nn18" rel="nofollow">official documentation</a>:</p>
<blockquote>
<p>C/C++ constants are installed as global Tcl variables containing the
appropriate value.</p>
</blockquote>
<p>So you must refer to the enum value by dereferencing the correspond... |
Is it possible to retrieve in output which predicate in where clause is evaluated true? <p>Is it possibile in a select query that has a where clause with a lot of predicates retrieving in output which one predicate is evaluated true, together with real tuple?</p>
<p>For instance, given this table:</p>
<pre><code>Tabl... | <p>You could wrap the condition:</p>
<pre><code>select *
from (
select p.*,
(age >= 25) as condition_1,
(hair_color = 'Blonde') as condition_2
from person p
) t
where condition_1 or condition_2
</code></pre>
<p>The above is standard SQL and assumes the DBMS being used support a proper <code... |
getting Readable { .. } instead of specific collection using find() on mongodb <p>I have a collection named 'EloVars' on my mongodb, with only one document:</p>
<pre><code>{
"_id": {
"$oid": "5800f3bfdcba0f48d2c58161"
},
"nextPID": "0",
"TotalComprasions": "0"
</code></pre>
<p>}</p>
<p>I'm trying to get the valu... | <p><code>find()</code> returns a <code>cursor</code>. You have to iterate the cursor to get the documents.</p>
<pre><code>var cursor = db.collection('EloVars').find();
cursor.each(function(err, doc) {
console.log(doc);
});
</code></pre>
<p>Or you can convert it to an array to get the documents.</p>
<pre><code>c... |
Angular2 reverse/generate url from Routes (typescript) <p>How can I generate url from route be code?
For exemple, I have a login component in my routes:</p>
<pre><code>const appRoutes: Routes = [
...
{ path: 'login', component: LoginComponent },
...
];
</code></pre>
<p>I want to build a string correspondi... | <p>You can inject <code>Router</code> and <code>UrlSerializer</code></p>
<pre><code>constructor(router:Router, urlSerializer:UrlSerializer) {
let tree = router.createUrlTree(['/path', param, 'otherPath'], relativeTo: 'xxx', queryParams: {y: z});
let url = urlSerializer.serializeUrl(tree);
}
</code></pre>
<p>To ge... |
Redirect is not working in LogSuccessfulLogin handle in Laravel Auth <p>I am using <code>Laravel 5.3</code> in which using <code>Auth</code>for user controller.
So basically i create a <code>Listener</code> for <code>Auth</code> Event</p>
<pre><code>'Illuminate\Auth\Events\Login' => [
'App\Listeners\LogSuccessf... | <p>As one of possible solutions I would provide a response middleware that will be attached to login route. After getting response you should check if user is logged and if yes - apply your custom redirection login. In that case you will overwrite default Laravel 5.3 logic of redirection. Smth like this:</p>
<pre><cod... |
Not able to show Google Map in android version 4.1 whereas map is visible in android higher then version 5 <p>In this i have alse implemented firebase service of google previously i was not using firebase service so that time my compile 'com.google.android.gms:play-services-location:8.3.0' it was working fine in 4.1 a... | <p>First, remove the line <code>'com.google.android.gms:play-services:9.4.0'</code> because it will add all the Google Play and Firebase libraries to you app. It will also increase the build time and the size of the APK file. So replace it with the library that you only need. Here is the <a href="https://developers.goo... |
How can I play MIDI tracks created using python-midi package? <p>I want to create MIDI tracks in a Python program and be able to play them instantly (preferably without writing to disk). I have recently discovered the package <a href="https://github.com/vishnubob/python-midi" rel="nofollow">python-midi</a> which looks ... | <p>My solution if anyone is interested:</p>
<p>I ended up using <a href="https://github.com/olemb/mido" rel="nofollow">mido</a> for my Python MIDI API, with Pygame as the backend.
Works like a charm :)</p>
|
Taking photo with custom camera Swift 3 <p>in Swift 2.3 I used this code to take a picture in custom camera:</p>
<pre><code> func didPressTakePhoto(){
if let videoConnection = stillImageOutput!.connection(withMediaType: AVMediaTypeVideo) {
stillImageOutput?.captureStillImageAsynchronouslyFromConn... | <p>You can use <code>AVCapturePhotoOutput</code>like this in Swift 3:</p>
<p>You need the <code>AVCapturePhotoCaptureDelegate</code> which returns the <code>CMSampleBuffer</code>.</p>
<p>You can get as well a preview image if you tell the <code>AVCapturePhotoSettings</code> the previewFormat</p>
<pre><code>class Ca... |
angularjs firebase user auth service not communicating with the views <p>I have a service which passes on the parameter <code>pseudonym</code> to the evironment. I call on this <code>pseudonym</code> in my views, but it doesn't appear at all.<br />
How can I fix this to display the value in my views?<br /></p>
<p><st... | <p>Return the promise created by the <code>.then</code> method:</p>
<pre><code>app.service('MyUser', ['DatabaseRef', 'firebase', function(DatabaseRef, firebase) {
//var pseudonym ="";
var userId = firebase.auth().currentUser.uid;
return {
getUserName: function() {
//return promise
... |
Displaying normalized data in the react UI component <p>Let' say we have normalized object like this one in redux store.</p>
<pre><code>{
entities: {
plans: {
1: {title: 'A', exercises: [1, 2, 3]},
2: {title: 'B', exercises: [5, 6]}
},
exercises: {
1: {title: 'exe1'},
2: {title: 'exe2'},
3: {... | <p>Yup, you have to denormalize before displaying. For example if you have list of active users stored as denormalized list of user ids, you have to map through those and for each fetch respective object from the state tree. </p>
<p>Yes, probably do this in mapStateToProps. </p>
<p>Sort-of recommended approach is to ... |
How to escape double quotes and colon in ACK in powershell <p>I am using Ack version 2.04, in powershell.
I want to search texts like <strong>"jsonClass":"Page"</strong> (quotes included) inside text files.</p>
<p>I cant seem to get the quoting and escaping correctly.</p>
<pre><code>ack -c --match '"jsonClass":"Page... | <p>To complement <a href="http://stackoverflow.com/a/40058586/45375">JPBlanc's effective answer</a> with a <strong>PowerShell v3+</strong> solution:</p>
<p>When <strong>invoking external programs</strong> such as <code>ack</code>
, use of the so-called <strong>stop-parsing symbol, <code>--%</code></strong>, makes Powe... |
Call a Method From Inside dom-repeat in Polymer <p>I'm having this situation where I need to call a method from the dom-repeat. Below is my code</p>
<pre><code><template is='dom-repeat' items="[[_dataArray]]" as="rowItem">
<template is='dom-repeat' items="[[_objectArray]]" as="columnItem">
&l... | <p>If your code is exactly as you pasted, then you have one too many <code><template></code> tags.</p>
<pre><code><template is='dom-repeat'>
<template is='dom-repeat'>
<span></span>
</template>
</template>
</code></pre>
<p>The innermost template must be removed. You ... |
Scala: Write log to file with log4j <p>I am trying to build a scala based jar file in eclipse that uses log4j to make logs. It prints out perfectly in the console but when I try to use log4j.properties file to make it write to a log file, nothing happens.</p>
<p>The project structure is as follows</p>
<p><a href="htt... | <p>Hello while you are deploying you application you should define log4j file for executor and driver as follows</p>
<pre><code>spark-submit --class MAIN_CLASS --driver-java-options "-Dlog4j.configuration=file:PATH_OF_LOG4J" --conf "spark.executor.extraJavaOptions=-Dlog4j.configuration=file:PATH_OF_LOG4J" --master MAS... |
How do I pass an array of line specifications or styles to plot? <p>I want to plot multiple lines with one call to <code>plot()</code>, with different line styles for each line. Here's an example:</p>
<p>Both</p>
<pre><code>plot([1,2,3]', [4,5;6,7;8,9], {'-o', '-x'})
</code></pre>
<p>and</p>
<pre><code>hs = plot([1... | <p>Referring to <a href="http://www.mathworks.com/help/matlab/ref/plot.html" rel="nofollow">http://www.mathworks.com/help/matlab/ref/plot.html</a>, this is how to draw multiple lines with a single plot command:</p>
<pre><code>plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn)
</code></pre>
<p>So your idea of </p>
<pre><code>... |
Distance formula in SQL <pre><code>SQL> SELECT sighting_id, distance
FROM sightings
WHERE distance = SQRT(POWER(latitude -(-28),2) + POWER(longitude -(151),2))
GROUP BY sighting_id, distance;
</code></pre>
<p>Receiving the error PLS-306: wrong number or types of arguments in call to 'OGC_DISTANCE'. Any ideas?</p>... | <p>try using some other name for 'distance' column, looks like it is some internal GEO function or synonym already defined in your Oracle DB. Please also check if all latitude and longitude values in the table are valid numbers, not null etc. </p>
<p>You may need to add some coalesce() wrapper for null latitude and lo... |
Downloading an Excel file with plots and dataframes from shiny. (Not working for plots) <p>Hello fellow shiny users. </p>
<p>I am running across a problem I can't seem to find any solution to on the various forums and websites.
I will share a relatively simple reproducible example that illustrates my problem. </p>
<... | <p>Here is a working <code>server.R</code> file. Note that I couldn't get the emf file format to work, but jpeg works.</p>
<pre><code>library(shiny)
library(xlsx)
library(ggplot2)
server <- function(input, output) {
output$download.Excel <- downloadHandler(
filename = function() { paste("Excelfile.xlsx"... |
AS3 error 1119: Access of undefined property CHANGE through a reference with static type flash.events:MouseEvent <p>This might be a bug in AS3 because the event its listing in the error is not associated with a mouseEvent, but I'd really like to get to the bottom of this. I've been working on this project and have a mo... | <p>The problem is how you are naming your variables.</p>
<pre><code>function shwSrch(Event:MouseEvent):void
</code></pre>
<p>Here you use <code>Event</code> as the parameter name which is a bad choice, because it's the same name the <code>Event</code> class has. Later, you add a listener.</p>
<pre><code>srch.npt1.it... |
How to get DUID <p>How to get a DUID for Tizen tablet.
Connection Explorer - Device - Properties didn't get such information:</p>
<p><a href="https://i.stack.imgur.com/vUm69.png" rel="nofollow"><img src="https://i.stack.imgur.com/vUm69.png" alt="enter image description here"></a></p>
| <p>As I know DUID is not standard specification of Tizen.</p>
<p>It is served only Gear devices.</p>
<p>You can get it with following command.</p>
<pre><code>sdb shell /opt/etc/duid-gadget
</code></pre>
<p><code>/opt/etc/duid-gadget</code> is not in specification of Tizen. so it can be changed in any time. (But cur... |
Find netMask on Android device <p>I have to find information about the network to which the Android device is connected. Basically the Android device is a Android TV and it has WiFi and Ethernet connectivity.<br>
I am working with WiFi and getting all the correct information except <code>netMask</code> as it is always ... | <p>It's <a href="https://code.google.com/p/android/issues/detail?id=82477" rel="nofollow">an android bug</a>.</p>
<p>According to the bug report, you can either use the following workaround (copied from the report):</p>
<pre><code>WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SER... |
create file containing '/' in file name in python <p>how can I create a file in python if the filename contains '/'</p>
<pre><code>url='https://www.udacity.com/cs101x/index.html'
f=open(url,'w')
f.write('123')
f.close()
</code></pre>
<p>above code produces an error as</p>
<pre><code>Traceback (most recent call last)... | <p>Use os.path.basename() to isolate the filename.</p>
<pre><code>import os
url='https://www.udacity.com/cs101x/index.html'
filename = os.path.basename(url)
f=open(filename,'w')
f.write('123')
f.close()
</code></pre>
<p>This will create a file called index.html</p>
|
SQL group by coalesce not working as expected <p>I have following MySQL table (<code>images</code>):</p>
<pre><code>+----+------------+-----------------------+
| id | gallery_id | path |
+----+------------+--------------... | <p>You could use a when in with subselect and group by</p>
<pre><code>select * from `images`
where (gallery_id, id ) in (select gallery_id, min(id)
from `images`
where gallery_id is not null
group by gallery_id)
</code></pre>
|
Auto-open perspective <p>I'm developing an eclipse plugin in which I included a custom perspective.<br>
I'd like to get a similar behaviour to the Java perspective. That is that when creating a Java project eclipse will ask you whether you want to open the respective perspective for this... </p>
<p>I found out that I... | <p>Your New Project wizard should call </p>
<pre><code>BasicNewProjectResourceWizard.updatePerspective(configElement);
</code></pre>
<p>in your <code>performFinish</code> when the project has been created.</p>
<p><code>configElement</code> is the <code>IConfigurationElement</code> for your new wizard. You get this b... |
PostgreSQL: stored proc to return a fake row from several ones with a condition <p>consider the following table:</p>
<pre><code>Value1 Value2 Value3
1 1 0.9
1 2 0.8
1 3 0.1
2 1 0.1
2 2 0.15
</code></pre>
<p>I need to return only rows those match the following conditio... | <p>Use <code>union</code>:</p>
<pre><code>select *
from a_table
where value3 >= 0.8
union all
select value1, 0, max(value3)
from a_table
group by value1
having max(value3) <= 0.2;
</code></pre>
<p>It is easy to create an sql function based on the query, e.g.:</p>
<pre><code>create or replace function select_... |
EventKitUI/EKCalendarChooser needs access to contacts - why? <p>I have an existing app since 2010, and with iOS 10 it is now required that the app is having strings in the <code>Info.plist</code> describing the usage, as explained here:
<a href="http://useyourloaf.com/blog/privacy-settings-in-ios-10/" rel="nofollow">ht... | <p>I've just had the same problem and believe it is because the EKCalendarChooser can show which of your Contacts is sharing a calendar. I just turned off all sharing including removing family members from iCloud Family and it no longer requires access to Contacts. I then tried to share a calendar with a contact using ... |
What is axis in Python with Numpy module? <p>when I use np.stack, sometimes have to use axis, like axis=1. I don't understand what the axis means for it. for exmaple,</p>
<pre><code>c1 = np.ones((2, 3))
c2 = np.zeros((2, 3))
c = np.stack([c1, c2], axis = 1)
</code></pre>
<p>this shows like,</p>
<pre><code>array([[[1... | <p>Axis means the dimension . For a simple example consider <a href="http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.sum.html" rel="nofollow">numpy.sum</a> </p>
<pre><code>import numpy as np
a=np.array([1,2,3],[2,3,1])
sum1=np.sum(a,axis=0)
sum2=np.sum(a,axis=1)
print sum1,sum2
</code></pre>
<p>This ... |
Keeping subdomain name in address bar - Wordpress <p>I'm completely new to the community and have a question which might seem stupid.</p>
<p>I've created a page in my Wordpress site (which is not finished yet) which I want to use as a landing page. However, I want this page to be seen as a subdomain of my website.</p>... | <p>There are two ways to modify the response to a request, rewrite and redirect.</p>
<ul>
<li><p>Rewrite is just declaring, what should be sent to a client for some given request.</p></li>
<li><p>Redirect tells the client, where it should fetch the response.</p></li>
</ul>
<p>A redirect is triggered explicitly by the... |
DEPRECATION WARNING after updating from Rails 5.0.0 to 5.0.0.1 <p>I updated my Rails app from 5.0.0 to 5.0.0.1 by running the command <code>bundle update rails</code></p>
<p>Some commands that gives me this warning are:</p>
<pre><code>rails s
rails db:migrate
rails db:seed
git push heroku
</code></pre>
<p>The ful... | <p>Upgrade <code>sass-rails</code> by adding <code>gem 'sass-rails', '~> 5.0', '>= 5.0.6'</code> to <code>Gemfile</code> or modifying the existing line to this and run <code>bundle install --without production && bundle update</code> .</p>
|
DBCC Command Not Working Inside Procedure <p>I have below query. Logically, the procedure <code>usp_mytran</code> should RESEED the Identity to 1 for table <code>dbo.Sales</code>. But the last query is returning different values for <em>Max_ID_Value</em> and <em>Current_Seed_Value</em>. Can anyone please explain why DB... | <p>Sorry for answering my own question. As pointed by @Kannan Kandasamy, it is the <code>ROLLBACK TRANSACTION</code> code that is reverting back the work done by <code>DBCC CHECKIDENT</code>. So to make it work, I have created a job with name <code>Reseed_Sales</code> containing code to RESEED Identity for table <code>... |
caffe hdf5 H5LTfind_dataset(file_id, dataset_name_) Failed to find HDF5 dataset <p>I was using HDF5 as one of the input to feed caffe, the hdf5 file only contains some weight information to put in the sigmoidcrossentropyloss layer so it doesn't contain any <code>label</code>.This error occured:</p>
<blockquote>
<pre><... | <p>Your <code>"HDF5Data"</code> has <code>top</code> named <code>"weight28"</code>, but your <code>h5</code> file has only dataset <code>"data"</code>. The <code>"top"</code> of <code>"HDF5Data"</code> layer <strong>must</strong> be the same as the Dataset name stored in the <code>h5</code> file. If you have more than ... |
Android listview in scrollview <p>Hi i have try insert listview in scrollview but i have this problem:
<a href="https://i.stack.imgur.com/sNHMg.png" rel="nofollow"><img src="https://i.stack.imgur.com/sNHMg.png" alt="enter image description here"></a></p>
<p>the space that scrollview reserve to listview is little, i wa... | <p>More solutions can be found here: <a href="http://stackoverflow.com/questions/18367522/android-list-view-inside-a-scroll-view">Android list view inside a scroll view</a></p>
<p>This is a common issue that a lot of developer face. The issue is you are stacking a scrollable view inside another scrollable view. One so... |
Duration of counting to a high number <p>I am trying to set the duration of my counter to be slow without having a large duration number set in the code for example:</p>
<pre><code>duration: 99999;
</code></pre>
<p>Originally I had the counter set to a low number but the count is to reach 1,000,000,00 but i want to b... | <p>If you want to set how quickly the count is being made, you can try setting the duration (which is measured in milliseconds) to match the <code>countTo</code> value. For example, if you want an increment to be made every second, do: <code>duration: parseInt(countTo)*1000</code>.</p>
<p><div class="snippet" data-lan... |
how to enable/disable specific dates in DateTimePicker winforms c# <p>I am programming a <code>C#</code> <code>Windows</code> application for a clinic and i stored days of works for every doctor for example </p>
<p>Dr.John works every Monday and Tuesday how i can enable dates in <code>DateTimePicker</code> for dates t... | <p>Instead of the <code>DateTimePicker</code> you can </p>
<ul>
<li>create a form on the fly</li>
<li>add a <code>MonthCalendar</code> to it</li>
<li>add either valid or invalid dates to the <code>BoldDates</code> collection</li>
<li>code the <code>DateChanged</code> event</li>
<li>test to see if a valid date was sele... |
.hide("slow") is synchronous or Asynchronous method? <p>As we know <code>$.ajax()</code> Is a asynchronous method , beacuse next statement starts executing before <code>ajax()</code> method is fully executed and 'ajax()' keep doing his stuff parallelly ,And <code>hide()</code> is a Synchronous method, because it immed... | <blockquote>
<p>.hide(âslowâ) is synchronous or Asyncronous method</p>
</blockquote>
<p>The <em>call</em> to the method is synchronous, but it starts an asynchronous process. So we would normally, loosely, call it an "asynchronous method" (in this case, where you're giving it a duration argument).</p>
<p>When y... |
How to create a "LIKE" button on a cell and conform to MVC? <p>I want to create a like button on a table view cell, just like Instagram, Facebook, and 100s of other social network apps have, but I am struggling to understand how this can be done properly keeping in mind MVC paradigm. </p>
<p>My structure looks like th... | <p>How about something like:</p>
<p>FeedCell.swift:</p>
<pre><code>@IBOutlet var likeButton: UIButton!
var likeButtonPressedHandler: (() -> ())?
var isLikeButtonSelected: Bool {
get { return likeButton.isSelected }
set { likeButton.isSelected = newValue }
}
@IBAction func likeButtonPressed(_ button: UIButton... |
Advanced array concatenation python <p>Say I have four multi-dimensional arrays - </p>
<pre><code>a = [["a","a","a"],
["a","a","a"],
["a","a","a"]]
b = [["b","b","b"],
["b","b","b"],
["b","b","b"]]
c = [["c","c","c"],
["c","c","c"],
["c","c","c"]]
d = [["d","d","d"],
["d","d","d"],
["d"... | <p>Maybe like this:</p>
<pre><code>top = list(x+y for x,y in zip(a,b))
bottom = list(x+y for x,y in zip(c,d))
total = top + bottom
for r in total: print(r)
</code></pre>
<p>Output:</p>
<pre><code>['a', 'a', 'a', 'b', 'b', 'b']
['a', 'a', 'a', 'b', 'b', 'b']
['a', 'a', 'a', 'b', 'b', 'b']
['c', 'c', 'c', 'd', 'd', '... |
How to synchronize a google calendar with google spreadsheet? <p>My goal is to synchronize a google calendar with a google spreadsheet automatically. Every time an event is added to the calendar, rows should be appended to the google spreadsheet. I wrote a script that loads the list of the upcoming event into a google ... | <h1>Short answer</h1>
<p>Use a time-drive trigger</p>
<h1>Explanation</h1>
<p>At this time Google Apps Script is not able to bound a script to a Google Calendar. The alternatives are to use a bounded to a spreadsheet or a standalone script, so it's not possible at this time to trigger an script when an event is crea... |
mysqli_insert_id on compound query <p>I am using <code>mysqli_insert_id()</code> to get the last auto increment id on a table, but it always returns '0'. </p>
<pre><code>$sql = "INSERT INTO inventory (SELECT * FROM tmptable)";
$result = mysqli_query($link, $sql);
$newId = mysqli_insert_id($link); //$newID ends up bein... | <p>You're using <code>LAST_INSERT_ID()</code> incorrectly. <a href="http://dev.mysql.com/doc/refman/5.7/en/information-functions.html#function_last-insert-id" rel="nofollow">http://dev.mysql.com/doc/refman/5.7/en/information-functions.html#function_last-insert-id</a> It's the server feature underlying <a href="http://... |
difference between viewport and camera in libgdx? <p>I am new to LibGdx framework, and having trouble working with viewport and camera. Can anyone give a simple difference between each and use of both.</p>
| <p>In a simple way, the camera is nothing but it's like our real life camera. in libgdx camera is used to show our game area. for example for making a movie the director will do so many preparation and everything will be capturing through the camera. in the same way in libgdx for our gameplay, we create so many sprites... |
Floating action button: Error inflating class FloatingActionButton <p>I'm trying to use the floating action button in xamarin.forms from the NuGet <code>FAB.Forms</code> package(<a href="https://github.com/keannan5390/Xamarin.Plugin.FAB" rel="nofollow">github</a>). I tried to make my code like the example provided in t... | <p>I had similar problem but i use Android. Just change the project parent theme to any Theme.AppCompat~, this resolved my problem, maybe your also. And add <code>global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity</code> to your <code>MainActivity.cs</code>.</p>
<pre><code>[Activity(Label = "YourName", ... |
PHP form validation to do alert if no error <p>I have the following form validation.</p>
<pre><code><?php
$error_occured = 0;
$error_name = "";
$error_email = "";
$error_contact = "";
$error_comments = "";
if(isset($_POST["tx_name"])) {
if(($tx_name == "") || (!preg_match("/^... | <p>Try like this</p>
<pre><code><?php
$error_occured = 0;
$error_name = "";
$error_email = "";
$error_contact = "";
$error_comments = "";
if(isset($_POST["tx_name"])) {
if(($tx_name == "") || (!preg_match("/^[a-zA-Z ]*$/",$tx_name))) {
$error_occured = 1;
$error_name = "P... |
Download a web page using wget and define a new filename <p>I need to write a script in bash using <code>wget</code> which download a web page which has been passed to an argument and then the script should put the extracted page in a new <em>file.html</em> and then also extract all the tags of the web page in a second... | <p>This will work:</p>
<pre><code>page="https://fr.wikipedia.org/wiki/Page_web"
wget -O file.html -r -np "$page"
</code></pre>
<ol>
<li>Variable assignment: <code>var_name=value</code> (no space allowed around <code>=</code>)</li>
<li>Bash is not PHP, <code>$var=val</code> is not correct, <code>var=val</code> is.</li... |
How to find oracle J2EE tutorial? <p><a href="https://docs.oracle.com/javaee/7/tutorial/" rel="nofollow">https://docs.oracle.com/javaee/7/tutorial/</a></p>
<p>I can`t find this tutorial; I am a beginner with j2EE.</p>
<p>Thanks in advance. </p>
| <p>check this link please
<a href="http://docs.oracle.com/javaee/7/tutorial/" rel="nofollow">Java Platform, Enterprise Edition: The Java EE Tutorial</a> </p>
<p>They have just restructured the documentation.</p>
|
Theano learning AND gate <p>I wrote a simple neural network to learn an AND gate. I'm trying to understand why my cost never decreases and the predictors are always 0.5:</p>
<pre><code>import numpy as np
import theano
import theano.tensor as T
inputs = [[0,0], [1,1], [0,1], [1,0]]
outputs = [[0], [1], [0], [0]]
x = ... | <p>Your model is of form</p>
<pre><code><w, x>
</code></pre>
<p>thus it cannot build any separation which <strong>does not cross the origin</strong>. Such equation can only express lines going through point (0,0), and obviously line separating AND gate ((1, 1) from anything else) does not cross the origin. You ... |
Split strings with specified step in python <p>I have a string in python without white space and I want python to split this string for every 3 letters so like <code>'antlapcap'</code>,
For example would be <code>['ant', 'lap', 'cap']</code> is there any way to do this? </p>
| <p>not sure if theres a more efficient way of doing it but
,try:</p>
<pre><code>string = "antlapcap"
list = []
i = 0
for i in range(i,len(string)):
word =string[i:i+3]
list.append(word)
i=i+3
j = list
b =j[::3]
print(b)
</code></pre>
|
Method not calling of RestController of Spring mvc4 <p>I wrote Code for restful api but method is not calling,
getting error "Context Root Not Found".</p>
<p>I am using liberty profile</p>
<p>Here is a my code
Controller</p>
<pre><code>@RestController
public class demoAPIController {
@RequestMapping(value = "/r... | <p>Possible cause would be your liberty does not support servlet 3.0+. So you should do some tweaking according to spring recommends</p>
<blockquote>
<p>Spring Boot uses Servlet 3.0 APIs to initialize the ServletContext
(register Servlets etc.) so you canât use the same application out of
the box in a Servlet ... |
Many to many naming conventions <p>What I've understand so far is that many to many table naming conventions for Laravel are:</p>
<p><code>users & privileges = user_privilege</code></p>
<p>But what is the case with more complex names like:</p>
<p><code>attributes & composed_attributes = ?</code></p>
<p>As y... | <p>It will be <code>attribute_composed_attribute</code>.</p>
<blockquote>
<p>Name of the pivot table should consist of singular names of both tables, separated by undescore symbole and these names should be arranged in alphabetical order</p>
</blockquote>
<p><a href="http://laraveldaily.com/pivot-tables-and-many-to... |
How do javascript engine count number of tag of the HTML document is ill-formed? <p>From this question: <a href="https://stackoverflow.com/questions/40057381/finding-the-missing-sequence-number-in-a-file">Finding the missing sequence number in a file</a></p>
<p>The author gave this example:</p>
<pre><code><p>ha... | <blockquote>
<p>My question is how do javascript engine make that?</p>
</blockquote>
<p>It doesn't. By the time you're using JavaScript to access the resulting DOM document, the structural problems like unclosed tags have <em>already</em> been resolved by the browser's HTML parser. All that's happening in the line o... |
In which class I can write this function as per OOP standards? <p>I have Institute class and Branch class. Institute have multiple branches, so as per OOP standard, when I need branches of particular institute with function getBranches($institute_id), then in which class I need to write this function, In Institute or B... | <p>In General you should place getBranches in Institute class.</p>
<p>But depending on the case and the problem you are solving the implementation may vary.</p>
|
Recommended way to export variables in Node.js <p>I have a <code>worker.js</code> file which periodically updates the values of few variables.
In other files of my Node.js server I want to access to those vars.</p>
<p>I know how to export them, but it seems they are exported by value - i.e. they have the value they ha... | <p>A possible way to export them by reference is to actually manipulate the <code>module.exports</code> object - like so:</p>
<pre><code>//worker.js
module.exports.exportedVar = 1;
var byValueVar = 2;
setInterval(foo, 2000);
function foo() {
module.exports.exportedVar = 6;
x = 8;
}
//otherfile.js
var worker... |
What Kind of technology is this? <p>I have recently been awestruck by this Javascript based technology i saw on a webiste.
I just want to know how these guys are doing that. Are they using any frameworks or is it RAW JS or Jquery.</p>
<p>Please take a look at this - <a href="http://startit.select-themes.com/tech-busin... | <p>Take a look at this: <a href="https://github.com/VincentGarreau/particles.js/" rel="nofollow">https://github.com/VincentGarreau/particles.js/</a></p>
<p>The readme explains everything in detail.<br><br>
Basically you create a <code><div id="particles-js"></div></code> and you include the needed files li... |
How do I make a file inaccessible with Apache? <p>all!</p>
<p>First of all, a list of what software & frameworks I use:<br>
- XAMPP<br>
- Apache 2.4<br>
- Modal-view-controller (mvc) framework with Bootstrap/Twig/Altorouter/PSR4</p>
<p>I have a folder on my site, with a .json file which contains my da... | <p>Basically, you have to edit your htaccess file in the specified directory where settings.json is.</p>
<pre><code> <Files ~ "\.json">
Order allow,deny
Deny from all
</Files>
</code></pre>
<p>This would prevent any json file to be opened. make it as </p>
<pre><code><Files ~ "\settings.json">
Orde... |
setTransform () for SurfaceView <p>When recording via TextureView to the screen is not mirrored used setTransform () method:</p>
<pre><code>Matrix txform = new Matrix();
mTextureView.getTransform(txform);
txform.setScale((float) newWidth / viewWidth, (float) newHeight / viewHeight);
txform.postTranslate(xoff, yoff);
m... | <p>In order to mirror over Y axis use this:</p>
<pre><code>txform.setScale(-(float) newWidth / viewWidth, (float) newHeight / viewHeight, viewWidth / 2.f , 0);
</code></pre>
|
Import settings from the file <p>I would like to import settings from a yaml file, but make them available as regular variables in the current context.</p>
<p>for example I may have a file:</p>
<pre><code>param1: 12345
param2: test11
param3:
a: 4
b: 7
c: 9
</code></pre>
<p>And I would like to have vari... | <p>Even though the trick is great in @baldr's answer, I suggest moving the variable assignments out of the function for better readability. Having a function change its caller's context seems very hard to remember and maintain. So, </p>
<pre><code>import yaml
def get_settings(filename):
with open(filename, 'r') a... |
Cypher: All paths without loops <p>I have trouble to get all possible paths between to nodes without loops. I use neo4j 3.0.4. I prepared an example but first of all a short explanation. I have nodes from A to Z. These nodes can be connected in each way. I want to get all possible paths without loops, meaning a specifi... | <p>Your filter will fail out slightly faster if you change it to this:</p>
<pre><code>WHERE ALL(x IN NODES(path) WHERE SINGLE(y IN NODES(path) WHERE y = x))
</code></pre>
<p>But I don't believe you'll find a fundamentally more efficient way. Usually your options are pretty limited when your question contains the word... |
Adding space in an array in JavaScript <p>I am trying to make a hangman game. So I have a function that takes the word and makes a new array of the underscore dashes. I have that working perfectly but now I am trying to add the functionality of have spacing so multiply words. But now it adds random spaces instead. </p>... | <p>This spaces aren't random â they inverted.<br>It's because of you running your word from back to front:<br>
instead of <code>for (var i = word.length - 1; i >= 0; i--)</code> try it:</p>
<pre><code>function dash(word) {
var dash = [];
for (var i = 0; i < word.length; i++) {
if (word[i] ==... |
Autoplay youtube video on hover/mouseover <p>I am trying to play the youtube video for auto play when the iframe tag is on focus. Tried the following but it is not working. Error with my jquery?
I want to add &autoplay=1 to the src of iframe when it is focus.</p>
<p>Html :-</p>
<pre><code><div class="vid-wrap... | <p>Actually you don't really want to change the <code>src</code> attribute, but to use <a href="https://developers.google.com/youtube/iframe_api_reference" rel="nofollow">youtube's api</a> for that:</p>
<blockquote>
<p>The snippet will <strong>not</strong> work due to cross-origin problems (specifically in stackover... |
Webix Datatable onclick cannot get selected row data <p>I am putting together a webix UI for country data.<br><br> The working code is here: <a href="http://sahanaya.net/webix/flags3.html" rel="nofollow">http://sahanaya.net/webix/flags3.html</a><br><br>
I cannot get the datatable row data when clicked. I want to click ... | <p>You are required to get the selected item from its id and then access its data members directly. Hence, in the <strong>onItemClick</strong> function you can write as:</p>
<pre><code>onItemClick:function(id){
var item = this.getItem(id); //to get the selected item from its id
var country = item.data1; // to a... |
How to hide images based on src 301 redirect URL attribute? <p>I can hide all images with matching src attribute using a CSS3 attribute selector. For example:</p>
<pre><code>img[src*="photo_unavailable"] {
display: none;
}
</code></pre>
<p>will hide images with src containing "photo_unavailable".</p>
<p>However, wh... | <p>No, that is not possible. Because the <code>src</code> attribute correspond to the "broken" image link, not the "photo_unavailable" link.</p>
|
create new dataframe from missing values <p>Consider a vector x:</p>
<pre><code>x <- c(0, 5, 10, 25, 30)
</code></pre>
<p>I would like to create a new vector with "missing values," which means all the values that were "skipped" if I were to have a sequence with intervals of 5.</p>
<p>So for this example, the outp... | <p>If you need as a function, </p>
<pre><code>nats <- function(x, interval){
lastvalue <- x[length(x)]
firstvalue <-x[1]
xseq <- seq(firstvalue, lastvalue, interval)
xna <- xseq[!xseq %in% x]
return(xna)
}
x <- c(0,5,10, 15,25,30)
nats(x, 5)
#[1] 20
x <- c(3, 6,18)
nats(x, 3)
#[1]... |
How do convert an enum int value to a string in ionic template <p>I have a template in AngularJS that has the following content</p>
<pre><code><li>{{item.Day }},{{item.Time}},{{item.Notes}}</li>
</code></pre>
<p>Problem is that <code>item.Day</code> is an int from <code>0</code> to <code>6</code>, represe... | <p>Why don't You just use it like this, First create a array object for days in string like</p>
<p><code>$scope.days=['Sun','Mon','tue','Wed','Thur','Fri','Sat'];</code></p>
<p>Then in your template just use</p>
<pre><code><li>{{days[item.Day]}},{{item.Time}},{{item.Notes}}</li>
</code></pre>
<p>Thanks<... |
Google Maps: Unable to add auto search options in map contains marks from database <p>I am trying to add store markers from database in Google map, and auto search option to zoom the particular location.</p>
<p>I am able to add markers from database, but i am unable to add auto search options in map contains marks fro... | <p>As mentioned in <a href="https://developers.google.com/places/web-service/autocomplete#place_autocomplete_results" rel="nofollow">Place Autocomplete Results</a></p>
<blockquote>
<p>The Place Autocomplete response does not include the scope or alt_ids fields that you may see in search results or place details. Thi... |
Iterator which only ever yields a single value? <p>Some STL algorithms (and STL-like algorithms one could think up in other contexts) take their inputs via iterators. I sometimes find myself wanting to pass a (const) iterator as one of their inputs which just keeps yielding the same value (or const reference to the sa... | <p>Just create a class implementing a <a href="http://en.cppreference.com/w/cpp/concept/ForwardIterator" rel="nofollow">forward iterator interface</a>, and whose dereference operator returns your single value.</p>
|
Read text or number from mobile camera <p>I don't know if is it possible to read specific text from mobile camera with Javascript. </p>
<p>I'm trying to make an webapp which read a ISBN number from a book and then import it in a database. There are some websites which convert webapp into apk and I need it because I wa... | <blockquote>
<p>I don't know if is it possible to read specific text from mobile camera with Javascript.</p>
</blockquote>
<p>The first challenge you will have is to read the image from the mobile device camera, you can do that by using with multiple approaches, one of them is a simple</p>
<pre><code><input type... |
Starting new Activity after finish of several Async-Tasks <p>I tried to Download and Unzip files if there is an update on a server and all works perfect. But I want to open the next Activity only after all files have been downloaded and unzipped, not when it started downloading.</p>
<p>This is my Activity:</p>
<pre><... | <p>You are starting the new Activity whenever AsyncTaskRunner finishes executing its background job. AsyncTaskRunner is basically just launching multiple DownloadFileAsync tasks. </p>
<p>AsyncTaskRunner won't wait for the launched tasks to complete. It will just launch them and finish the task which causes your new Ac... |
How to prevent Emacs from scrolling with the mouse past the end of the buffer? <p>The default behavior is that Emacs keeps scrolling the last line to the center of the frame. How can I keep the last line at the bottom of the frame when I scroll using the mouse?</p>
| <pre class="lang-lisp prettyprint-override"><code>(setq scroll-conservatively 101)
</code></pre>
<p>Here is the information from the <code>*Help*</code> window produced by <code>describe-variable</code>:</p>
<pre><code>scroll-conservatively is a variable defined in `C source code'.
Its value is 101
Original value w... |
how to compare two different XML with all tags and show the difference? <p>Expected XML</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<bvoip:updateCustSiteDetailRe... | <p>There are 2 options</p>
<p>a) Use a library like XMLUnit , get the differences and ignore the namespaces and compare text values</p>
<p>b) Rollout a difference comparator of your own. If there only a specific tag you need to compare (and you do not want additional dependencies or JAXP) you can use this approach.</... |
Weird behaviour when running the script <p>I started to code a guess the number type of game. When I execute the program, it either flows perfectly, either doesn't work...</p>
<pre><code>import random
from random import randint
print("Welcome to guess the number!\nDo you want to play the game?")
question = input("")... | <p>You really need a while loop. If the first guess is too high then you get another chance, but it then only tests to see if it is too low or equal. If your guess is too low then your second chance has to be correct.</p>
<p>So you don't need to keep testing, you can simplify, but you should really do this at the desi... |
How to clear out commit history when submiting a PR on GitHub? <p>I'm new to Git. On GitHub, I forked a third-party project to make contributions to. Every time new PRs are merged to its master, I have to update my fork to stay current. On the home page of my forked repository, I click <code>New pull request</code>, sw... | <p>You shouldn't squash or use pull requests, instead add the remote for the original repo to your project and then you can rebase on top of their latest code.</p>
<pre><code> git remote add theirs https://www.github.com/original/project.git
git fetch theirs
</code></pre>
<p>Now in Visual Studio (or from the command... |
A protocol message was rejected because it was too big (more than 67108864 bytes) on mesos <p>Kmeans on spark by mesos
16/10/15 19:10:41 WARN TaskSetManager: Stage 54 contains a task of very large size (212070 KB). The maximum recommended task size is 100 KB.</p>
<pre><code>[Stage 54:>
... | <p>bin/spark-submit --name com.yonyou.ml.idfkmeans.SalesPurchasingKmeans --master mesos://zk://10.251.177.219:2181,10.163.122.93:2181,10.251.131.33:2181,10.174.236.104:2181,10.163.170.192:2181,10.164.14.172:2181/mesos --driver-cores 5.0 --driver-memory 30720M --class com.yonyou.ml.idfkmeans.SalesPurchasingKmeans --exec... |
Dictionary removing duplicate along with subtraction and addition of values <p>New to python here.
I would like to eliminate duplicate dictionary key into just one along with performing arithmetic such as adding/subtracting the values if duplicates are found.</p>
<p><strong>Current Code Output</strong></p>
<blockquo... | <p>Working with your current output as posted in the question, you can just <a href="https://docs.python.org/3/library/functions.html#zip" rel="nofollow"><code>zip</code></a> the different lists of tuples of items and quantities and prices to align the items with each other, add them up in two <code>defaultdicts</code>... |
How the relevant part of the report sent to relevant party using SSRS <p>Sales report should be sent to all the relevant department heads. Ex: Plastic department should
get only the plastic department sales while garment department should receive only its
department data. How to accomplish this requirement using SSRS?<... | <p>This is what I would to, and it is an easy approach. Plus, no Enterprise Edition needed for this.</p>
<p>Add a department parameter to the report, and make sure the data uses the parameter value to filter the results, whether that is done at the dataset level (filtering the data at the database level in the <code>W... |
How to change toolbar color on button click? <p>I have a app with a button and a Tool bar. I want to change the Tool bar color when button clicked.
I don't want to launch any other activity, I just want when user click button the color of my Toolbar get changes.</p>
| <p>Try this</p>
<p><code>getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorAccent)));</code></p>
<p>To change color of status bar you should add this code:</p>
<pre><code>if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
wind... |
Spring rest resource change path <p>I currently have a repository annotated with <code>@RepositoryRestResource</code>. I'm adding the following: </p>
<pre><code>@RestResource(path="make", rel = "make", description = @Description("Get vehicles by make"))
List<Vehicle> findByMake(@Param("make") String make);
</cod... | <p>Unfortunately it's not possible. I make some research in Spring Data Rest source code.</p>
<p>There are constants that uses for URI building in <a href="https://github.com/spring-projects/spring-data-rest/blob/master/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchControll... |
Complex JSON structure and databinding in NativeScript ListView <p>I have an interesting data set being returned from an API and I can't resolve the binding in the NativeScript listview for an object of objects within the parent binding context. The listview <code>items</code> (feeditems) is an ObservableArray(). Every... | <p>I don't see 'site_id' defined in the styles JSON. So probably just skipping the '[site_id]' part would be enough.</p>
<p>And one off-topic: please remove the <strong>StackLayouts</strong> you don't need them. </p>
|
How to add an Integer object, and an Object, in Java? <p>I have to add two objects, one of type Integer, and the other of type ArrayList(i). Here is the function I am working on, I will need to find the average of the array. The error I get is: error: bad operand types for binary operator '+', for the line 7 here. Tha... | <pre><code>import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Array<E> {
public static int brojDoProsek(ArrayList a){
//Code here...
double average = 0.0;
Integer sum = new Integer(0);
for(int i = 0; i < a.si... |
code igniter $this->form_validation->run() always returns false <pre><code> function form_submit (){
$this->load->library('form_validation');
$this->form_validation->set_rules('cname', 'Company Name', 'required');
$this->form_validation->set_rules('cpname', 'Conta... | <p>You missed the <code>method</code> attribute in form tag. It should be </p>
<pre><code><form id="form_sub" action="<?php echo site_url('controller/form_submit');?>" method="POST">
</code></pre>
|
ruby : shoes installed but hello world program doesn not work <p>I installed shoes gem but I can't use it:</p>
<pre><code>> gem install green_shoes
Successfully installed green_shoes-1.1.374 ... | <p>I recently reïnstalled green_shoes under Windows7 and Ruby 2.3.0 and had no difficulties, here the gdk versions that are used on my system.
Install them seperate while specifying this version.
Don't know if necessary here but it is always advisable to have the devkit in your path.</p>
<p>Versions:</p>
<pre><code>... |
Why won't my text align with my image? <p>I want my logo, my description text and my nav bar to all sit along the same line at the top of my site. They won't align and I can't for the life of my figure out why. They are all on the same line, but the description text is sitting lower than the rest. Padding and margins d... | <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.header:after {
content: '';
display: block;
clear: both;
}
#title {
float: left;
... |
cordova net::ERR_CACHE_MISS <p>i have an cordova pp
i am calling a post method in controller
it works in browser , but in build and debug apk i get the error </p>
<p>ionic.bundle.js:23826 POST <a href="http://somedomain.com/api/account/validation" rel="nofollow">http://somedomain.com/api/account/validation</a> net::... | <p>This Error means you don't have access to internet.There are two ways you can provide this access by changing these files</p>
<p><strong>1.AndroidManifest.xml</strong></p>
<p>add these following permission </p>
<pre><code><uses-permission android:name="android.permission.INTERNET" />
<uses-permission and... |
React Native Speech to Text <p>I am making a language app that records any new vocabulary a user is trying to learn. It would be great if users can add their words via a speech to text program, instead of having to enter it manually. I am having trouble achieving this task. I am aware that there is an API for apple but... | <p>You might wanna look at <a href="https://www.npmjs.com/package/react-native-android-voice" rel="nofollow">react-native-android-voice</a>, a React Native module that supports speech-to-text for Android. </p>
<p>Alternatively, you can always write your custom native module using Android's <a href="https://developer.a... |
C# Custom Attribute parameters <p>I saw this answer from this link <a href="http://stackoverflow.com/questions/270187/can-i-initialize-a-c-sharp-attribute-with-an-array-or-other-variable-number-of-a">Adding parameters to custom attributes</a> of how is to add parameters on Custom Attribute </p>
<pre><code>class MyCust... | <p>For <code>[MyCustomAttribute(3, 4, 5)]</code> the parameter list is unnamed, so the the constructor of <code>MyCustomAttribute</code> is used. </p>
<p>Therefore it does not matter, if there is a public <code>Values</code> properties.</p>
<p>In your first code sample it is acceptable to use <code>[MyCustomAttribute... |
member function pointer with variadic templates <p>I am trying to write a class that "manages" delegates in c++. I already have the delegate class implemented for me. I want this delegate manager class to have two functions:</p>
<ul>
<li><p>One would take a pointer to instance of a delegate of a certain type with a gi... | <p>One approach is to use partial specialization:</p>
<pre><code>template<typename> class DelegateManager;
template<typename FuncRetType,typename... FuncParams>
class DelegateManager<DelegateInfoPack<FuncRetType,FuncParams...>>
{
template<typename UserClass>
void BindDelegate(_Fu... |
DynamoDB global index on a field with small amount of distinct values <p>In official Amazon docs there's this text:</p>
<blockquote>
<p>For example, suppose you have an Employee table with attributes such
as Name, Title, Address, PhoneNumber, Salary, and PayLevel. Now
suppose that you had a global secondary inde... | <p>Its not really going to help. High cardinality is generally your goal when it comes to indexes in any database.</p>
<p>Consider also that this is their recommendation. Trust the documentation until you see something that conflicting in actual practice. </p>
|
How Can I sum up the column with decimal value in C# crystal report <p>Why is it not summing up. The datatype of totalamount due is decimal and When I insert a summary there is no sum in calculate summary. </p>
<p><a href="https://i.stack.imgur.com/JEdko.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/JEdko.jp... | <p>I did it when i created a formula and convert it to Number and then Create another formula where it will hold the sum</p>
|
TextView with setAutoLinkMask(Linkify.WEB_URLS) firing android.util.AndroidRuntimeException when tapping the link <p>I'm inflating views programatically and I need the links inside the <code>TextViews</code> to be clickable.</p>
<p>I'm doing it this way:</p>
<pre><code>((TextView) newView).setAutoLinkMask(Linkify.WEB... | <p>You probably passed the "wrong" context in your adapter. Here is a helpful article: <a href="https://possiblemobile.com/2013/06/context/" rel="nofollow">https://possiblemobile.com/2013/06/context/</a></p>
|
In what terms does new operator is considered harmful? <p>Factory pattern is supposed to be used when using new operator for creating object is considered harmful. In what terms does new operator is considered harmful</p>
| <p>The main reason you use factory pattern is that you don't need a lot of constructors for a object;</p>
<pre><code>public Person(int age, String firstName, String lastName);
public Person(int age, String firstName, String middleName, String lastName);
public Person(int age, String firstName, String lastName, String ... |
Restoring the exact angle from std::cos(angle) using std::acos <p>Is it guaranteed by the C++ standard that <code>angle == std::acos(std::cos(angle))</code> if <code>angle</code> is in the range [0, Pi], or in other words is it possible to restore the exact original value of <code>angle</code> from the result of <code>... | <p>Answer by StoryTeller:</p>
<blockquote>
<p>The standard cannot make that guarantee, simply because the result of <code>std::cos</code> may not be representable exactly by a <code>double</code>, so you get a truncation error, which will affect the result of <code>std::acos</code>.</p>
</blockquote>
|
using multiple redux stores one for each app user <p>in a react native app, i'm using redux. currently the whole app have single store and i use redux-persist to cache store to localstorage. </p>
<p>my app is username and password protected, you must create account to use it.</p>
<p>now i want to provide ability so t... | <p>I don't think having a store for each user is a good idea. See this SO answer: <a href="http://stackoverflow.com/a/33633850/3794660">http://stackoverflow.com/a/33633850/3794660</a></p>
<p>Why don't you namespace the data you have in your reducer by user id? Something like this:</p>
<pre><code>{
currentUserId: "1... |
Can't select added element <p>I faced this problem while doing some exercises. Can't select recently added button number two, and cant call alert method</p>
<pre><code>$('#but').click(function() {
$('#but').after('<button id="but2">Ðнопка 2</button');
});
$('#but2').click(function() {
alert('somethi... | <p>Your <code>htmlString</code> is lacking a <code>></code> on its closing tag:</p>
<pre><code>.after('<button id="but2">Ðнопка 2</button');
^
</code></pre>
<p>And use event delegation for dynamic elements:</p>
<pre><code>$(document).on('click','#but2',func... |
Why can yield be indexed? <p>I thought I could make my python (2.7.10) code simpler by directly accessing the index of a value passed to a generator via <code>send</code>, and was surprised the code ran. I then discovered an index applied to <code>yield</code> doesn't really do anything, nor does it throw an exception:... | <p>You are not indexing. You are yielding a list; the expression <code>yield[0]</code> is really just the same as the following (but without a variable):</p>
<pre><code>lst = [0]
yield lst
</code></pre>
<p>If you look at what <code>next()</code> returned you'd have gotten that list:</p>
<pre><code>>>> def g... |
How to save parts of linprog solutions <p>I am solving a serie of linear programing problems using linprog by indexing each problem in a for-loop:</p>
<pre><code>from scipy.optimize import linprog
for i in range(1,N):
sol[i] = linprog(coa3[N][0], A_ub = coa4[i], b_ub = chvneg[i], options= {"disp": True})
</c... | <p>Consider reading the <a href="http://docs.scipy.org/doc/scipy/reference/optimize.linprog-simplex.html" rel="nofollow">docs</a> as it's pretty clearly explained what exactly linprog returns.</p>
<p>The good thing is, that you are actually storing these values with your code already because you are storing the whole ... |
Python Indention Block? Why? <p>I have tried untabifying region.. and did not mix spaces/tabs.. What could be wrong here? When I run the module it traces to <code>if result["geo"]:</code> and says "There's an error in your program: expected an indention block"</p>
<pre><code>from twitter import *
import sys
import c... | <p>here is the problem :</p>
<pre><code>for result in query["statuses"]:
if result["geo"]:
date = result["created_at"]
</code></pre>
<p>python has specific syntax and it has to be considered
<br />
you have to change it to:</p>
<pre><code>for result in query["statuses"]:
if result["geo"]:
... |
How to use multiple values in between clause <p>Hi all is there any way that i can use multiple values in between clause as
column_name between 0 and 100 or 200 and 300 like this
Any help would be appreciated
here is my query <code>SELECT CASE WHEN ISNUMERIC(value_text) = 1 THEN CAST(value_text AS INT) ELSE -1 END) b... | <p>You can do this using <code>AND/OR</code> logic</p>
<pre><code>value_text NOT LIKE '%[^0-9]%' and
(
value_text between 0 and 100
Or
value_text between 101 and 200
)
</code></pre>
<p>If you don't want to repeat the column name then frame the range in table valued constructor and join with your table</p>
<pre><co... |
Flyway cannot connect to db after Heroku Postgres upgrade <p>I am upgrading my heroku database from a hobby dev to Standard 0 (using the official instructions <a href="https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases#upgrade-with-pg-copy-default" rel="nofollow">https://devcenter.heroku.com/arti... | <p>Looks like you aren't connecting with SSL where it is required by Heroku PostgreSQL installs.</p>
<p>See Herokus <a href="https://devcenter.heroku.com/articles/heroku-postgresql#external-connections-ingress" rel="nofollow">documentation on SSL for PostgreSQL</a>.</p>
<p>See also Herokus <a href="https://devcenter.... |
Slider - Active blur <p>I currently have this</p>
<p><a href="https://i.stack.imgur.com/AkAq7.png" rel="nofollow"><img src="https://i.stack.imgur.com/AkAq7.png" alt="enter image description here"></a></p>
<p>and I want it to look like </p>
<p><a href="https://i.stack.imgur.com/LYnsV.png" rel="nofollow"><img src="htt... | <p>You can probably do this using only one class instead of two by doing this :</p>
<pre><code>.image-fade {
-webkit-mask-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,1), rgba(0,0,0,0));
}
</code></pre>
<p>What I did is add more "anchor" points to the gradient, so that it's white in the two bord... |
Feature branching for mobile development <p>I use feature branching for my web projects, where, for each feature, I create a new branch and open a pull request when the feature is ready to be tested by other members of the team. </p>
<p>Using <a href="https://devcenter.heroku.com/articles/github-integration-review-app... | <p>I think you could use <a href="https://hockeyapp.net/" rel="nofollow">HockeyApp</a>. You can have different builds there (one for each feature for example), and the tester is able to choose what version to install.</p>
|
Where am I wrong in the loop? <p>It is supposed to print multiplication table of number 1-10. </p>
<pre><code><script>
//Multiplication table of 1 to 10;
var a=b=1;
for (a==1; a<=10; a++){
for(b==1; b<=10; b++){
document.write(a + "x" + b + "=" + (a*b) + "<... | <p>Change <code>a==1</code> and <code>b==1</code> to <code>a=1</code> and <code>b=1</code>. <code>==</code> is a comparison sign.</p>
|
Vertical LinearLayout, making the map shrink the more controls are added <p>I want to display a Google map and 2 controls below it.
How do I achieve this?! I tried it this way:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
an... | <p>Try this - </p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:layout_alignParentTop="true"
android:layout_above="@+id/con... |
String.split(String regex) Symbol avoidance <p>I have </p>
<pre><code>String text2 = "Samaras did something by Papandreou's government.";
</code></pre>
<p>When I use </p>
<pre><code>String[] w2 = text2.split("\\s+");
</code></pre>
<p>it takes the "Papandreou's" as a whole word (as its supposed to do). But how can I... | <pre><code>text2.split("(\\'s)?\\s+");
</code></pre>
<p>This regular expression splits the <strong><em>'s</em></strong> as optional, so it means either <strong>"Split 's follow with spaces"</strong> or <strong>"Split only spaces"</strong>.</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.