input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How to properly structure Firebase database to allow easy reading and removal <p>I am creating a recipe finding app and basically I have a "favorites" where if the user favorites a recipe, they will be able to easily access it in the favorites tab of the app. Basically this is my structure right now:</p>
<pre><code>ap... | <p>You might wanna consider making favourites as a <code>NSDictionary</code>:- </p>
<pre><code> app:
users:
2ReAGRZlYiV5F2piwMakz59XDzl1: //(uid)
favorites:
{172171 : true,
4123123 : true,..}
</code></pre>
<ul>
<li><p>For <strong>Appending</strong> in the favourites:- </p>
<pre><code> USERS_... |
Check if user is online in realtime <p>I want to check if a User is online at this moment. This should be shown on the users profile.</p>
<p>I got this in my <code>application_controller</code></p>
<pre><code>after_filter :user_activity
private
def user_activity
current_user.try :touch
end
</code></pre>
<p... | <p>The best way to do this would be using your client-side technology. The server can only know if a user has been active based on their last request to the server.</p>
<p>The user may be browsing around your app without a request being sent to the server, and would show as not online based on your time limit (even th... |
What's the purpose of the TPL ContinueWith method? <p>I'm confused about the TPL <code>ContinueWith</code> method. I don't understand why it's needed. <a href="https://msdn.microsoft.com/en-us/library/dd537612(v=vs.110).aspx" rel="nofollow">Here's an example from MSDN</a> that shows how to use <code>ContinueWith</cod... | <p>You're assuming that every single <code>Task</code> is just a synchronous method that's being run in a thread pool thread. That's just not the case, and you shouldn't think of tasks that way. A <code>Task</code> is some kind of work that will finish at some point, possibly generating a value as a result. It could... |
Alias in SAS/SQL is not working <p>This SAS/SQL query returns a table DS_Dbtr_Status with column names FACS_Schema_ID and DBACCT and not the aliases as given.</p>
<pre><code>proc sql outobs=10; **DS_Dbtr_Status**;
create table DS_Dbtr_Status as
select
FACS_Schema_ID as ID,
DBACCT as ACCOUNT_NUM,
... | <p>In SAS you can specify the label directly as a column modifier in the SELECT clause just by quoting it. The <code>label=</code> part of the modifier is optional:</p>
<pre><code> select
FACS_Schema_ID as ID 'ID',
DBACCT as ACCOUNT_NUM 'Account Number'
</code></pre>
<p>Using empty quotes will remove the ... |
How can I use PostgreSQL transactions in SailsJs? <p>My problem is that i have a complex chain of queries and it make rollback if someone of this transactions fail.
I've read about transactions in Sails and, for default, Sails don't support transactions because each transaction make a new connection with Postgres, so, ... | <p>Currently transactions are not supported by waterline. You can join the discussion here <a href="https://github.com/balderdashy/waterline/issues/755" rel="nofollow">https://github.com/balderdashy/waterline/issues/755</a>.</p>
<p>Transactions are on the roadmap but are not expected in near future: <a href="https://g... |
Is it possible to add a custom hover color to Raised Buttons? <p>Working on a project that is using the Material-UI library of components and I've gotten a request for a custom button hover color that is outside of the normal convention of the MUI theme.</p>
<p>I found this relevant block of code in the Raised Button ... | <p>I was able to solve it by giving a <code>className</code> prop to <code>RaisedButton</code> component and specifying <code>:hover</code> attribute in css with <code>!important</code> directive. </p>
<p>In your component:</p>
<pre><code>...
<RaisedButton className="my-button" />
...
</code></pre>
<p>In your ... |
Lower keyboard height on the menu, as in chat rooms, WeChat or viber ANDROID <p>Who can faced or tell me which way to look, the lower menu appears by pressing a button, the height equal to the height traveled keyboard.</p>
<p>As seen here:
<a href="http://i.stack.imgur.com/ZAtQh.jpg" rel="nofollow">http://i.stack.imgu... | <p>So you want to make the <code>View</code> the same height as the keyboard. Getting the keyboard height is not trivial, see <a href="https://stackoverflow.com/questions/16788959/is-there-any-way-in-android-to-get-the-height-of-virtual-keyboard-of-device">this question</a>. It will only work after the keyboard was ope... |
How register JacksonFeature on ClientConfig <p>How to give back JSON on resfull java project using jackson?</p>
<p>Following the article <a href="http://www.vogella.com/tutorials/REST/article.html" rel="nofollow">http://www.vogella.com/tutorials/REST/article.html</a> (8.4. Create a client ) about create rest project i... | <p>JacksonFeature in org.glassfish.jersey.jackson.JacksonFeature</p>
<p>Necessary. </p>
<pre><code>jersey-media-json-jackson-2.23.2.jar
jersey-entity-filtering-2.23.2.jar
</code></pre>
|
Butterknife 8.4.0 - Plugin with id 'android-apt' not found <p>I keep getting the error <code>Plugin with id 'android-apt' not found</code>. What's going wrong here?</p>
<pre><code>plugins {
id "me.tatarka.retrolambda" version "3.2.5"
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {... | <p>According to the <a href="https://github.com/JakeWharton/butterknife/blob/master/README.md" rel="nofollow">Butter Knife readme</a> you need</p>
<pre><code>buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
</code... |
Ignoring duplicate entry at table records 130045, No further warning will be generated in this table in lookup of datastage <p>when my datastage run i am seeing a warning as Ignoring duplicate entry at table record 130045,No further warning will be generated in this table,</p>
<p>so what is the number 130045 means and... | <p>These warnings are usually shown if you get duplicates from a reference link in a lookup. The problem is that in that case it might hit the wrong "duplicate". Make sure the reference data is duplicate free regarding your lookup key.
Otherwise provide more information about your job structure and stages used.</p>
|
How to create a m4v video using ffmpeg? <p>I'm trying to create a m4v video with the following command using ffmpeg:</p>
<pre><code>ffmpeg -loop 1 -i orange640x360.png -i Be+Present.mp3 -tune stillimage -shortest -c:v libx264 -c:a copy ./Be+Presentorange640x360.m4v
</code></pre>
<p>This is the error that I'm getting:... | <p>Since I was not sure I looked it up and yeah - FFmpeg considers <code>m4v</code> files to be a raw video stream container without any audio. From <a href="https://github.com/FFmpeg/FFmpeg/blob/9264bb7e79a50678eca6f320e1e1fb85bf00b009/libavformat/rawenc.c" rel="nofollow">rawenc.c</a> on github:</p>
<pre><code>#if CO... |
Google Tag Manager and sending data offline <p>I have a question to the following case. We want to track a content platform using google tag manager. However, not every time the platform is online but GTM would send data to our internal server. Therefore our concern is if data collected during this offline period will ... | <p>No, that is not how Google Tag Manager works. GTM for web is basically a javascript injection engine. It bundles your configured tags,triggers and variables with a selector engine and injects that into your page. There is no serverside component that stores data.</p>
<p>I'm sure one could come up with a solution to... |
Android Toolbar in webapp <p>I am developing a web app, and here I have a problem.</p>
<p>I have a tool bar(android widget toolbar) with logo and search button</p>
<p>As you can see I have the login page(webview). I want to user to see this search button after users login to the webpage. How should I do that?</p>
<p... | <p>If the search button is an Android <code>View</code>, you can hide it by calling <code>View.setVisibility(View.GONE)</code>.</p>
<p>If you have instead defined it as a <code>menu</code> XML resource and loaded it in this <code>Activity</code>, then just don't load the <code>menu</code> resource unless the user is l... |
How can i update the data within my app without having the user update the app in the playstore <p>I'm taking a break from simple game development to do something totally different. I would like to create an android/ios app (something like a news app and new technology app) that i can daily update the data in it withou... | <p>The best way to do this is to make the data available as a web service and have the app go fetch the data.</p>
|
Mongoose Updating Certain Fields of a Document <p>I'm trying to implement an update method for our API and I'm kinda new to the Node so I didn't know what would be the best practice to carry out the task of updating some fields of a document. Let me elaborate, we have a user model which keeps basic info of a user like ... | <p>The easiest approach what i can think of is to use $Set to perform the update operations.</p>
<p>an example would be :</p>
<pre><code>var updatedUsers= function(db, callback) {
db.collection('users').updateMany(
{ "_id": "value"},
{
$set: { bio: "new bio" }
}
,
function(err... |
Capture a websites objects in separate pcap files <p>A website usually consists of multiple objects (e.g. text file, a few png files etc.), I would like to know if there's a tool that can capture the individual requests/responses in different pcap files?</p>
<p>So for example if I browse to <a href="http://somewebsite... | <p>A HTTP connection can have multiple requests inside the same TCP connection and browsers make heavy use of this HTTP keep alive. With HTTP pipelining the requests/responses don't even need to be fully separated in time, i.e. a client can send another request even though the response for the previous one is not there... |
Ruby loop order? <p>I'm trying to bruteforce a password. As I was playing with some loops, I've noticed there's a specific order. Like, if I have <code>for i in '.'..'~'</code> it puts</p>
<pre><code>.
/
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_
`
a
b
c
d
e
f... | <p>The order is defined by the binary representation of the letters. Which, in turn, is defined by a standard. The standard used is ASCII (American Standard Code for Information Interchange).</p>
<p><a href="http://www.asciitable.com/" rel="nofollow">http://www.asciitable.com/</a></p>
<p>Other encoding standards exi... |
Making a non-serializable vendor class serializable <p>I am using a class from a vendor's DLL that is not XML serializable because one of the class members is an Interface.</p>
<p>However, I do need to serialize an instance of the class.</p>
<p>How can I tell the XmlSerializer to ignore the interface and serialize ev... | <p>You can do 2 things:</p>
<p>1) Create a class with every thing you want, populate it with the your vendor class, then you serialize it. </p>
<p>Check <a href="http://www.dofactory.com/net/adapter-design-pattern" rel="nofollow">adapter design pattern</a></p>
<p>2) Use Json.Net. Once I need to serialize the IPaged... |
Apache Reverse Proxy to a Wordpress site passes subpath when it shouldn't <p>I've been trying to set up a reverse proxy on a main website to a blog site of the url format</p>
<p>example.com/blog -> blog.example.com</p>
<p>example.com/blog is on an Apache instance and in the <code>httpd.conf</code> I have added the fo... | <p>I'm an idiot. I was using <code>ProxyPassMatch</code> instead of <code>ProxyPass</code>. Ugh.</p>
|
Type trait through a variable of the type <p>I'd like to test a property of the type of a variable. I do can it, but the code is too verbose.</p>
<p>Consider an example, in which I define a variable of the same type as the type of a value in a container:</p>
<pre><code>#include <vector>
int main() {
std::vec... | <p>Use some <em>using declarations</em>:</p>
<pre><code>using my_value_type = decltype(v)::value_type;
using your_value_type = std::remove_reference<decltype(rv)>::type::value_type;
</code></pre>
<p>Your code will become:</p>
<pre><code>int main() {
std::vector<int> v, &rv=v;
using my_value_... |
With Django Rest Framework, how can I grab the sub-objects of a specific entity? <p>If I want to, say, grab all of the questions of survey 5, a âRESTfulâ url for that would look something like â<a href="http://domain.com/api/survey/5/question/" rel="nofollow">http://domain.com/api/survey/5/question/</a>â. </p>... | <p>A co-worker just pointed me to this: <a href="https://github.com/alanjds/drf-nested-routers" rel="nofollow">https://github.com/alanjds/drf-nested-routers</a>, the existence of which hints that such functionality <em>isn't</em> (yet) built into DRF.</p>
<p>After testing around a little bit, and appears easy enough t... |
Ignore some directories in Git <p>I have in my git repository this path :</p>
<pre><code>pir-enio/src/main/java/at/ClientSide/com/audit/client
</code></pre>
<p>I want to ignore this part: </p>
<pre><code>src/main/java/at/ClientSide/
</code></pre>
<p>because my package is <code>com.audit.client</code>.</p>
<p>I am ... | <p>You can negate excludes like:</p>
<pre><code>pir-enio/*
!pir-enio/src/main/java/at/ClientSide/com/audit/client
</code></pre>
<p>But if You want it like this, then why You didn't started git repository in /com ?</p>
|
Different layouts for Login Page (one for login and other layout for others) in Angular 2 <p>I creating an angular 2 application. In my app.component I've got this</p>
<pre><code><header-component><header-component>
<router-outlet></router-ââoutlet>
</code></pre>
<p>with the router:</p>
<... | <p>You can remove the from you page. For your desired result to be achieved you can make all the components that should display the header-component as a child route of it.</p>
<p>You can achieve it like this:</p>
<pre><code>{ path: 'dashboard', component: HeaderComponent, children: [
{ path: '', component: Heade... |
Zebra ZQ 510 Mobile Printer compatible with Motorola MC32NO (Windows Embedded Compact 7.0) <p>Have problem to get connect with the new purchased Zebra ZQ 510 mobile printer from Motorola MC32N0 via bluetooth by using the following legacy code(referencing InTheHand.Net.Personal dll):</p>
<pre><code>using InTheHand.Net;... | <p>Finally find out a solution. Downloaded <strong>Motorola EMDK for .NET v2.9</strong>, and referenced <strong>Symbol.WPAN.dll</strong>. by using following code, managed to connect to the <strong>Zebra ZQ510 printer</strong>, and printed out label as expected. Don't forget to copy <strong>BTInterface.dll</strong> f... |
error using Python Elasticserarch-py package <p>So I am trying to create a connection to AWS ES. I have successfully connected to my S3 bucket in the same zone. However, when I try to connect to ES, I get this message every time.</p>
<pre><code>Please install requests to use RequestsHttpConnection.
</code></pre>
<p... | <p>As per the documentation for <a href="http://elasticsearch-py.readthedocs.io/en/master/transports.html" rel="nofollow">elasticsearch-py</a>.</p>
<blockquote>
<p>Note that the RequestsHttpConnection requires requests to be installed.</p>
</blockquote>
<p>There is a need to explictly install the <a href="http://do... |
Django model reload_from_db() vs. explicitly recalling from db <p>If I have an object retrieved from a model, for example:</p>
<pre><code>obj = Foo.objects.first()
</code></pre>
<p>I know that if I want to reference this object later and make sure that it has the current values from the database, I can call:</p>
<pr... | <p>Django sources are usually relatively easy to follow. If we look at the <a href="https://github.com/django/django/blob/master/django/db/models/base.py#L656" rel="nofollow">refresh_from_db() implementation</a>, at its core it is still using this same <code>Foo.objects.get(id=obj.id)</code> approach:</p>
<pre><code>... |
No GPIO controller on Raspberry Pi 3 with Windows 10 IoT <p>I recently got myself a Raspberry Pi 3 model B, and wanted to get my feet wet with Windows 10 IoT by following some of the tutorials from Microsoft (in this case, <a href="https://developer.microsoft.com/en-us/windows/iot/samples/kitblinky" rel="nofollow">Blin... | <p>My problem seems to have been related to Windows 10 IoT itself, after letting it update via the device portal, the GPIO works as outlined in the tutorial.</p>
|
Show/Hide DIV sections based on radio boxes <p>I'm trying to rework several forms and there are several sections where I have a typical "Was xxxx Required?" Yes/No radio boxes. If they choose YES I want the box below to open up requiring them to enter more info. I'd like to use one JQuery function if I could that would... | <p>Unclear what you mean.. if you have a div with the id of <code>Employee</code> and one for <code>Vendor</code> and add the vendor radio button.... the code works fine....</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="sni... |
Is there an official host uri for Gitlab API? <p>is it possible to use Gitlab API for official Gitlab Server? I mean <code>www.gitlab.com</code>. I can't find the host URI. Here is the api:
<a href="https://docs.gitlab.com/ce/api/" rel="nofollow">https://docs.gitlab.com/ce/api/</a></p>
| <p>While <a href="https://docs.gitlab.com/ce/api/" rel="nofollow">the documention</a> does mention <code>https://gitlab.example.com/api/v3/...</code>, you are still able to apply that API to gitlab.com itself.</p>
<p>You would use urls like <code>https://gitlab.com/api/v3/...</code> as described in <a href="https://gi... |
How to launch an F# console app from VS Code <p>Given a simple F# console app:</p>
<pre><code>[<EntryPoint>]
let main argv =
printfn "Hello world"
Console.ReadLine() |> ignore
0
</code></pre>
<p>What do I need to do to start the console app up in the same manner that ctrl F5 would do in Visual ... | <p>I would have preferred to comment but it would be too long, I consider this more of a workaround answer, as I'm not that familiar with Fake. My guess is that your Run Target is actually being executed but is probably being swallowed by AsyncExec or it just shows in the Fake output window (try Exec) but doesn't start... |
Logstash/Graylog won't write to ES with data node down <p>We ran into an issue where one of our Elasticsearch data nodes died completely in AWS. Even with a second node we had trouble getting the cluster back online. It originally came up in a <code>yellow</code> state and we could retrieve data but not write to it.<... | <p>The problem ended up being that we were using AWS discovery for the ES Cluster. Even though we removed the dead instance (still visible in AWS, just no accessible) from the security group we were using we did not restart all of the remaining ES nodes. Once we did this everything started working again.</p>
|
Android googlemap permission check, cannot resolve symbol <p>I got sample code from <a href="https://developers.google.com/maps/documentation/android-api/location?hl=en" rel="nofollow">https://developers.google.com/maps/documentation/android-api/location?hl=en</a></p>
<pre><code>if (ActivityCompat.checkSelfPermission(... | <p>You can do import manifest manually.</p>
<p>Put <code>import android.Manifest;</code>import part of activity.java</p>
|
Sending email using perl with sendmail <p>I am trying to send email using sendmail in perl. Email is sent but the content which I send as Subject gets added to 'To:' in the email. For example, if from address is <code>from@gmail.com</code>, To address is <code>to@gmail.com</code> and subject is <code>"test subject"</co... | <p>I am not sure what is wrong with what you show, but here is some working code</p>
<pre><code>my ($header, $From, $To, $Cc, $ReplyTo, $Subject);
$From = "From: $from";
$To = "To: $to";
$Cc = "Cc: $cc_addresses";
$ReplyTo = "Reply-To: $replyto";
$Subject = "Subject: $subj";
# Form the header. The fiel... |
SPARQL date filter query for RDF <p>I am querying using SPARQL, which works fine. But when I add a data filter it doesn't throw an error but also it doesn't do the filter. The final part is that I should be able to query between two dates:</p>
<pre><code>PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>... | <p>SPARQL FILTER works as a positive filter. If the expression is true for any match, then the match stands. Otherwise the match is discarded and there won't be any bindings for <code>?room</code> <code>?sender</code> and <code>?Firstday</code>. No error will be thrown as the query correctly returns no matches.</p>
|
MS Access duplicate values using SUM <p>I'm having trouble writing a query in Microsoft Access 2016 that will show the sum of an Expense for a particular event, the sum of the signs that event produced, along with the year, event description and company name.</p>
<p>I think I am missing something simple, and am going ... | <p>Consider splitting the query into two aggregations, one to sum <code>Signed</code> in Company_Target_Actual and the other to sum <code>Expense</code> in Business_Company_Expense. Then, join the two queries by Company, Event, and Year which are the grouping factors. </p>
<p>Below uses two derived tables (subqueries ... |
VB6: Grabbing String Starting with x From an Array <p>Let's say I have the following Array, <code>arr</code> that contains a <em>maximum</em> of 20 substrings. In this example, the array will have 4 substrings: </p>
<p><code>arr = {"AAAA: 1234567" , "BBBB: 2345678" , "CCCC: 98765432" , "DDDD: 87654321"}</code></p>
<... | <blockquote>
<p><strong>EDIT - FIX YOUR ARRAY LOAD</strong></p>
</blockquote>
<p><strong>Change this (it MUST give you an error!):</strong></p>
<pre><code>arr = {"AAAA: 1234567" , "BBBB: 2345678" , "CCCC: 98765432" , "DDDD: 87654321"}
</code></pre>
<p><strong>To This:</strong></p>
<pre><code>Dim arr As Variant
ar... |
Setting up a result backend (rpc) with Celery in Django <p>I am attempting to get a result backend working on my local machine for a project I'm working on but I am running into an issue.</p>
<p>Currently I am trying to create a queue system in order for my lab to create cases. This is to prevent duplicate sequence nu... | <p>If you want to keep your result, try this <a href="http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#keeping-results" rel="nofollow">Keeping Results</a></p>
<pre><code>app = Celery('proj', backend='amqp', broker='amqp://guest@localhost//')
</code></pre>
<h3>EDIT</h3>
<blockquote... |
Slow site...understanding google chrome network results <p>Im experiencing a really slow site. It takes a lot of time before the images on the frontpage shows up and i have a high load time. This is an image from the results from loading the frontpage with the network tab open. I should mention that this problem does n... | <p>1) you can create image style to reduce the image size
2) you can also use boots module to speed up site
3) or Please check your server response time if there is any issue persent</p>
|
Load Modal dialog by injecting HTML with JQuery <p>I have the following function on my JS file that has defined the HTML code for a Modal dialog that is defined in <a href="http://getbootstrap.com/2.3.2/javascript.html#modals" rel="nofollow">here</a></p>
<p>I've copied the HTML code and assigned into a variable on my ... | <p>The easiest way is to <code>append</code> modal <a href="http://api.jquery.com/append/" rel="nofollow">http://api.jquery.com/append/</a> to a particular DOM element(parent element).</p>
<pre><code>function loadModalDialog(p1) {
var modal = ....
$(parent_id).append(modal);
}
</code></pre>
<p><strong>UPDATED</st... |
python code not working after copied from windows to linux <p>I just wrote a small program in python, which is:</p>
<pre><code>#!/usr/bin/env python
print "hello"
</code></pre>
<p>It works in windows. And when I type this code in linux, it works, too.</p>
<p>But when I copy the python file from windows to linux in m... | <p>Perhaps you get an error because of different line endings on windows and linux? Windows uses "\r\n" and Linux just "\n". </p>
<p>You could write script that would get rid of "\r" on linux, for example:</p>
<p>EDIT: I have realized that carriage returns are seen only in binary mode. So script should do something l... |
How to structure two different headers with ui-router? <p>I'm doing some refactoring with Angularjs 1.4.2 and ui-router and I'm not sure what the proper architecture should be for the change. </p>
<p>Currently, we are using $state.go("main"); to call a main route
and all subsequent routes, which are separate componen... | <p><em>I ended up recreating this in Codepen. For whatever reason, I couldn't get either Plunkr nor JSFiddle to work properly.</em> </p>
<h1>Multiple Named Views</h1>
<p>UI Router allows you to set up multiple views in each state. You simple need to:</p>
<h3>1) Name the view in your template</h3>
<p>It's as easy... |
How to integrate a python program into a kivy app <p>I'm working on an app written in python with the kivy modules to develop a cross-platform app. Within this app I have a form which takes some numerical values. I would like these numerical values to be passed to another python program I've written, used to calculate ... | <p>As far as I understood you want the labels in your GridLayout in the last section of your code to get their texts from your python code. You could do something like this:</p>
<pre><code>from otherprogram import results1, results2, results3, results4
class ResultsScreen(Screen):
label1_text = results1
labe... |
How to use factorygirl to associate user_id <p>I am learning to do tests using Rails testing tools, mainly: <code>rspec, factory_girl, shoulda, and faker</code> gems.</p>
<p>I want to test <code>has_one</code> and <code>belongs_to</code> associations. I have <code>user.rb</code> (with <code>name</code>) and <code>addr... | <p>I think the way you build association is incorrect. See <a href="https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#associations" rel="nofollow">https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#associations</a>.</p>
<p>If you want a more specific associated user eg na... |
Install all JSPM dependencies in gulp task <p>I want to have one command to download all dependencies the project need. This should be a <code>gulp dependencies</code>. I have a JSPM dependencies in the fronted and I can install them by typing <code>jspm install</code> in the command line. I want to automate it with gu... | <p><code>jspm.install()</code> expects a package name as its first argument in order to install a specific package. If you want to install <strong>all</strong> packages you have to pass <code>true</code> (see <a href="https://github.com/jspm/jspm-cli/blob/master/docs/api.md#package-manager-api" rel="nofollow">the docs<... |
Does C++ support STL-compatible immutable record types? <p>A number of languages have support for immutable types â once you have constructed the value of such a type, it cannot be modified in any way. I won't digress into the benefits of such types, as this has been discussed extensively elsewhere. (See e.g. <a href... | <p>Remember that assignment in most other languages behaves like <em>pointer</em> reassignment in C++.</p>
<p>Thus, a <code>std::shared_ptr<const T></code> in C++ has similar semantics to immutable types in other languages.</p>
<pre><code>struct Coordinates {
double x;
double y;
};
std::shared_ptr<co... |
How to check for Object key in javascript for object not inheriting from Object.prototype <p>In node 6.x the <code>querystring</code> module parses values into an object that does not extend from <code>Object.prototype</code> (Although I have no idea why this change was made). </p>
<p>Given that, what is the expected ... | <p>Looks like you can use <code>Object.hasOwnProperty.call( this.query, "keyonly" )</code>. I set up a bit of a contrived test case and it appears to work:</p>
<pre><code>const querystring = require("querystring");
const qs = "keyonly&keyvalue=valuekey";
const result = querystring.decode(url);
console.log(Object... |
The Same instance of a list for all elements when using Select New List<> in linq to sql <p>The Same instance of a list for all elements when using Select New List<> in linq to sql</p>
<p>I recently ran across a very odd behavior that I would like some help clarifying. I have a workaround for the issue, but donâ... | <p>I raised a ticket with Microsoft and they confirmed this is expected behavior and not a bug.</p>
<p>What it boils down to is the following:</p>
<ol>
<li><p>Linq to Objects and Linq2SQL are completely different. Quote from the Linq2SQL dev - âFirst of all, linq2sql has nothing to do with linq to object. IQueryPro... |
changing background image multiple times with Javascript <p>Simply trying to cycle through 3 images by clicking on them.</p>
<p>Here is my code:</p>
<pre><code><script type="text/javascript">
function toggleImages(obj) {
if(obj.style.backgroundImage == "url('images/none.jpg')") {
obj.style.backgroundImage =... | <p>My javascript console prints <strong>url("images/none.jpg")</strong> with double quotes and you are checking with single, you must use something other to check it. One way (not so smart) is this:</p>
<pre><code> function toggleImages(obj) {
var tmp=obj.style.backgroundImage.replace(/url\(('|")/,'').replace(/(... |
rails 3 escaped html tags unescaped in browser when served as JSON <p>I have a Rails 3.2 app that interacts with a 3rd party XML API for some data using ActiveResource. We want to ensure against XSS in that 3rd party XML, so we have enabled:</p>
<pre><code>ActiveSupport.escape_html_entities_in_json = true
</code></p... | <p>If the string sent to the browser is like the one in the question, then it's not the browser converting it back, it's already sent unescaped. However, I don't think the server needs to encode it, as it's just data, sent in an intermediary data format which is JSON. It <em>is</em> correctly encoded for JSON. You have... |
NumberFormatException error while checking if JTextField is empty <p>I am getting a <code>NumberFormatException</code> error during runtime. The error is caused when checking if the <code>JTextField</code> is empty using an IF Statement.</p>
<pre><code> private void btnAddNumberMouseClicked(java.awt.event.MouseEven... | <p>Might want to change this:</p>
<pre><code>Integer.toString()
</code></pre>
<p>to something like this</p>
<pre><code>String.valueOf()
</code></pre>
<p>Or you could just append the integer in the textArea without casting it to String. </p>
<p>Also try to use the .isEmpty() method instead of .equals()</p>
|
how to pick second element starting from the last one? <p><a href="http://i.stack.imgur.com/ddm8U.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/ddm8U.jpg" alt="enter image description here"></a></p>
<p>I have two elements and they have the same class and I want to pick the second element starting from the la... | <p>you can use <code>nth-last-child(2)</code> or <code>nth-last-of-type(2)</code>, this will select the 2nd last item.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>li {... |
Rails backend 500 errors for old assets <p>When I deploy a new version on my server with new asset versions, I often see some 500 errors reported by amazon. In the logs, I see that those request seem to try to fetch old versions of assets (old asset digest)</p>
<blockquote>
<p>F, [2016-09-12T22:47:46.657377 #6663] F... | <p>Are these assets that you no longer have on your pages? If so - this can sometimes happen when eg google has cached an old copy of a page and then somebody (sometimes the google crawler) tries to look at it and fetch the assets from it... which no longer exists.</p>
<p>Normally you'd get a 404 for a missing asset, ... |
How to create a mutable array list containing immutable objects, Java <p>I have objects representing columns in a table that I want to declare as final. Some of these columns represent primary keys in my table, and for those columns I want to add them to an array list that gets passed into a function.</p>
<p>How can I... | <pre><code>public final class Column {
private final Integer a;
private final String b;
public Column(Integer a, String b) {
this.a = a;
this.b = b;
}
public Integer getA() {
return a;
}
public String getB() {
return b;
}
}
</code></pre>
<p>Create column class in this fashion and then add the obj... |
I have been learning python 3.5, and trying to get a string to reprint a user input variable? <pre><code>print ("how old are you??"),
age = input()
print("How tall are you"),
height = input()
print("How much do you weigh"),
weight = input()
print("So, you're '%r' old, '%r' tall and weigh '%r' ") % ('age, height weight... | <p>Don't put your variables in quotes. Instead of </p>
<pre><code>print("So, you're '%r' old, '%r' tall and weigh '%r' ") % ('age, height weight')
</code></pre>
<p>put</p>
<pre><code>print("So, you're '%r' old, '%r' tall and weigh '%r' " % (age, height weight))
</code></pre>
|
The first buttons work, the second do not <p>The first section works. When i press +, it works. Nothing works after the +. I press the plus and the second set of buttons appear, but pressing them does nothing. By the way, I am making a calculator.</p>
<pre><code><html>
<head>
<title>
JavaScript
</... | <p>The issue you had with your original solution was that the functions in the second calculator were in the private scope of the add() function, but the HTML <code><button></code>s are in the global scope, so there was no way for them to access the functions to add numbers to your 'second' variable.</p>
<p>Here... |
Using quotes within a javascript array and getting the result verbatim <p>So I have an array that looks like:</p>
<pre><code>var typeArray = [
"'<span class="class">Text</span>'",
"test",
]
</code></pre>
<p>and im calling the array in code that looks like this:</p>
<pre><code><script>
... | <p>Change <code>"'<span class="class">Text</span>'"</code> to <code>"<span class='class'>Text</span>"</code></p>
|
Alias template for reference type passed as template template argument in SFINAE context <p>I encountered the following problem with G++ 6.1.0 (<code>-std=c++14</code> switch) and I don't understand why the compiler rejects the code.</p>
<p>I have a helper struct <code>is_well_formed</code> which checks if a supplied ... | <p>It may be a compiler bug and user <a href="https://stackoverflow.com/questions/39460120/alias-template-for-reference-type-passed-as-template-template-argument-in-sfinae#comment66241640_39460120">T.C.</a> reported it on the GCC Bugzilla <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77575" rel="nofollow">here<... |
Build fails for Android Studio <p>This is the error I am getting:</p>
<pre><code>Error:Execution failed for task ':app:transformClassesWithPreJackPackagedLibrariesForDebug'.
> Failed to delete temporary file C:\Users\Jesse\AppData\Local\Temp\jill-1473722184552-0.jack
</code></pre>
<p>Gradle syncs, but no projects ... | <p>Might be a simple solution. Did you try File/Invalidate Caches / Restart... ?</p>
|
Scala Play Json JSResultException Validation Error <p>I am trying to pass this json string to my other method but SOMETIMES I get this error,</p>
<p>play.api.libs.json.JsResultException: JsResultException(errors:List((,List(ValidationError(error.expected.jsstring,WrappedArray())))))</p>
<p>I find it strange that this... | <p><code>(string \ "first_name")</code> gives <code>JsValue</code> not <code>JsString</code> so <code>as[String]</code> does not work.</p>
<p>But if you need <code>first name value</code> you can do </p>
<pre><code>val firstName = ((json \ "first_name") \ "value").as[String]
</code></pre>
|
How to show a localized exception message <p>I need to show the Exception message for a WCF service in a localized language, that is different from English. For example, if I run this instruction anywhere in my code:</p>
<pre><code>throw new ArgumentNullException(name, "El parámetro es obligatorio.");
</code></pre>
... | <p>If the language depends on the particular client, I'd create an overload of the functions of the service with an additional parameter for the language, and set both CurrentCulture and CurrentUICulture.</p>
<p>If the language does not depend on the client (i.e. same language for a whole site), set it somewhen during... |
How can a Tomcat webapp access its "maxthreads" parameter? <p>Our application accepts incoming requests (REST) and satisfies them using another of our services. When this application boots, it requests a number of connections from that other service - our goal is to maintain a 1:1, thread-to-connection, ratio (I won't ... | <p>I'll answer my own question - JMX / MBeans.</p>
|
Invalid Json web token in Go <p>I am trying to make a Json web token authentication system with Go however I cant seem to get the parsing of the web token working.
The error occurs in the following function.</p>
<pre><code>func RequireTokenAuthentication(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc... | <p>The error returned by <code>jwt.Parse()</code> says </p>
<blockquote>
<p>tokenstring should not contain 'bearer '</p>
</blockquote>
<p>So if you remove "Bearer ":</p>
<pre><code>jwtString = strings.Split(jwtString, "Bearer ")[1]
</code></pre>
<p>you get a bit further</p>
<blockquote>
<p>The token has been s... |
Java serve files to iOS video <p>I'm trying to get around a cross domain issue by proxying files from a java server to the web app. This works fine in most cases, but in iOS the video won't run. </p>
<p>It runs if the video comes straight from Amazon S3, but if I try and run it from a local server I get the 'media_err... | <p>Setting the Content Type manually</p>
<pre><code> video = document.createElement( 'video' );
source = document.createElement('source');
video.appendChild(source);
source.setAttribute('src',"/file/1.mp4");
source.setAttribute('type',"video/mp4");
</code></pre>
<p>Along with getting this multi-part servle... |
putting variables into vectors to be used in subsequent function (R) <p>i have a question regarding my second function which is not producing what i wanted to</p>
<pre><code>#example for mt-cars
selected_cyl_6 <- subset(mtcars, mtcars$cyl==6)
selected_cyl_4 <- subset(mtcars, mtcars$cyl==4)
count <- function(... | <p>If you're going to use quoted strings to refer to data and variables, we need to modify your two functions.</p>
<p>The main task is to redefine the <code>count</code> function so that it can handle your proposed inputs. We can use <code>eval</code> and <code>as.name</code> to do this.</p>
<h3>new count function</h... |
NSMutableDictionary objectForKey returns null with correct key <p>Im having a really weird problem with NSDictionary, take a look at the code and the console output and see for yourself.</p>
<pre><code>for (int y = 0; y < self.tileProperties.allKeys.count; ++y) {
//I go over all the keys in my NSDictionary,self.ti... | <p>The Answer with the help of JoshCaswell</p>
<pre><code>NSNumber *num = [NSNumber numberWithInt:496];
NSLog(@"Object in Array 2 %@",[self.tileProperties objectForKey:num]);
2016-09-12 18:14:43.217 GreatGrimBeta[1156:149732] LOOK {
fire = 7;
}
</code></pre>
|
intersection algorithm O(n) better way? <p>Let S1 and S2 be two sets of integers, such that |S1| = |S2| = n. </p>
<p>All the integers are obtained from the domain [1, 20n]. Give an algorithm to report all the integers in S1 â© S2 in O(n) worst-case time.</p>
<p>I'm confused, why have they given me the domain?
i kno... | <p>Your way works, but here is another way that I feel is a little less complicated than sorting and iterating. It follows your idea of count sorting, or radix sorting, but with a slight twist.</p>
<ol>
<li>Create an array of size 20n.</li>
<li>Iterate through your first and second set and increment each index that ma... |
RxJs: How to "listen" to change on a subscription when it receives a stream? <p>I'm new with Angular 2 and Observables, but I haven't found a way to "listen" to change on a subscription when it receives a stream, I don't even know if this is possible or if it's the right way.</p>
<p>This is what I used to do with prom... | <p>A <code>Subscription</code> is a listener, you can't listen to a listener, can you?</p>
<p>Instead, you need to return an <code>Observable</code> to be able to subscribe to. Change your function to be as follow (not tested):</p>
<pre><code>getItems(): Observable<any> {
let obs = this.itemService.getItems()... |
How to use same Partial for multiple resources? <p>I'm using tables to list recorded from database in index templates, And as usual the last three table cells are used for the links of Show, Edit and Destroy the Object.</p>
<p><strong>../users/index.html.erb</strong></p>
<pre><code><table>
...
<% @user... | <p>The lines causing errors are because you're trying to treat an object like a string.</p>
<p>Because the <code>_path</code> helpers are typically <code>snake_case</code>, you can use the <code>underscore</code> method on the object's class name like so:</p>
<pre><code><%= link_to send("edit_#{dist.class.name.und... |
How to make an overlay which capture no events <p>I would like to draw some sort of window on top of all the other windows. For example, to display some debugging infos (like conky) or things like a timer.</p>
<p>The main thing is that I would like to able to continue using the other windows while using it (the events... | <p>I think the Composite-extension-approach will not work when a compositing manager is running (and thus Composite's overlay window is already used).</p>
<p>Since you explicitly mention "no event capture":</p>
<p>The <a href="https://www.x.org/releases/X11R7.7/doc/xextproto/shape.html" rel="nofollow">SHAPE extension... |
Distinct Append in Select <blockquote>
<p>How will i distinct the value of select when i append. see the sample output below </p>
</blockquote>
<p><a href="http://i.stack.imgur.com/BmJ1o.png" rel="nofollow"><img src="http://i.stack.imgur.com/BmJ1o.png" alt="enter image description here"></a> </p>
<pre><code> $(d... | <p>Test each option to see if one exists that has a value that compares similarly and perhaps replace the value entered with the existing one (or visa versa)</p>
<p>You probably want to avoid using the text/label of an option as the value. if you don't decide to do that there's no point to setting all the values to "... |
Periodic spikes in CPU usage, possibly queue related? <p>I added a beanstalk queue to my application (running through <a href="https://laravel.com/docs/5.3/queues#supervisor-configuration" rel="nofollow">supervisor</a>).</p>
<p>I noticed that my CPU usage was periodically spiking:</p>
<p><a href="http://i.stack.imgur... | <p>The short answer is that it takes effort to load the relevant PHP files, and check the queue for new items, regardless of any work that is in the queue, which would be done.</p>
<p>Enabling Opcache to be used for command-line scripts, as well as faster versions of PHP, like v7, will help, as well as longer sleeps b... |
Git shortcut for checkout, pull, checkout, merge/rebase <p>Let's say I've got 2 branches, master and codyDev. Before I begin making changes on codyDev, I do the following in order to make sure I'm starting from the latest master commit on codyDev:</p>
<p><code>git checkout master</code><br>
<code>git pull</code><br>
<... | <p>You can update your <code>codyDev</code> branch with the latest changes from <code>master</code> without actually changing branches:</p>
<pre><code>git checkout codyDev # ignore if already on codyDev
git fetch origin # updates tracking branches, including origin/master
git merge origin/master # merg... |
F# sum of a list of lists <p>I created my own datatype And I'm trying to create the sum of all the numbers in that datatype which is a list of lists. I don't want to use any F# libraries</p>
<p>My datatype</p>
<pre><code>type elist = A | L of int * elist
</code></pre>
<p>I'm a beginner in F# and trying to grasp my ... | <p>You're nearly there. All you need is to lose the <code>a</code>:</p>
<pre><code>let rec sum l =
match l with
| A -> 0
| L(head,A) -> head
| L(head,tail) -> head + sum tail
</code></pre>
<p>Then evaluating <code>sum l</code> when <code>l = L(4, L(3, L(6, L(3, A))))</code> gives</p>
<pre><cod... |
algorithm to find the median value from an array with an odd number of elements <p>I would like to know if there exists an algorithm to find the median of an array of odd length. Obviously one could just sort the array and take the middle but ideally by only being interested in the median one could make gains in terms ... | <p>This is solved by a <a href="https://en.wikipedia.org/wiki/Selection_algorithm" rel="nofollow">selection algorithm</a>, and can be done in <code>O(n)</code> time. <a href="https://en.wikipedia.org/wiki/Quickselect" rel="nofollow">Quickselect</a>, or its refinement introselect, are popular methods.</p>
<p>A very bri... |
Setting height for UITableViewCell with UIWebView inside <p>I have a <code>UIWebView</code> inside my custom <code>UITableViewCells</code>. The problem is that I don't quite know how to dynamically size my <code>UITableViewCell</code> cells since the webview inside the cell needs to render before I can know the webview... | <p>remove :</p>
<pre><code>[self.tableView beginUpdates];
[self.tableView endUpdates];
</code></pre>
<p>add :</p>
<pre><code>[self.tableView reloadData];
</code></pre>
<p><br/>
<br/><br/>
This is Apple Documents:
<br/>
<a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/... |
Javascript variable String to Array(Json, Object) <p>I'm trying to use Javascript variable String to Array.</p>
<p>But I got below console error:</p>
<p><a href="http://i.stack.imgur.com/emaRQ.png" rel="nofollow"><img src="http://i.stack.imgur.com/emaRQ.png" alt="enter image description here"></a></p>
<p>This is my ... | <p>In JSON, strings need to be enclosed in double-quotes. You are using single-quotes.</p>
|
angular 2 Do we need avoid two way databind when not necessary? <p>I search a lot to understand if there is some bad performance if I use two way databind (ng-model) all times at my forms instead of one way databind.
I know that with angular 1 for each two way databind a new watch is created and with huge applications ... | <p><a href="https://yakovfain.com/2015/12/29/two-way-data-binding-in-angular-2/" rel="nofollow">https://yakovfain.com/2015/12/29/two-way-data-binding-in-angular-2/</a></p>
<p>There are instances where 2-way data binding is best practice but specifically when you need real-time 2 way UI updates and other uncommon occur... |
How to run a Powershell DSC script locally <p>I'm trying to run a very simple Powershell DSC script locally. (I never plan on pulling or pushing configuration files at this stage)</p>
<p>I get the following error message. The WS-Management service is running, but there are no firewall holes or ports reserved (server h... | <p>Try:</p>
<pre>
configuration SampleIISInstall
{
Node "localhost"
{
File FileDemo {
Type = 'Directory'
DestinationPath = 'C:\TestUser3'
Ensure = "Present"
}
}
}
# Compile the configuration file to a MOF format
SampleIISIns... |
Can't multiple insert using openrowset <p>I already searched a couple of times. Some post are related but still can't help me on this problem.</p>
<p>Here are the sample items of my items.txt. I checked the .txt file and there is absolutely no white space, etc.</p>
<pre><code>0000100000
7005432111
4545213695
45452136... | <pre><code>My Text File Data(Store ProcessId) :-
21
22
23
24
CREATE TABLE temp ( ProcessId VARCHAR(2000) ) ;
BULK INSERT dbo.temp
FROM 'D:\items.txt'
WITH
(
CODEPAGE = '1252',
FIELDTERMINATOR = ';',
CHECK_CONSTRAINTS
)
SELECT *
FROM temp
INNER JOIN dbo.Process_Master ... |
Python parse SQL and find relationships <p>I've got a large list of SQL queries all in strings, they've been written for <a href="http://prestodb.io" rel="nofollow">Presto</a>, so kinda formatted for MySQL.</p>
<p>I want to be able to tease out the table relationships written in some queries. </p>
<p>Let's start with... | <p>With some minor changes to the select_parser.py (<a href="https://sourceforge.net/p/pyparsing/code/HEAD/tree/trunk/src/examples/select_parser.py" rel="nofollow">https://sourceforge.net/p/pyparsing/code/HEAD/tree/trunk/src/examples/select_parser.py</a>) that is part of the pyparsing examples, I get this after parsing... |
System.Data.SqlClient.SqlException: Invalid object name 'dbo.__TransactionHistory' <p>I get the error </p>
<blockquote>
<p>"System.Data.SqlClient.SqlException: Invalid object name
'dbo.__TransactionHistory'."</p>
</blockquote>
<p>when I try creating a <code>new dbcontext</code> using the <code>TransactionContext<... | <p>I ended up doing two things.</p>
<ol>
<li>Manually run the SQL <pre><code> CREATE TABLE [dbo].[__TransactionHistory] (
[Id] [uniqueidentifier] NOT NULL,
[CreationTime] [datetime] NOT NULL,
CONSTRAINT [PK_dbo.__TransactionHistory] PRIMARY KEY ([Id]) </code></pre></li>
<li>Creating a CommitFailureHandler that overrid... |
Cannot auto-complete c++ in vs code <p>Hey I recently started using vs code and am having a really weird issue. where my code won't auto complete. I have installed the c/c++ extension and have the "c_cpp_properties.json" file containning the following</p>
<pre><code>{
"configurations": [
{
"nam... | <p>This seems to be a limitation (or bug?) of VSCode's code completion feature. The Vulkan header wraps the typdefs for all handles (like VkInstance, VkFence, etc.) in a Macro and it looks like VSCode can't handle this.</p>
<p>E.g. this:</p>
<blockquote>
<p>VK_DEFINE_HANDLE(VkInstance)</p>
</blockquote>
<p>Won't a... |
TCP TIME_WAIT Assassination <p><strong>I just looked up the <a href="https://tools.ietf.org/html/rfc1337" rel="nofollow">RFC1337</a> about TIME_WAIT Assassination and this is a portion of it.</strong></p>
<blockquote>
<p>Figure 1 shows an example of TIME-WAIT assassination. Segments 1-5<br>
are copied exactly fro... | <p>RFC 793 states in 'Reset generation':</p>
<blockquote>
<ol start="3">
<li>If the connection is in a synchronized state (ESTABLISHED,
FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT),
any unacceptable segment (out of window sequence number or
unacceptible acknowledgment number) must elicit... |
setuid program doesn't work on 2.6 kernel <p>I am having trouble understanding why my setuid program doesn't seem like it is actually elevating permissions, even though the id's seem correct. This is running on a 2.6 kernel and fails, but works exactly as intended on Ubuntu 14.04 doing the same thing. I need a program ... | <p>Calling your program under strace caused the setuid bit to be ignored.</p>
<p>You tried to run setuid binaries with ruid == calling user's Id. This does not work very well; however this does not seem to be your main problem either.</p>
<p>Don't <em>ever</em> call system() from a setuid program else somebody does <... |
How to pass variable (Alias) into where condition SQL <p>Goodday to all,</p>
<p>I want pass 'coalesce(MDT.DeptName,DD5.Name) as <strong>departname</strong>' into where condition. Now the error shows invalid column. Any possibilties ?
below is my code:</p>
<pre><code>SELECT op_id,
DD.NAME ... | <p>You cannot use <code>Alias</code> name in <code>Where</code> clause. Use the original columns </p>
<pre class="lang-sql prettyprint-override"><code>WHERE COALESCE(MDT.deptname, DD5.NAME) = ''
AND isactive = 0
AND isverifed = 1
</code></pre>
<p>This is how a query is logically processed </p>
<pre... |
Scale an image ,keeping aspect ratio without being cropped-android app <p>I take the photo from gallery and I display it on another activity in image view . Everything it's fine except when the photo is displayed. I want the photo to be displayed in the exact same size like the image view keeping the aspect ratio and ... | <p>Are you aware of the available attribute, "scaleType?"</p>
<pre><code><com.example.ga.photoeditor.ScaleImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="320dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="tr... |
How to make Spring Cloud Consul register with external IP? <p>How to make Spring Cloud Consul register with external IP?</p>
<p>I run spring boot applications with spring cloud consul in docker.
The application is running inside a docker network on a docker swarm.</p>
<p>This means that if spring consul registers wit... | <p>You can set <code>spring.cloud.consul.discovery.ipAddress</code> externally and set the property <code>spring.cloud.consul.discovery.preferIpAddress=true</code>.</p>
<p>Alternatively, you can <a href="https://github.com/spring-cloud/spring-cloud-commons/blob/master/docs/src/main/asciidoc/spring-cloud-commons.adoc#i... |
Using directive for basic types like C++ typedef <p>I[m trying to mimic a C++ typedef on C# using the using clause:</p>
<pre><code>using MyString = System.String;
using MyInt = System.Int32;
using MyBool = System.Boolean;
using MyFloat = float;
</code></pre>
<p>It works for all types, except for the float type, as it... | <pre><code>using MyFloat = System.Single;
</code></pre>
<p>References:</p>
<ul>
<li><a href="https://msdn.microsoft.com/en-us/library/ya5y69ds" rel="nofollow">MSDN - Built-In Types Table (C# Reference)</a></li>
</ul>
|
AngularJs controller value doesn't update after factory resolve <p>I'm trying to build a user page where it shows it's main data, details, address, etc.. When I make the first load, it doesn't show on the screen until I change the page and go back to the user page. It's problaby because of the promise return after I al... | <p>The way I could solve this problem, was to create a single object with nested arrays in the factory, instead of creating multiple arrays. Also, in the controller, I can't set the specific array direct to the vm, I need to set the array inside the object, this way it's automatically updated.</p>
<pre><code>//Factory... |
PHP Curl site is responding javascript not enabled. How does it know? <pre><code>$curl = curl_init("http://example.com/");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Host: example.com",
... | <p>To my knowledge, the mininum of 2 requests is needed to know if a client has JavaScript enabled or not.
Since this is CURL, and can be setup as an "original" request the response would not make any sense unless that website checks request headers like a <strong>hound dog</strong>.</p>
<p>As @zerkms mentioned, chrom... |
fprintf outputs 0x08 when printing backspace <p>When trying to print a backspace <code>("\b \b")</code> to a file (in <code>C</code>), it would show up as an unicode character (0x08).</p>
<p>Does this have to do with the format of the file I am printing to or the emulation of the terminal?</p>
<p><img src="http://i.s... | <p>If you are trying to delete characters from an existing file, you should use fseek. printing '\b' won't help. </p>
|
Relational Division: Exact Division <p>I came across the following problem: </p>
<blockquote>
<p>Write a query to find any users with exactly the same friends as another user U. </p>
</blockquote>
<p>Here are the tables (and a SQL Fiddle: <a href="http://sqlfiddle.com/#!9/457260/1" rel="nofollow">http://sqlfiddle.c... | <p>The simplest way is to aggregate the friends and then do the comparison:</p>
<pre><code>with f as (
select user_id, array_agg(friend_id order by friend_id) as friends
from friendships f
group by user_id
)
select user_id
from f
where f.friends = (select friends from f where user_id = 1) and
... |
how to compare values in array in while loop <p>My while loop condition looks like this:</p>
<pre><code>while ($currentmodif <= $lastmodif)
{
.....thing to be done
}
</code></pre>
<p>Now instead of comparing between two values, I compare between array and a string. </p>
<p>The array look like this:</p>
<pre><co... | <p>To expand on @siddhesh's comment, foreach will loop through your array just fine. </p>
<pre><code>foreach($yourarray as $item) {
if($item['time'] <= $lastmodif) {
// do your work
}
}
</code></pre>
<p>This loop goes through your array and giving you a copy of each item.
If you want to <em>modify</em> th... |
Detecting centers of circles from camera images <p>So I'm developing an Ionic app that uses the phone camera to detect circles on fabric, like the picture below:
<a href="http://i.stack.imgur.com/iIb2m.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/iIb2m.jpg" alt="enter image description here"></a></p>
<p>Wher... | <p>You can use Image Segmentation with Watershed Algorithm which described in
<a href="http://docs.opencv.org/3.1.0/d3/db4/tutorial_py_watershed.html" rel="nofollow">here</a> </p>
|
How to handle the Leave/Stay browser dialog in selenium webdriver <p><a href="http://i.stack.imgur.com/NRJRa.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/NRJRa.jpg" alt="enter image description here"></a></p>
<p>I am not able to handle this browser dialog in my selenium c# code. The switchTo().alert doesn't ... | <p><a href="http://stackoverflow.com/questions/6852732/selenium-webdriver-how-to-close-browser-popup">Read This</a></p>
<p>or </p>
<p>You can try <a href="https://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress(v=vs.110).aspx" rel="nofollow">keyboard event</a> as well</p>
<pre><code>public eve... |
how to exclude some list properties to make data table <p>In below utility function (list to Data Table), how can I exclude some member of list.</p>
<p>Like, I don't want to send the 2 properties "UniqueKey" & "PointToPointData" to the utility method below,</p>
<pre><code>public class PointDataClone
{
public ... | <p>create an attribute</p>
<pre><code>[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
public class DontShowMe : Attribute
{
}
</code></pre>
<p>You can then use the attribute to annotate your class</p>
<pre><code>public... |
Connecting to Azure SQL with Python <p>I am trying to connect to a SQL Database hosted in Windows Azure through MySQLdb with Python. </p>
<p>I keep getting an error mysql_exceptions.OperationalError: (2001, 'Bad connection string.')</p>
<p>This information works when connecting through .NET (vb, C#) but I am definite... | <p>@Kyle Moffat, what OS are you on? Here is how you can use pyodbc on Linux and Windows:
<a href="https://msdn.microsoft.com/en-us/library/mt763261(v=sql.1).aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/mt763261(v=sql.1).aspx</a></p>
<p><strong>Windows:</strong></p>
<ul>
<li>Download and install Pyth... |
Android Realm Update Asynchronously Using RxJava <p>I have this query to update data already in my realm table;</p>
<pre><code>for (MyGameEntrySquad squad : response.body().getSquad()) {
subscription = realm.where(RealmPlayer.class).equalTo("id", squad.getPlayer().getId())
.findFirstAsy... | <pre><code>realm.where(RealmPlayer.class).equalTo("id", squad.getPlayer().getId())
.findFirstAsync()
.<RealmPlayer>asObservable()
.subscribe(new Action1<RealmPlayer>() {
@Override
... |
How to remove plain text from a string after using strip_tags() <p>So i have a string and I used the <code>strip_tags()</code> function to remove all tags except IMG but I still have plain text next to my IMG element. Here a visual example</p>
<pre><code>$myvariable = "This text needs to be removed<a href='blah_bla... | <p>Instead of replacing something you can very well extract the values you want:</p>
<pre><code>(<(\w+).+</\2>)
</code></pre>
<p>To be used with <code>preg_match()</code>, see <a href="https://regex101.com/r/mO9gM6/1" rel="nofollow"><strong>a demo on regex101.com</strong></a>.<br>
IN <code>PHP</code>:</p>
<... |
Google Docs preview does not show S3 Signed URL <p>I have embedded Google Docs preview in my Rails application. While using AWS S3 signed URL, it does not generate preview. How can I solve this problem?</p>
<p>Example</p>
<pre><code><iframe src="http://docs.google.com/gview?embedded=true&amp;url=https://d2qvdh... | <p>I think the s3/cloudfront url does not encoded. Try with encoded url.</p>
<p>the url should be <code>https%3A%2F%2Fd2qvdh0r9424ok.cloudfront.net%2Fmallow-tech%2Fattachments%2F1%2Foriginal%2Flogo-page.png%3F1473416934</code> instead of <code>https://d2qvdh0r9424ok.cloudfront.net/mallow-tech/attachments/1/original/lo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.