title
stringlengths 15
150
| body
stringlengths 38
32.9k
| label
int64 0
3
|
---|---|---|
Chat App using GCM, PHP & MySQL | <p>I am following this tutorial </p>
<p><a href="http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-1" rel="nofollow noreferrer">Part-1</a></p>
<p><a href="http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-2/" rel="nofollow noreferrer">Part -2</a></p>
<p>part-1 has been done sucessfully and but in part -2 when i deploy app im my mobile then i am not getting any <strong>gcm registration token</strong> in toast and neither in logcat.
As i have searched that due to my config.php file i am using ip s=address instead of hostname i had to change my link <strong>from this</strong>
<a href="http://live_host_ip_address/gcm_chat/v1/user/login" rel="nofollow noreferrer">http://live_host_ip_address/gcm_chat/v1/user/login</a> ---->
<strong>to this</strong>
<a href="http://live_host_ip_address/gcm_chat/v1/index.php/user/login" rel="nofollow noreferrer">http://live_host_ip_address/gcm_chat/v1/index.php/user/login</a> </p>
<p>on using <strong>Postman Chrome REST API</strong> with this link-<a href="http://live_host_ip_address/gcm_chat/v1/user/login" rel="nofollow noreferrer">http://live_host_ip_address/gcm_chat/v1/user/login</a> it was not working but on changing the link to <a href="http://live_host_ip_address/gcm_chat/v1/index.php/user/login" rel="nofollow noreferrer">http://live_host_ip_address/gcm_chat/v1/index.php/user/login</a> the link begaun to work properly.</p>
<p><strong>On testing its showing volley error:null</strong></p>
<p><a href="https://i.stack.imgur.com/pTRjN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pTRjN.png" alt="enter image description here"></a></p>
<p><strong>and in Logcat its showing</strong></p>
<pre><code>23676-24548/info.androidhive.gcm E/LoginActivity﹕ params: {[email protected], name=abc}
23676-24548/info.androidhive.gcm E/LoginActivity﹕ params: {[email protected], name=abc}
23676-23676/info.androidhive.gcm E/LoginActivity﹕ Volley error: null, code: null
23676-23676/info.androidhive.gcm D/Volley﹕ [1] Request.finish: 7764 ms: [ ] http://live_ip_address/gcm_chat/v1/user/login 0x44e0acb1 NORMAL 7
</code></pre>
<p><strong>I think the problem lies in that i am using <a href="http://live_host_ip_address/gcm_chat/v1/index.php/user/login" rel="nofollow noreferrer">http://live_host_ip_address/gcm_chat/v1/index.php/user/login</a> from the Postman Chrome REST API but in logcat its showing <a href="http://live_host_ip_address/gcm_chat/v1/user/login" rel="nofollow noreferrer">http://live_host_ip_address/gcm_chat/v1/user/login</a></strong></p> | 2 |
Most standard way to create single page application with Django | <p>I just started working with Django today, and am a little lost in the docs at the moment.</p>
<p>I'd like to create a single page application. I'd like the server to return a single index.html for any request that doesn't match "/api/*".</p>
<p>Can somebody show me what the most standard/accepted way to do this with Django would be? I spent a bit of time trying to Google for similar projects, but didn't have any luck so far.</p> | 2 |
How to programmatically add an active graphics layer to a map? | <p>I'm writing a WPF applicating, in C#, using ArcObjects.</p>
<p>I have an ESRI.ArcGIS.Controls.AxMapControl on my form, and I'm trying to draw some graphics elements on top of it.</p>
<p>The map I'm developing with is a customer-provided mdf of the state of Georgia.</p>
<p>I'm trying an example I found here: <a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000001rv000000" rel="nofollow">How to interact with map elements</a>.</p>
<pre><code>public void AddTextElement(IMap map, double x, double y)
{
IGraphicsContainer graphicsContainer = map as IGraphicsContainer;
IElement element = new TextElementClass();
ITextElement textElement = element as ITextElement;
//Create a point as the shape of the element.
IPoint point = new PointClass();
point.X = x;
point.Y = y;
element.Geometry = point;
textElement.Text = "Hello World";
graphicsContainer.AddElement(element, 0);
//Flag the new text to invalidate.
IActiveView activeView = map as IActiveView;
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
</code></pre>
<p>It took while to figure out how to project the lat/long of Atlanta to the coordinate system of the map, but I'm pretty sure that I've got it right. The x/y values I'm passing into AddTextElement() are clearly within the Atlanta area, according to the Location data I see when I use the Identify tool on the map.</p>
<p>But I'm not seeing the text. Everything seems to be working correctly, but I'm not seeing the text.</p>
<p>I can see a number of possibilities:</p>
<ul>
<li>The layer I'm adding the TextElement to isn't visible, or doesn't exist.</li>
<li>I need to apply a spatial reference system to the point I'm setting as the TextElement's geometry</li>
<li>The text is drawing fine, but there's something wrong with the font - it's invisibly small, or in a transparent color, etc.</li>
</ul>
<p>Haven't a clue, which.</p>
<p>I was hoping there was something obvious I was missing.</p>
<p>===</p>
<p>As I've continued to play with this, since my original posting, I've discovered that the problem is the scaling - the text is showing up where it should, only unreadably small.</p>
<p>This is what Rich Wawrzonek had suggested.</p>
<p>If I set a TextSymbol class, with a specified Size, the size does apply, and I see me text larger or smaller. Unfortunately, the text still resizes as the map zooms in and out, and my trying to set ScaleText = false doesn't fix it.</p>
<p>My latest attempt:</p>
<pre><code>public void AddTextElement(IMap map, double x, double y, string text)
{
var textElement = new TextElementClass
{
Geometry = new PointClass() { X = x, Y = y },
Text = text,
ScaleText = false,
Symbol = new TextSymbolClass {Size = 25000}
};
(map as IGraphicsContainer)?.AddElement(textElement, 0);
(map as IActiveView)?.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
</code></pre>
<p>I recognize that the above is organized very differently than the way is usually done with ESRI sample code. I find the way ESRI does it to be every difficult to read, but switch from one to another is pretty mechanical.</p>
<p>This is the same function, organized in a more traditional manner. The behavior should be identical, and I'm seeing exactly the same behavior - the text is drawn to a specified size, but scales as the map zooms.</p>
<pre><code>public void AddTextElement(IMap map, double x, double y, string text)
{
IPoint point = new PointClass();
point.X = x;
point.Y = y;
ITextSymbol textSymbol = new TextSymbolClass();
textSymbol.Size = 25000;
var textElement = new TextElementClass();
textElement.Geometry = point;
textElement.Text = text;
textElement.ScaleText = false;
textElement.Symbol = textSymbol;
var iGraphicsContainer = map as IGraphicsContainer;
Debug.Assert(iGraphicsContainer != null, "iGraphicsContainer != null");
iGraphicsContainer.AddElement(textElement, 0);
var iActiveView = (map as IActiveView);
Debug.Assert(iActiveView != null, "iActiveView != null");
iActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
</code></pre>
<p>Any ideas as to why ScaleText is being ignored?</p> | 2 |
How to show date from MonthCalendar to TextBox C# | <p>I have two forms, on one is month, on another is TextBox.
Problem is that I don't get displayed date on the TextBox after selecting it.
To be certain that I wrote working code, I did same thing just on one form, and it works fine.
Set MonthCalendar to public and same with the TextBox where date needs to be displayed.<br>
<a href="https://i.stack.imgur.com/5XzH7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5XzH7.jpg" alt="enter image description here"></a></p>
<p>Here is the code for Button and for the monthcalendar:</p>
<pre><code>public void mcKalendar_DateChanged()
{
frmNovoVozilo fNv = new frmNovoVozilo();
fNv.txtDatKupovine.Text =
mcKalendar.SelectionRange.Start.ToShortDateString();
}
private void btnDatum_Click(object sender, EventArgs e)
{
frmKalendar fKalen = new frmKalendar();
fKalen.StartPosition = FormStartPosition.CenterScreen;
fKalen.Show();
}
</code></pre>
<p>Did try also DateSelected and it's giving me the same result, nothing.
Thanks upfornt.</p> | 2 |
Why does chrome.contextMenus create multiple entries? | <p>I am using <code>chrome.contextMenus.create</code> function to create context menus in my Chrome extension. But it creates extra options.</p>
<p>I gave permission in my <code>manifest.json</code> file, added this function my <code>background.js</code> file and added it my <code>manifest.json</code> file.</p>
<p>Why this is happening ?</p>
<pre><code>function getword(info,tab) {
console.log("Word " + info.selectionText + " was clicked.");
chrome.tabs.create({
url: "http://www.google.com/search?q=" + info.selectionText,
});
}
chrome.contextMenus.create({
title: "Search: %s",
contexts:["selection"],
onclick: getword,
});
</code></pre>
<p><a href="https://i.stack.imgur.com/1WESS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1WESS.png" alt="enter image description here"></a></p> | 2 |
How to hide the cursor in a C# console application on Linux? | <p>I am writing a C# application which is running on Linux with Mono, and I want to hide the console cursor. But since this <code>Console.CursorVisible = false</code> seems to do nothing at all, is there another way of doing this, e.g. a console command or a native function?</p> | 2 |
Spring boot @RestController | <p>Is there a step needed, like adding jars to classpath?</p>
<p>I followed this:</p>
<p>10.2.6 Quick start Spring CLI example</p>
<p>Here’s a really simple web application that you can use to test your installation. Create a file called app.groovy:</p>
<pre><code>@RestController
class ThisWillActuallyRun {
@RequestMapping("/")
String home() {
"Hello World!"
}
}
</code></pre>
<p>Then simply run it from a shell:</p>
<pre><code>$ spring run app.groovy
</code></pre>
<p>and get:</p>
<pre><code>startup failed:
file:/home/rgupta/Documents/products/microservices/postabook/hola-springboot/app.groovy: 1: unable to resolve class ResttController, unable to find class for annotation
@ line 1, column 1.
@ResttController
^
file:/home/rgupta/Documents/products/microservices/postabook/hola-springboot/app.groovy: 4: unable to resolve class RequestMapping , unable to find class for annotation
@ line 4, column 5.
@RequestMapping("/")
^
2 errors
[rgupta@rgupta hola-springboot]$
</code></pre> | 2 |
Spring MVC: What is an HttpEntity? | <p>I have read the spring docs about the HttpEntity. Accordingly, it represents a Http response/request entity. I arrived in the conclusion that this is the same as a character in a character stream. However, it consists of a header and a body.</p>
<p>Please elaborate about HttpEntity or Http response/request in general. Links are welcome.</p> | 2 |
Cucumber how to find if a feature file has executed? Any Java method? | <pre><code> @Before
public void quit_if_tagged_scenario_failed(Scenario scenario) {
if (!isTagged(scenario) && prevScenarioFailed)
throw new IllegalStateException("An important scenario has failed! Cucumber wants to quit.");
}
</code></pre>
<p>I'm using this method to check if the previuos scenario failed. If failed I want to skip all the scenarios in that feature file.So the problem here is if I’m running two feature files the last scenario in the feature file failed and the first step of next feature will also fails because cucumbers previous scenario from past feature file is failed. Do you know how to handle that kind of situation?
Your help will be greatly appreciated.</p> | 2 |
How to store image in bitmap variable from picasso | <p>I download image from url using picasso.But, i don't know how to store that image in bitmap variable.Please anyone help me!</p>
<p>Here my code:</p>
<pre><code>Bitmap bitmapImage = null;
Picasso.with(context)
.load(url)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
</code></pre>
<p>Thanks in advance!</p> | 2 |
What commands is required to revert changes made by git mergetool? | <p>I have made some changes to a number of conflicting files as the result of a a <code>git pull</code> command, using the <code>git mergetool</code> command, but I want to revert it back to the state before I made the changes with the mergetool.</p>
<p>It is basically the state where git warns that there are conflicts and lists them. What command is required for that?</p> | 2 |
Python selenium drop down menu click | <p>i want to select option from a drop down menu, for this i use that :</p>
<pre><code>br.find_element_by_xpath("//*[@id='adyen-encrypted-form']/fieldset/div[3]/div[2]/div/div/div/div/div[2]/div/ul/li[5]/span").click()
</code></pre>
<p>To select option month 4 but when i do that pyhton return error message : </p>
<blockquote>
<p>selenium.common.exceptions.ElementNotVisibleException: Message:
element not visible (Session info: chrome=51.0.2704.103) (Driver
info: chromedriver=2.22.397929
(fb72fb249a903a0b1041ea71eb4c8b3fa0d9be5a),platform=Mac OS X 10.11.5
x86_64)</p>
</blockquote>
<p>That is the HTML code:</p>
<pre><code></div>
<div class="form-row exp-date clearfix fancyform">
<div class="formfield expired-label monthcaption">
<label>Date d'expiration <span>*</span></label>
</div>
<div class="formfield month">
<div class="value value-select">
<select class="selectbox required" id="dwfrm_adyenencrypted_expiryMonth" data-missing-error="Veuillez sélectionner le mois d'expiration" data-parse-error="Ce contenu est invalide" data-range-error="Ce contenu est trop long ou trop court" data-value-error="Cette date d'expiration est invalide" pattern="^(:?0[1-9]|1[0-2])$" required="required" >
<option class="selectoption" label="Mois" value="">Mois</option>
<option class="selectoption" label="01" value="01">01</option>
<option class="selectoption" label="02" value="02">02</option>
<option class="selectoption" label="03" value="03">03</option>
<option class="selectoption" label="04" value="04">04</option>
<option class="selectoption" label="05" value="05">05</option>
<option class="selectoption" label="06" value="06">06</option>
<option class="selectoption" label="07" value="07">07</option>
<option class="selectoption" label="08" value="08">08</option>
<option class="selectoption" label="09" value="09">09</option>
<option class="selectoption" label="10" value="10">10</option>
<option class="selectoption" label="11" value="11">11</option>
<option class="selectoption" label="12" value="12">12</option>
</select>
</code></pre>
<p>What is wrong ? I know selenium cant find the element but i dont know why , xpath wrong ? i need to use other method to find element ? thanks for anwsers </p> | 2 |
stopwatch running in background with service | <p>I'm trying to make a simple stopwatch for Android. It should keep counting time after minimalizing an app. I have put stopwatch logic into Service and I bind this service in <code>MainActivity</code> to get control over it. Counting time runs in separate thread and I'm using messenger to send time back to <code>MainActivity</code>. Everything works good as long as I don't minimize app and go back while stopwatch is running. After that, pressing start/stop runs second thread counting time instead of stopping the first one. Could check what is wrong? Would appreciate :)</p>
<p>Here are java classes: </p>
<pre class="lang-java prettyprint-override"><code>public class MainActivity extends Activity {
public static Handler sHandler;
private final int playPause = 0;
private final int reset = 1;
private int secs = 0;
private int mins = 0;
private int millis = 0;
private long currentTime = 0L;
private boolean isBound = false;
private MyService myService;
private Intent intent;
@BindView(R.id.timer)
TextView time;
@OnClick(R.id.fab_playPause)
public void playPause() {
myService.startStop();
}
@OnClick(R.id.fab_reset)
public void reset() {
myService.reset();
mins = 0;
secs = 0;
millis = 0;
setTime();
}
@OnClick(R.id.fab_exit)
public void exit() {
onDestroy();
}
@OnClick(R.id.fab_save)
public void save() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
intent = new Intent(this, MyService.class);
MainActivity.sHandler = new Handler() {
@Override
public void handleMessage(Message timeMsg) {
super.handleMessage(timeMsg);
currentTime = Long.valueOf(timeMsg.obj.toString());
secs = (int) (currentTime / 1000);
mins = secs / 60;
secs = secs % 60;
millis = (int) (currentTime % 1000);
setTime();
}
};
}
@Override
protected void onResume() {
super.onResume();
bindService(intent, myConnection, Context.BIND_AUTO_CREATE);
}
@Override
protected void onDestroy() {
super.onDestroy();
stopService(intent);
finishAffinity();
}
private ServiceConnection myConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
MyService.LocalBinder binder = (MyService.LocalBinder) service;
myService = binder.getService();
isBound = true;
}
@Override
public void onServiceDisconnected(ComponentName name) {
isBound = false;
}
};
public void setTime() {
time.setText("" + mins + ":" + String.format("%02d", secs) + ":"
+ String.format("%03d", millis));
}
}
</code></pre>
<p>and:</p>
<pre class="lang-java prettyprint-override"><code>public class MyService extends Service {
private boolean isRunning = false;
private long startTime = 0;
private long timeInMilliseconds = 0;
private long timeSwapBuff = 0;
private long updatedTime = 0;
private final IBinder mBinder = new LocalBinder();
private Message timeMsg;
public MyService() { }
public Runnable updateTimer = new Runnable() {
public void run() {
timeInMilliseconds = SystemClock.uptimeMillis() - startTime;
updatedTime = timeSwapBuff + timeInMilliseconds;
Log.d("Czas:", String.valueOf(updatedTime));
timeMsg = new Message();
timeMsg.obj = updatedTime;
MainActivity.sHandler.sendMessage(timeMsg);
MainActivity.sHandler.postDelayed(this, 0);
}
};
@Override
public void onCreate(){
super.onCreate();
}
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
public void startStop(){
if (isRunning) {
timeSwapBuff += timeInMilliseconds;
MainActivity.sHandler.removeCallbacks(updateTimer);
isRunning = false;
} else {
startTime = SystemClock.uptimeMillis();
MainActivity.sHandler.postDelayed(updateTimer, 0);
isRunning = true;
}
}
public void reset(){
MainActivity.sHandler.removeCallbacks(updateTimer);
isRunning=false;
startTime = 0L;
timeInMilliseconds = 0L;
timeSwapBuff = 0L;
updatedTime = 0L;
timeMsg = new Message();
timeMsg.obj = updatedTime;
MainActivity.sHandler.sendMessage(timeMsg);
}
public class LocalBinder extends Binder {
public MyService getService(){
return MyService.this;
}
}
}
</code></pre>
<p>and a GitHub link: <a href="https://github.com/zelaznymarek/stoper" rel="nofollow">https://github.com/zelaznymarek/stoper</a></p> | 2 |
Correct way to handle readFile and writeFile exceptions | <p>I'm writing an application in Haskell and would like to display a meaningful error message to the user if <code>readFile</code> or <code>writeFile</code> fails. I'm currently catching <code>IOError</code>s with <code>Control.Exception.tryJust</code> and converting them to human-readable text.</p>
<p>However, I'm having trouble figuring out which errors I should catch and how to extract information from them. For example, assuming "/bin" is a directory and "/bin/ls" is a file, <code>readFile "/bin"</code> and <code>readFile "/bin/ls/asdf"</code> both give "inappropriate type" but (in my opinion) they are different errors. In the case of the first one, I could recover by processing each file within the directory, whereas the second is more like a "does not exist" type of error.</p>
<p>In relation to the previous example, there doesn't seem to be a portable way of catching "inappropriate type" errors. Looking at <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.IO.Exception.html#IOErrorType" rel="nofollow noreferrer">GHC.IO.Exception</a>, <code>InappropriateType</code> is marked GHC-only so I can't just pattern match on <code>ioeGetErrorType</code>. I could pattern match on <code>ioeGetErrorString</code> but I'm not sure if those strings are always the same across different platforms, compilers, locales, etc.</p>
<p>In summary, my questions are:</p>
<ol>
<li>Which exceptions should I be catching for <code>readFile</code>/<code>writeFile</code>?</li>
<li>Once I have an exception, how should I go about extracting information from it?</li>
<li>Is there a portable way of catching the GHC-only exceptions such as <code>InappropriateType</code>?</li>
</ol>
<p><strong>Update:</strong></p>
<p>Based on @ErikR's answer I'm looking at the fields of <code>GHC.IO.Exception.IOException</code> with the following Haskell program:</p>
<pre><code>import Control.Exception (try)
import GHC.IO.Exception (IOException(..))
import qualified Data.ByteString as B
main :: IO ()
main = do
try (readFile "/nonexistent") >>= printException
try (writeFile "/dev/full" " ") >>= printException
try (readFile "/root") >>= printException
try (readFile "/bin") >>= printException
try (writeFile "/bin" "") >>= printException
try (readFile "/bin/ls/asdf") >>= printException
try (writeFile "/bin/ls/asdf" "") >>= printException
try (B.readFile "/dev/null") >>= printException
-- I have /media/backups mounted as read-only. Substitute your own read-only
-- filesystem for this one
try (writeFile "/media/backups/asdf" "") >>= printException
printException :: Either IOError a -> IO ()
printException (Right _) = putStrLn "No exception caught"
printException (Left e) = putStrLn $ concat [ "ioe_filename = "
, show $ ioe_filename e
, ", ioe_description = "
, show $ ioe_description e
, ", ioe_errno = "
, show $ ioe_errno e
]
</code></pre>
<p>The output on Debian Sid GNU/Linux with GHC 7.10.3 is:</p>
<pre><code>ioe_filename = Just "/nonexistent", ioe_description = "No such file or directory", ioe_errno = Just 2
ioe_filename = Just "/dev/full", ioe_description = "No space left on device", ioe_errno = Just 28
ioe_filename = Just "/root", ioe_description = "Permission denied", ioe_errno = Just 13
ioe_filename = Just "/bin", ioe_description = "is a directory", ioe_errno = Nothing
ioe_filename = Just "/bin", ioe_description = "Is a directory", ioe_errno = Just 21
ioe_filename = Just "/bin/ls/asdf", ioe_description = "Not a directory", ioe_errno = Just 20
ioe_filename = Just "/bin/ls/asdf", ioe_description = "Not a directory", ioe_errno = Just 20
ioe_filename = Just "/dev/null", ioe_description = "not a regular file", ioe_errno = Nothing
ioe_filename = Just "/media/backups/asdf", ioe_description = "Read-only file system", ioe_errno = Just 30
</code></pre> | 2 |
two plots from pandas dataframe with different vertical axes on the same figure | <p>i'm trying to plot in python a line plot and a bar plot on the same figure using data from pandas dataframe. i manage to get two axes on the plot and the legend displays two entries, but the first of the plots is not present.</p>
<p>here's my code:</p>
<pre><code>import matplotlib.pyplot as plt
import pandas as pd
ax1 = data[["timestamp", "polarity"]].plot(x="timestamp", kind="bar")
ax1.set_xticks(data["timestamp"].values)
ax1.set_ylabel("polarity")
ax1.set_xlabel("year")
ax2 = ax1.twinx()
data[["timestamp", "revenue"]].plot(x="timestamp", linestyle="-", marker="o", ax=ax2)
ax2.set_ylabel("revenue")
plt.show()
</code></pre>
<p>and this is the plot that i get:</p>
<p><a href="http://i.stack.imgur.com/TvuoU.png" rel="nofollow">plot</a></p>
<p>when i reverse the order in which i plot, i get the following plot:</p>
<p><a href="http://i.stack.imgur.com/3muJt.png" rel="nofollow">plot 2</a></p>
<p>how do i make the plots appear on the same figure?</p>
<p>thanks in advance!</p> | 2 |
How to configure a Play application to use Let's Encrypt certificate? | <p>Once I obtain the certificate, how do I generate a JKS key store from it?</p>
<p>How do I configure the Play application to use this key store?</p>
<p>Anything else I need to do?</p> | 2 |
Why is there a string ID in the data model of Azure Mobile Apps? | <p>I'm working the C# in Azure Mobile Apps trying to learn them. I created the Model to link to my Azure SQL DB, created a DataObject like this:</p>
<pre><code>public class Account : EntityData
{
//public int id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string PhoneNumber { get; set; }
public string Password { get; set; }
public DateTime dtCreated { get; set; }
public Guid oGuid { get; set; }
}
</code></pre>
<p>Notice that I commented out the public int id above; it was giving me a duplicate column error on the query.</p>
<p>Finally, I created a controller using the newly created Account DataObject.</p>
<p>So I ran the application and hit the "tables/Account" function and it returned zero rows (but there is data and I can query it with the user I'm using in the azure mobile app).</p>
<p>I then noticed the model schema as this:</p>
<pre><code>[
{
"id": 0,
"FirstName": "string",
"LastName": "string",
"PhoneNumber": "string",
"Password": "string",
"dtCreated": "2016-07-06T17:45:47.114Z",
"oGuid": "string",
"Id": "string",
"Version": "string",
"CreatedAt": "2016-07-06T17:45:47.114Z",
"UpdatedAt": "2016-07-06T17:45:47.114Z",
"Deleted": true
}
]
</code></pre>
<p>There's a couple of issues I see with the configured model (and I don't know where some of the columns are coming from...)</p>
<p>First, the id is listed twice, once as an int (which has to be mine) and another id as string and I have no idea where that came from.</p>
<p>Also, in the DB, the oGuid is of type uniqueIdentifier; not string. This may or may not be an issue because I can't test yet. </p>
<p>Then there are the other columns that just do not exist in my DB including CreatedAt (datetime), UpdatedAt (datetime), Version (string) and Deleted (bit).</p>
<p>I'm thinking the issue / reason why I'm not getting any data back from that call is that there is a data mismatch.</p>
<p>Do I need to add the other columns that are listed in the model in the api test?</p>
<p>I've also tested trying to call the /table/Account/3 to load a specific account and it returns no rows... I'm guessing it's a model mismatch but I'm not sure if that's the issue or something else causing it? I'm not seeing any errors or warnings.</p>
<hr>
<p><strong>Update</strong></p>
<p>I figured out what is going on with model first and Azure and how to attach an existing DB in Azure to new code. I'm going to post this here for the hopes that it saves other's time. This really should have been easier to do. I'm not a fan of codefirst (yet) as I like to control the DB by hand... So this makes it a lot easier for me to work with the db backend.</p>
<p>First I created a new project (Azure Mobile App) then under models I right clicked the model and add->new entity data model then added in the azure db name, password and gave it my "user created profile name" as used below. This connection must be edited in the web.config as shown below. </p>
<p>I then had to create the model for the table in DataObjects (without the MS required columns) and create a controller off of the dataobject. I then had to edit the web.config and set a non-entity DB connection string: eg:</p>
<pre><code><add name="[user created preset name]" providerName="System.Data.SqlClient" connectionString="Server=[Azuredb server connection];initial catalog=[DBName];persist security info=True;user id=[user];password=[pass];MultipleActiveResultSets=True"/>
</code></pre>
<p>Finally, in the MobileServiceContext, I had to map the DataObject model to the table in Azure sql and set the connection string to use from the default MS_TableConnectionString to the connectionstring in web.config.</p>
<pre><code> private const string connectionStringName = "Name=[user created preset name]";
</code></pre>
<p>and under OnModelCreating() I added:</p>
<pre><code> modelBuilder.Entity<Account>().ToTable("tblAccount");
</code></pre>
<p>Where Account was the model (class) I created in DataObjects and the tblAccount is the table name in AzureDB.</p> | 2 |
Unity Sprites not sliced correctly | <p><a href="https://i.stack.imgur.com/LLS81.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LLS81.png" alt="Perfectly sliced"></a></p>
<p>So I made a spride sheet for a button animation, which Unity shows me in the spriteeditor as perfectly sliced, up to the individual pixel, But once I test them they are cut off like this:</p>
<p><a href="https://i.stack.imgur.com/g5Naz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g5Naz.png" alt="Not correct"></a></p> | 2 |
Firebase notification onMessageReceived show the same notification as when app in background | <p>I am sending messages to my app from the Console and I managed to have the app react as I want, when it is in background. So basically there is a notification shown by the SDK and when the user taps it and the app starts, I have some custom data fields to use to build a dialog message. </p>
<p>Since I also want the app to react when on foreground I've added the service and I've noticed that the <code>RemoteMessage</code> also contains a <code>getNotification()</code> method which returns <code>RemoteMessage.Notification</code> which I suppose is used by the SDK to show the notification when app in background.</p>
<p>Is there an easy way to simply use that retrieved notification and display it, just as when the app is in background?</p> | 2 |
Monitor user activity in vb.net | <p>I would like to make a program that monitors user activity. I do not need to know what the user is doing, all i need to know is that he is doing something. Moving the mouse, or typing. The program will be used to show to the company who is at the desk and who is gone from the workstation. So if there is no activity for 2 minutes, that means that the user is away from the computer.</p>
<p>I was thinking of using the keyboard hook and the mouse position to monitor changes every lets say 5 seconds. On every change I will reset the counter.</p>
<p>Is there a better way? (For example reading the screensaver countdown or something like that)</p> | 2 |
align image to a column of text while keeping it responsive | <p>I am trying to code a class schedule in <code>Wordpress</code>. I have attached a picture of a mock up to better illustrate what I am trying to achieve.</p>
<p>Mock Up below here:</p>
<p><a href="https://i.stack.imgur.com/mMNmo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mMNmo.jpg" alt="enter image description here"></a></p>
<p>The text div keeps either going under the thumb div or wraps around it and my column is lost.</p>
<p>Also, when going into responsive mode, the divs do not align one under each other, but stack up one on top of the other. I am trying to have the thumb image with a column of text next to it just like in the picture and have it scale nicely into small screens.</p>
<p>Any ideas how this could be accomplished? Is it even possible? Thank you so much in advance. </p>
<p>Here is the code:</p>
<pre><code>#text {
width: 33%;
align: left;
clear: both;
}
#thumb {
width: 33%;
align: left;
}
<div id ="thumb"><img src=“---" /></div>
<div id=“text”>NAME OF FIRST CLASS
</div>
</code></pre> | 2 |
how could I reload websecurityconfig runtime | <p>I've use Spring Security's <code>WebSecurityConfig</code> to manager permissions.
and permissions just loaded once when the spring application started.</p>
<p>so how could I manually reload <code>WebSecurityConfig</code> in runtime when permission is changed?</p>
<p>this is my <code>WebSecurityConfig</code> code:</p>
<pre><code>@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
{
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/css/**").permitAll()
.antMatchers("/js/**").permitAll()
.antMatchers("/rest/login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/boss/login")
.permitAll()
.and()
.logout()
.permitAll();
http.csrf().disable();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authProvider);
}
}
</code></pre> | 2 |
how to add a pagination inside tabs | <p>Im new to laravel 5.2. I just want to ask how to add paginations inside tabs. In my interface there are 5 tabs and eack tab is displaying separate 5 tables from the database. And the database which i using is oracle. In my interface i have added paginatiins for the first tab and it worked successfully.(i added simplepagination method)</p>
<p>But when i adding same method to second tab pagination appeared and when i click the next button on that pagination it directed to the 2nd page of 1st tab not the 2nd page of second tab. I'll be really thankfull if some one can help me to solve this</p>
<p>Thank you</p> | 2 |
Closing then opening standard input in C under Linux | <p>I have a C console application under Linux (Raspbian - Raspberry Pi). The program has some character animation - it prints out messages character by character. For example, the text </p>
<blockquote>
<p>Please give me your name!</p>
</blockquote>
<p>is printed out completely after 5 seconds (char by char).</p>
<p>Afterwards, the user is asked to type in their name, which works just fine if the user waits for the message to be printed out. However, if the user is impatient and hits the keys on the keyboard randomly, the input request later is compromised.</p>
<p>Imagine the user types in </p>
<blockquote>
<p>abc\nefgh\n</p>
</blockquote>
<p>while the above text is being echoed ('\n' means new line - enter). If that happens, the user will not be asked to properly type in his/her name, but the array of characters 'abc' will be accepted as input and gets validated.</p>
<p>My question is how to disable input (buffering) temorarily (on Linux). I have tried several methods and read numerous posts about doing so, but none of them worked for my purpose.</p>
<p>The function that is responsible for asking for input is as follows:</p>
<pre><code>int getLine(char *s, int length)
{
int i;
char c;
for (i = 0; i < length && (c = getchar()) != EOF && c != '\n'; i++)
{
if (c == '\0')
{
i--;
}
else
{
s[i] = c;
}
}
s[i] = '\0';
while (c != EOF && c != '\n')
{
c = getchar();
}
return i;
}
</code></pre>
<p>Empty lines are eliminated with the help of a while loop in the function calling the one above so enter inputs are considered invalid.</p>
<p>I tried closing stdin, but could not reopen it:</p>
<pre><code>fclose(stdin);
</code></pre>
<p>and emptying buffer before the <code>getLine</code>:</p>
<pre><code>char buf[BUFSIZ];
while (c = fgets(buf, BUFSIZ, stdin) != NULL);
</code></pre>
<p>Unfortunately, it did not work as it does with text files.</p>
<p><code>fflush(stdin);</code> did not work either and is not pretty anyway.</p>
<p>My goal is to prevent users from typing in anything while the text is being written out and to ignore/close input buffering (stdin) temporarily. Also, it would be great to disable outputting (flushing) user inputs during printing as it gets displayed on Linux terminal.</p> | 2 |
extract multiple values from string based on REGEXP_INSTR in Oracle | <p>HI have following sample string. </p>
<p>'Claim Number: 299765Member: JOHNSON,XYZ Service Line Number 1<br>
Action Code 0 Response Directive 1641800532 Advice Line 2 Service Line<br>
Number 2 Action Code 0 Response Directive 400 Procedure Code<br>
4805587'</p>
<p>I need to extract the values after Response Directive string when ever there is a Response Directive String identified in the whole string . </p>
<pre><code>WITH TEST AS(
SELECT 'Claim Number: 299765Member: JOHNSON,XYZ Service Line Number 1
Action Code 0 Response Directive 1641800532 Advice Line 2 Service Line
Number 2 Action Code 0 Response Directive 400 Procedure Code
4805587'
AS NOTE_TEXT FROM DUAL
)
SELECT regexp_substr(NOTE_TEXT,'response directive+\s+(\w+)',1,1,'i',1) as
NUM_VAL
FROM TEST;
</code></pre>
<p>Right now I am resulted with only one result based on above query I written </p>
<p><strong>NUM_VAL</strong></p>
<p>1641800532 </p>
<p>Expected Result Set </p>
<p><strong>NUM_VAL</strong></p>
<p>1641800532 </p>
<p>400</p>
<p>Kindly help for multiple Occurrences. Thank You</p> | 2 |
Calling function inside angularjs ng-repeat | <p>I am new to angularjs, have creating an phonegap project. In my project I am using WP JSON API User Plus Plugin to fetch data in json format, The API gives the response as few contents, also I need to call another API with parameter get from the previous API. Is it possible to call an API inside an ng-repeat to load different datas.</p>
<p>I am getting data's in json, and load the data in ng-repeat,
I have tried like this</p>
<pre><code><tr ng-repeat="app in multipleApps" ng-init="getActivationDate(app)">
<td><h4> {{ app.Name }} </h4></td>
<td> <img src="{{ app.ava_img }}"/> </td>
</tr>
</code></pre>
<p>which call the below function, </p>
<pre><code>$scope.getActivationDate = function(app) {
Service.getActivationDate(app.name)
.then(function(response) {
var date = response.data.image;
$scope.app.ava_img = date;
},
// ...
};
</code></pre>
<p>the output what i am getting is display's the same image for all "app.ava_img", but the response from service is different. please advise regarding the issue but I have no clue how to use it with ng-repeat.</p>
<p>It will be thankful,</p> | 2 |
Errno::ENOENT at / no such file or directory | <p>I'm currently working on a sinatra app and im having a little problem.</p>
<p>i'm trying to load my index.erb but sinatra cannot find the index.erb.</p>
<p>Here is my app.rb</p>
<pre><code>require 'rubygems'
require 'sinatra'
module Registration
class HelloWorldApp < Sinatra::Base
get '/' do
erb :index
end
end
end
</code></pre>
<p>and this is my Code hierarchy.</p>
<p><a href="https://i.stack.imgur.com/ONoCy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ONoCy.png" alt="enter image description here"></a></p>
<p>It keeps on looking in the directory: Sinatra-Intro/app/views/index.erb
but my views is in the: Sinatra-Intro/views/index.erb</p> | 2 |
Converting a JSON object to a value list of a particular key in scala (play) | <p>I have a Json object, which is an output of Json.parse, which is of format </p>
<blockquote>
<p>{ "main_data" : [ {"a" : 1, "b" :2} , {"a" : 3, "b" : 4}, {"a" : 5, "b" : 6}]}.</p>
</blockquote>
<p>I want to create a list out of this Json object with the values of all the "a" key. So in the above example it will be [1,3,5]. As I am new to functional programming the first thing came to my mind was to write a For loop and traverse through the Json object to get the list. </p>
<p>But I was wondering is there a Functional/Scala way to do the above, using Map or flatMap ?</p> | 2 |
How do I read in from a file and display in a textfield/label in a GUI? | <p>I have a text file with a list of names in. I am trying to create a GUI and then read in the text from the file into the GUI and display it in a textfield/label/anything. I can create the GUI and read in the code, but do not know how to display the read in text in the GUI. Below is my code. When I run it displays the GUI but does not display the read in text.</p>
<pre><code>public class ASSIGNMENT {
private JLabel lbl1;
private JTextField txt1;
private JPanel panel;
private JFrame frame;
public ASSIGNMENT(){
createGUI();
addLabels();
frame.add(panel);
frame.setVisible(true);
}
public void createGUI(){
frame = new JFrame();
frame.setTitle("Books");
frame.setSize(730, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel = new JPanel();
panel.setLayout(null);
panel.setBounds(10, 10, 10, 10);
panel.setBorder(BorderFactory.createLineBorder (Color.decode("#1854A2"), 2));
frame.add(panel);
}
public void addLabels(){
lbl1 = new JLabel(" ");
lbl1.setBounds(700, 450, 120, 25);
lbl1.setForeground(Color.white);
panel.add(lbl1);
}
public void books() throws IOException{
String result = "books2.txt";
String line;
LineNumberReader lnr = new LineNumberReader(new FileReader(new File("books2.txt")));
while((line = lnr.readLine()) != null){
result += line;
}
JLabel label1 = new JLabel(result);
panel.add(label1);
}
public static void main(String[] args) throws Exception{
new ASSIGNMENT();
}
}
</code></pre> | 2 |
Owin Authorization denies Roles | <p>I've recently joined a project team and have been tasked with setting up User Roles for the backend of the project.
It uses ASP.NET C# WebApi with Owin.
My issue is, when I assign an attribute to the Controller Method like this:</p>
<pre><code>[Authorize(Roles = "Admin")]
</code></pre>
<p>The response is always Authorization denied for this request.
However if I simply use:</p>
<pre><code>[Authorize]
</code></pre>
<p>It works.
Note that I am logging in with a User that has been assigned the Role of Admin.</p>
<p>I've noticed that this question is similar to: <a href="https://stackoverflow.com/questions/25661623/authorization-roles-webapi-oauth-owin">Authorization roles WebAPI oauth owin</a></p>
<p>However, it seems their code in startup.cs is different somehow, or else I'm struggling to follow the answer correctly.</p>
<p>The code in the startup.cs that I have to work with is:</p>
<pre><code>public void Configuration(IAppBuilder app)
{
// configure OAuth
ConfigureOAuth(app);
// configure Mvc
HttpConfiguration config = new HttpConfiguration();
WebApiConfig.Register(config);
app.UseWebApi(config);
}
public void ConfigureOAuth(IAppBuilder app)
{
OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = new SimpleAuthorizationServerProvider()
};
// Token Generation
app.UseOAuthAuthorizationServer(OAuthServerOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
}
</code></pre>
<p>Is there something else I need to add in here to allow for Roles or should it be somewhere else in the code.
I'm not completely familiar with ASP.NET C# MVC or WebApi, any help is severely appreciated.</p> | 2 |
Python - Create dictionary of dictionaries from CSV | <p>I have a CSV with the first column having many duplicate values, and the second column being a predetermined code that maps to a value in the third column, such as this:</p>
<pre><code>1, a, 24
1, b, 13
1, c, 30
1, d, 0
2, a, 1
2, b, 12
2, c, 82
2, d, 81
3, a, 04
3, b, 23
3, c, 74
3, d, 50
</code></pre>
<p>I'm trying to create a dictionary of dictionaries from a CSV, that would result in the following:</p>
<pre><code>dict 1 = {'1':{'a':'24', 'b':'13', 'c':'30','d':'0'},
'2':{'a':'1', 'b':'12', 'c':'82','d':'81'},
... }
</code></pre>
<p>My code creates the key values just fine, but the resulting value dictionaries are all empty (though some print statements have shown that they aren't during the run process)...</p>
<pre><code>with open(file, mode='rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
dict1 = {} # creates main dict
for row in reader: # iterates through the rows of the csvfile
if row[0] in dict1:
dict2[row[1]] = row[2] # adds another key, value to dict2
else:
dict1[row[0]] = {} # creates a new key entry for the new dict1 key
dict2 = {} # creates a new dict2 to start building as the value for the new dict1 key
dict2[row[1]] = row[2] # adds the first key, value pair for dict2
</code></pre> | 2 |
Aligning a text box edge with an image corner | <p>I'm looking for a way of exactly aligning (overlaying) the corner edge of my image with corner and edge of a text box edge (bbox or other)</p>
<p>The code in question is:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1)
ax.imshow(np.random.random((256,256)), cmap=plt.get_cmap("viridis"))
ax.axis("off")
ax.annotate(
s = 'image title',
xy=(0, 0),
xytext=(0, 0),
va='top',
ha='left',
fontsize = 15,
bbox=dict(facecolor='white', alpha=1),
)
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/9c825.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9c825.png" alt="Single image"></a></p>
<p>As you can see, the edges of the text box is outside the image. For the life of me, I cannot find a consistent way of aligning the corner of the text box with the corner of the image. Ideally, I'd like the alignment to be independent of font size and image pixel size, but that might be asking a bit too much.</p>
<p>Finally, I'd like to achieve this with a grid of images, like the second example, below.</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8, 8))
images = 4*[np.random.random((256,256))]
gs = gridspec.GridSpec(
nrows=2,
ncols=2,
top=1.,
bottom=0.,
right=1.,
left=0.,
hspace=0.,
wspace=0.,
)
for g, i in zip(gs, range(len(images))):
ax = plt.subplot(g)
im = ax.imshow(
images[i],
cmap=plt.get_cmap("viridis")
)
ax.set_xticks([])
ax.set_yticks([])
ax.annotate(
s = 'image title',
xy=(0, 0),
xytext=(0, 0),
va='top',
ha='left',
fontsize = 15,
bbox=dict(facecolor='white', alpha=1),
)
</code></pre>
<p><a href="https://i.stack.imgur.com/usG9n.png" rel="noreferrer"><img src="https://i.stack.imgur.com/usG9n.png" alt="enter image description here"></a></p> | 2 |
How to add dynamic view inside a recycler view row | <p>I have one recycler view and inside each row I have one linear layout in which I have to insert some views dynamically according to data on each row.</p>
<p>I have tried </p>
<blockquote>
<pre><code>for(int i=0;i<4;i++){
View view = LayoutInflater.from(context).inflate(R.layout.sales_total_item_with_img,null);
holder.dynamicLinearLayout.addView(view);
}
</code></pre>
<p>the above code is written inside onBindHolder method and working but it is inflating each time I scroll and this thing is just adding more and more views </p>
</blockquote>
<p>Can anyone tell me if I am doing anything wrong and suggest me the better approach? </p> | 2 |
Task running once a day on Xamarin Forms | <p>I started using xamarin a few months ago, and, until now, I didn't have the need of doing something like this.
I'm developing an app that, once a day, should run a WCF web service and verify if an information is true. If it is true, it should show a notification on the device.
My problem is that I don't know how to perform it, i've read about backgrounding and schedule tasks, but I didn't understand well how can I perform this. How can I do it using Xamarin.Forms?</p>
<p>Thank you!</p> | 2 |
How to do inner join, group by and count using linq | <p>This is the output of joining 2 tables by inner join.</p>
<p><a href="https://i.stack.imgur.com/dhewM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dhewM.png" alt="enter image description here"></a></p>
<p>I want linq query of joing two table as inner join and group by name from one table and sum of total from another table column as taken snapshot as above.pls help</p> | 2 |
Convert dd/mm/yyyy to yyyy-mm-dd in php | <p>I need to convert date format in php , But i am getting getting error</p>
<p>here is my code </p>
<pre><code> $test = new DateTime('23/09/2016');
echo date_format($test, 'Y-m-d');
</code></pre>
<p>But i am getting error as </p>
<pre><code>Message: DateTime::__construct(): Failed to parse time string (23/09/2016) at position 0 (2): Unexpected character
</code></pre>
<p>How to resolve the issue </p> | 2 |
Ionic 2 - ion-scroll doesn't pick content height | <p>In my app I have a panel which shows/hides on the click of a button. This panel has a max-height of 300px. </p>
<p>The content inside the panel gets added/removed and the panel should adjust it's height to fit the content. Since I want to be able to scroll the content inside this panel, I've used a <code>ion-scroll</code>. </p>
<p>The problem is, the <code>ion-scroll</code> doesn't seem to take the height of it's content. I have to specifically set a height in 'px' for it to show it's content. Anyone know what I can do?</p>
<p>Note: Giving a height to the <code>ion-scroll</code> in percentage is not working either.</p>
<p>This is the structure of my HTML</p>
<pre><code><ion-content>
<div style="position: fixed; bottom: 0; width: 100%; z-index: 1; max-height: 300px;" *ngIf="showPanel">
<ion-scroll>Scroll content goes here.</ion-scroll>
</div>
</ion-content>
</code></pre>
<p>I'm using Ionic 2 - Beta 10.</p> | 2 |
Using editorconfig within Git submodules | <p>I have a Web application which has dependency on an external module for JSON schema validation. The Web app has its Git repository, within which the module is included as a Git submodule.</p>
<p>On the Web project, I have <code>editorconfig</code> for syntax standardisation. For this(as I use Sublime text), I use <a href="https://github.com/sindresorhus/editorconfig-sublime" rel="noreferrer">editorconfig-sublime</a>.</p>
<p>The module is maintained by another team, and they have their own coding style. I occasionally contribute to it though. </p>
<p>The issue I'm having is that when I add code within the Web folder, to the module, my coding style clashes with theirs, as I have my own <code>.editorconfig</code> file. They don't currently use <code>editorconfig</code>.</p>
<p>My question is this: </p>
<h3>Is it possible and if yes, advisable to use one <code>.editorconfig</code> in the base Git repository and another <code>.editorconfig</code> in the Git submodule? What is the best practice here?</h3> | 2 |
remove back/home button from action mode on long press in android | <p>I have implemented contextual action mode on long press inside <code>recycler view</code>. For that i have called <code>ActionModeCallback</code> from creating action mode . </p>
<p>While creating action mode , back arrow is showing by default .
Check below : </p>
<p><a href="https://i.stack.imgur.com/f67NG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f67NG.png" alt="enter image description here"></a></p>
<p>On click back arrow , action mode will close.</p>
<p>Now i want to <code>hide</code> or <code>remove</code> that default back button which is coming along with <code>action mode</code> in android .</p>
<p>Note : Already tried <code>getActionBar().setDisplayHomeAsUpEnabled(false).</code> but it's not working . Kindly help.</p>
<p>Edited :</p>
<p>Thanks Issues been resolved :
After adding in style.xml</p>
<pre><code><item name="actionModeCloseDrawable">@color/colorPrimary</item>
<item name="actionModeCloseButtonStyle">@style/Widget.AppCompat.ActionMode</item>
</code></pre> | 2 |
Double click / tap event cross browser and device | <p>I try use dblclick event like this</p>
<pre><code>$(element).on('dblclick', function(){
//handler
)};
</code></pre>
<p>but just working for double click not for double tap.
I need some jquery/javascript function for handle double click/tap event, i need for touchscreen laptop, someone can help me with a snippet or anything?</p> | 2 |
Is there a method to close and Reconnect an app in Xamarin Android UITest? | <p>Is there any way to close and reconnect to my app in Xamarin UITest?</p>
<p>In my test case I want close and reconnect my Android app.</p> | 2 |
What is the invert operation of bytes repr() in python3? | <pre><code>a = b'\x00\x01'
ra = repr(a) # ra == "b'\\x00\\x01'"
assert invert_repr(ra) == a
</code></pre>
<p>What is the correct form of invert_repr? string_escape & unicode_escape?</p> | 2 |
Alternative to PHP $mysql->fetch_assoc()? | <p>So basically I have the following loop to iterate database rows:</p>
<pre><code>while($row = $mysql->fetch_assoc())
</code></pre>
<p>But I need to access the rows <strong>before</strong> this loop as well. So, I do this:</p>
<pre><code>$inside = $mysql->fetch_assoc()
</code></pre>
<p>and <strong>$mysql</strong> <em>loses</em> its rows. When it gets to the while loop it simply does not enter it as the condition becomes NULL.</p>
<p>I tried the following</p>
<pre><code>while($row = $inside)
</code></pre>
<p>but this just waits until timeout (loops indefinitely).</p>
<p>Any idea on how I could perform this, making up for the requirements above? Thank you very much for your help...</p> | 2 |
Zillow and Google Script | <p>I have a script that pulls data from Zillow into a google doc....see below. It has worked fine for a couple of years but recently stopped working. It appears to run but takes a long time and no data is populated. The Zillow ID is located in Column B of the active sheet and according to the script the Zestimate should be written in Column 48. I've replaced my ZWS-ID with "X1-XXXXXXXXX_XXXX"</p>
<p>Any help is greatly appreciated.</p>
<p>Thanks
KIWI</p>
<pre><code>function getZillowEstimates() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
var specificRow = ""
var endRow;
if(specificRow == "")
{
specificRow = 1;
endRow = numRows;
}
else
{
specificRow = specificRow - 1;
endRow = specificRow;
}
for (var i = specificRow; i <= endRow; i++)
{
try
{
var row = values[i];
var response = UrlFetchApp.fetch("http://www.zillow.com/webservice/GetZestimate.htm?zws-id=X1-XXXXXXXXX_XXXX&zpid=" + row[1]);
var xmlDoc = XmlService.parse(response.getContentText());
var documentElement = xmlDoc.getRootElement();
var destinationRange = sheet.getRange(i + 1, 48, 1, 1);
if( null != documentElement )
{
var responseElement = documentElement.getChild("response");
if (null != responseElement)
{
var zestimateElement = responseElement.getChild("zestimate");
if( null != zestimateElement)
{
var amountElement = zestimateElement.getChild("amount");
if( null != amountElement)
{
var rowValue = [];
var cellValue = [];
cellValue.push(amountElement.getText());
}
}
}
}
else
{
cellValue.push("Not Found");
}
rowValue.push(cellValue);
destinationRange.setValues(rowValue);
}
catch(exception)
{
}
}
};
/**
* Adds a custom menu to the active spreadsheet, containing a single menu item
* for invoking the readRows() function specified above.
* The onOpen() function, when defined, is automatically invoked whenever the
* spreadsheet is opened.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var menuItems = [
{name: 'Get ZEstimate', functionName: 'getZillowEstimates'},
];
spreadsheet.addMenu('Zestimates', menuItems)
};
</code></pre> | 2 |
Why is uglify not working on AngularJS content? | <p>I've built some gulp tasks to help build my web project. In one of them, I am minifying js files. Here is the task : </p>
<pre><code>gulp.task('minify' , function() {
console.log('Copy minified js ');
return gulp.src('dist/www/**/*.js'])
.pipe(uglify().on('error', function(e){
console.log(e);
}))
.pipe(gulp.dest('dist/www'));
});
</code></pre>
<p>When i execute my task : <code>gulp minify</code> I get the following error : </p>
<pre><code>{ [Error: E:XXXXXX\dist\tmp\bootstrap.js: SyntaxError: Unexpected token: name (mainModule)]
message: 'E:XXXXXX\\dist\\tmp\\bootstrap.js: SyntaxError: Unexpected token: name (mainModule)',
fileName: 'E:XXXXXX\\dist\\bootstrap.js',
lineNumber: 1,
stack: 'Error\n at new JS_Parse_Error (eval at <anonymous> (E:XXXXXX\gfgfgfgf\\gulp-uglify\\node_modules\\uglify-js\\tools\\node.js:28:1), <anonymous>:1534:18)\n at js_error (eval at <anonymous> (
</code></pre>
<p>Here the bootstrap.js file :</p>
<pre><code>import mainModule from './src/main';
angular.element(document).ready(function() {
angular.bootstrap(document, [mainModule.name], { strictDi: true });
});
</code></pre>
<p>What's happening? Could someone help me by explaining why it doesn't work?</p>
<p>Thanks you!</p> | 2 |
Jenkins external-monitor-job setup | <p>I'm novice to Jenkins. I want to make Jenkins to monitor my crons. I'm following the official tutorial:
<a href="https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs" rel="nofollow">https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs</a></p>
<p>Jenkins is running on AWS Ubuntu 14. The installation was fine and I can access Jenkins on 9091.
<a href="http://www.example.com:9091/" rel="nofollow">http://www.example.com:9091/</a></p>
<p>External Monitor Job Plugin was installed by default. It can be found in the Plugin Manager.</p>
<p>What I did so far.
On Jenkins I created new External job called "backup". <a href="http://www.example.com:9091/job/backup/" rel="nofollow">http://www.example.com:9091/job/backup/</a> and basically that's all there.</p>
<p>In my cron file: "/var/spool/cron/crontabs/root":</p>
<pre><code>[email protected]
JENKINS_HOME=http://www.example.com:9091
* * * * * export JENKINS_HOME=$JENKINS_HOME; java -jar /usr/share/jenkins/jenkins-core-2.7.1.jar "backup" backup.sh 2>&1 > /dev/null
</code></pre>
<p>Because of the <code>mailto</code> settings initially I was receiving <code>no jenkins-core-*.jar found error</code>. I started looking for <code>jenkins-core-*.jar</code> but I didn't find one. In my "/usr/share/jenkins" folder there was only <code>jenkins.war</code> file. I unzipped the .war file and copied the following files to it's folder:</p>
<pre><code>jenkins-core-*.jar
remoting-*.jar
ant-1.7.0.jar
commons-io-1.4jar
commons-lang-2.4.jar
jna-posix-*.jar
xstream-*.jar
</code></pre>
<p>After I did this I started to receive more complicated error:</p>
<pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at hudson.Main.<clinit>(Main.java:222)
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContextListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 13 more
</code></pre>
<p>As expected there is noting on the Jenkins side. Obviously I'm missing something. I tryed to remove quotes around <code>"backup"</code> and to change the command <code>backup.sh 2>&1 > /dev/null</code> with something I'm sure is working. For example: <code>cd /my/directory && program myfile.file</code> but this is all. I'm wondering if I have to unzip the whole .war file somewhere or if I need to follow different path? I'm not sure what the error means. I found suggestion it's messing up with Tomcat. Please for some help with this.</p> | 2 |
PHP Fatal error: Uncaught HTTP_Request2_ConnectionException: Unable to connect to tls://bingapis.azure-api.net:443 | <p>I am working on my first script to use the new Bing search API and I keep getting an error. Based on my research it might have something to do with a certificate but I don't know where to look for a resolution. I am using a Centos 6 and 7 server with the same error result. Below is the error:</p>
<pre><code>PHP Fatal error: Uncaught HTTP_Request2_ConnectionException: Unable to connect to tls://bingapis.azure-api.net:443. Error: stream_socket_client(): unable to connect to tls://bingapis.azure-api.net:443 (Unknown error)
stream_socket_client(): Failed to enable crypto
stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /usr/share/pear/HTTP/Request2/Adapter/Socket.php on line 332
#0 /usr/share/pear/HTTP/Request2/Adapter/Socket.php(332): HTTP_Request2_SocketWrapper->__construct('tls://bingapis....', 10, Array)
#1 /usr/share/pear/HTTP/Request2/Adapter/Socket.php(128): HTTP_Request2_Adapter_Socket->connect()
#2 /usr/share/pear/HTTP/Request2.php(946): HTTP_Request2_Adapter_Socket->sendRequest(Object(HTTP_Request2))
#3 /usr/src/bingtest.php(33): HTTP_Request2->send()
#4 {main}
thrown in /usr/share/pear/HTTP/Request2/SocketWrapper.php on line 134
</code></pre>
<p>Can someone make a suggestion of what I should do next to troubleshoot? I am just copying and pasting the sample code from: <a href="https://bingapis.portal.azure-api.net/docs/services/56b43f0ccf5ff8098cef3808/operations/56b4433fcf5ff8098cef380c" rel="nofollow">bing api sample php code</a></p>
<p>As seen below:
( just for those who might ask i did insert my API key I generated from Bing, I just didn't want to include it here)</p>
<pre><code><?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://bingapis.azure-api.net/api/v5/images/search');
$url = $request->getUrl();
$headers = array(
// Request headers
'Ocp-Apim-Subscription-Key' => '{subscription key}', // I did replace this with my key
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
'q' => 'cats',
'count' => '10',
'offset' => '0',
'mkt' => 'en-us',
'safeSearch' => 'Moderate',
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_GET);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
</code></pre> | 2 |
How to fix ImportError: No module named urls | <p>i have installed django 1.10. And then ckeditor 5.0.3
When done with config i got an error "ImportError: No module named urls"
There is config settings.py:</p>
<pre><code>INSTALLED_APPS = [
...
'ckeditor',
]
CKEDITOR_UPLOAD_PATH = 'upload/'
</code></pre>
<p>There is urls.py:</p>
<pre><code>from django.conf.urls import url, include
(r'^ckeditor/', include('ckeditor.urls')),
</code></pre>
<p>There is urls.py of ckeditor_uploader:</p>
<pre><code>from __future__ import absolute_import
import django
from django.conf.urls import url
from django.contrib.admin.views.decorators import staff_member_required
from django.views.decorators.cache import never_cache
from . import views
if django.VERSION >= (1, 8):
urlpatterns = [
url(r'^upload/',
staff_member_required(views.upload),
name='ckeditor_upload'),
url(r'^browse/', never_cache(staff_member_required(views.browse)),
name='ckeditor_browse'),
]
else:
from django.conf.urls import patterns
urlpatterns = patterns(
'',
url(r'^upload/', staff_member_required(views.upload),
name='ckeditor_upload'),
url(r'^browse/', never_cache(staff_member_required(views.browse)),
name='ckeditor_browse'),
)
</code></pre>
<p>Please any help! </p>
<p>WSGI_APPLICATION:</p>
<pre><code>import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blago.settings")
application = get_wsgi_application()
</code></pre> | 2 |
Exactly how does a nonce and client nonce prevent a replay? | <p>I understand how a nonce and client nonce prevent password attacks via rainbow tables etc...but im not exactly clear on how they help prevent replay attacks. Can someone help me understand this?</p> | 2 |
Call method when console closes (Java) | <p>I have an application that is run in a command window. I have a <code>Scanner</code> that detects when the user types <code>/quit</code>, and runs the respective <code>quit()</code> method.</p>
<p>This works perfectly, but is there a way to determine if the user closes the console without entering <code>/quit</code>, and still run <code>quit()</code>?</p> | 2 |
Angular2: NgModelChange called twice | <p>I have a angular2 component and I recognized that the ngModelChange event is triggered twice when I select another option in a select element.</p>
<p>I had a look to the generated code for the template of this component and I found out that there are 2 value accessors.</p>
<pre><code>_View_SelectionPropertyComponent0.prototype._handle_change_7_1 = function($event) {
var self = this;
self.markPathToRootAsCheckOnce();
self.debug(7,3,8);
var pd_0 = (self._SelectControlValueAccessor_7_4.onChange($event.target.value) !== false); // First call
self.debug(7,3,8);
var pd_1 = (self._SelectControlValueAccessor_7_11.onChange($event.target.value) !== false); // Second call
return ((true && pd_0) && pd_1);
};
</code></pre>
<p>This is the template of my component:</p>
<pre><code><div class="form-group row">
<label class="col-xs-4 form-control-label">{{property.label}}</label>
<div class="col-xs-8">
<select class="form-control" [ngModel]="visual.appearance.get(property.name)" (change)="changeAppearance($event.target.value)" required>
<option *ngFor="let p of property.options" [value]="p">{{p}}</option>
</select>
</div>
</div>
</code></pre>
<p>Is this by design, because I am running the app in dev mode?</p> | 2 |
How to avoid to broadcast a large lookup table in Spark | <p>Can you help me to avoid broadcasting of a large lookup table? I have a table with measurements:</p>
<pre><code>Measurement Value
x1 5.1
x2 8.9
x1 9.1
x3 4.4
x2 2.1
...
</code></pre>
<p>And a list of pairs:</p>
<pre><code>P1 P2
x1 x2
x2 x3
...
</code></pre>
<p>The task is to get all values for both elements of every pair and put them into a magic function. That's how I solved it by broadcasting the large table with the measurements.</p>
<pre class="lang-scala prettyprint-override"><code>case class Measurement(measurement: String, value: Double)
case class Candidate(c1: String, c2: String)
val measurements = Seq(Measurement("x1", 5.1), Measurement("x2", 8.9),
Measurement("x1", 9.1), Measurement("x3", 4.4))
val candidates = Seq(Candidate("x1", "x2"), Candidate("x2", "x3"))
// create data frames
val dfm = sqc.createDataFrame(measurements)
val dfc = sqc.createDataFrame(candidates)
// broadcast lookup table
val lookup = sc.broadcast(dfm.rdd.map(r => (r(0), r(1))).collect())
// udf: run magic test with every candidate
val magic: ((String, String) => Double) = (c1: String, c2: String) => {
val lt = lookup.value
val c1v = lt.filter(_._1 == c1).map(_._2).map(_.asInstanceOf[Double])
val c2v = lt.filter(_._1 == c2).map(_._2).map(_.asInstanceOf[Double])
new Foo().magic(c1v, c2v)
}
val sq1 = udf(magic)
val dfks = dfc.withColumn("magic", sq1(col("c1"), col("c2")))
</code></pre>
<p>As you can guess I'm not pretty happy with the solution. For every pair I filter the lookup table twice, this isn't fast nor elegant. I'm using Spark 1.6.1.</p> | 2 |
Android Google Sheets API V4 - Update public sheet without OAuth | <p>I'm trying to programmatically update a public spreadsheet (set to anyone can edit) via the API but it fails with </p>
<blockquote>
<p>401 - "The request does not have valid authentication credentials."</p>
</blockquote>
<p>I would expect to not need "valid authentication credentials" since it's a publicly editable spreadsheet. I can GET data from the sheet just fine, although I had to generate a "browser" API Key since apparently using an Android Key doesn't work.</p>
<p>Anyone know if there is a trick to getting an update to work, or is this not possible with the API?</p>
<p>Sample code I'm hacking together:</p>
<pre><code>// Don't think I even need this?
GoogleCredential credential = new GoogleCredential();
credential.createScoped(Collections.singleton(SheetsScopes.SPREADSHEETS));
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory factory = JacksonFactory.getDefaultInstance();
final Sheets sheets = new Sheets.Builder(transport, factory, credential)
.setApplicationName("My Awesome App")
.build();
final String sheetID = "[ID Of Valid Public Spreadsheet Here]";
final String range = "A:S";
final ValueRange content = new ValueRange();
content.set("Column A Name", "Some Value to Set");
new Thread() {
@Override
public void run() {
try {
UpdateValuesResponse valueRange = sheets.spreadsheets().values()
.update(sheetID, range, content)
.setKey("My-Valid-Browser-Api-Key")
.execute();
mLog.D("Got values: " + valueRange);
}
catch (IOException e) {
mLog.E("Sheets failed", e);
}
}
}.start();
</code></pre> | 2 |
onCreate in abstract parent activity no called in kotlin | <p>I declared a child of MapActivity:</p>
<pre><code>class RecordingActivity : MapActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d("RecirdingActivity", "InitializeMap") //called
}
override fun getView(): Int {
return R.layout.activity_recording
}
}
</code></pre>
<p>I make a call to start this activity from my main activity:</p>
<pre><code>fab.setOnClickListener {
Log.d("MainActivity", "fabClick") //called
startActivity(intentFor<RecordingActivity>())
}
</code></pre>
<p>and I have the abstract activity:</p>
<pre><code>abstract class MapActivity: AppCompatActivity(), OnMapReadyCallback {
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
super.onCreate(savedInstanceState, persistentState)
setContentView(getView())
initializeMap()
Log.d("MapActivity", "InitializeMap")//not called
}
}
</code></pre>
<p>and <strong>onCreate method of this activity is never called</strong></p>
<p>I traced it with a debugger and I had the same result.
What am I doing wrong?</p> | 2 |
Firebase how to add new data to all child | <p>My Firebase Data.</p>
<pre><code>User : {
user1 : {
name : 1,
age : 2
},
user2 : {
name : 1,
age : 2
},
....
....
....
user10 : {
name : 1,
age : 2
}
}
</code></pre>
<p>I need add <strong><em>somekey</em></strong> to all user. not use loop each.</p>
<pre><code>userxx : {
name : 1,
age : 2,
somekey : 1
}
</code></pre>
<p>current code :</p>
<pre><code>fb.ref("Users").once('value',function(s){
s.forEach(function(snap){
fb.ref("Users/"+snap.key+"/somekey").set(2);
});
});
</code></pre>
<p>if small data this code is work, there might be a problem if large data have user 100+ .</p>
<p>thanks and sorry for grammar.</p> | 2 |
Keep javascript bundle file beautify using uglify | <p>I'm using <code>rollup-plugin-uglify</code> with rollup
I got development and production version of my JS bundle and I want on dev mode.
keep my file beautify though I'm using uglify</p>
<p>I tried to specified it as follows (on development build):</p>
<pre><code>import uglify from 'rollup-plugin-uglify';
export default {
entry: 'myfile.js',
dest: 'mybundle.js',
plugins: [uglify({
beautify: true,
mangle: false,
compress:false
})]
}
</code></pre>
<p>I'm using <code>rollup-plugin-uglify</code> with rollup
I got development and production version of my js bundle and I want on development mode
keep my file beautify though i'm using uglify</p>
<p>But unfortunately the file output still uglified.</p>
<p>Any idea?</p> | 2 |
Change the value of Global Variable in Python3 | <p>How can I modify a global variable in the main function? I set a global variable <code>ADDITION</code> and modify it in a function. Then, I try to modify it in <code>main</code>, but it seems like I failed.</p>
<pre><code>ADDITION = 0
def add(a, b):
global ADDITION
ADDITION = ADDITION + 1
return a+b
def fib_classic(n):
if(n <= 1):
return n
else:
return add(fib_classic(n-2) , fib_classic(n-1))
def fib_closed(n):
fib = (math.pow(1+math.sqrt(5),n) - (1-math.pow(math.sqrt(5),n)))/(math.pow(2,n)*math.sqrt(5))
return math.floor(fib)
def fib_classic(n):
if(n <= 1):
return n
else:
return add(fib_classic(n-2) , fib_classic(n-1))
def fib_loop(n):
a = 0
b = 1
if(n <= 1):
return n
else:
for i in range(0, n-1):
c = b
b = add(a, b)
a = c
return b
def fib_mem(n):
global FIB_DIC
if(n in FIB_DIC):
return FIB_DIC[n]
else:
if(n <= 1):
FIB_DIC[n] = n
else:
FIB_DIC[n] = add(fib_mem(n-1), fib_mem(n-2))
return FIB_DIC[n]
def main():
for i in range(0,36):
global ADDITION
print("Computing the {0}th Fibonacci Number:".format(i))
print("The closed form finds:", end=" "); print(fib_closed(i))
print("The recursive definition finds:", end=" "); print(fib_classic(i))
print("Additions needed for recursive definition:", end=" "); print(ADDITION)
ADDITIION = 0
print(ADDITION) # not 0
print("The loop definition finds:", end=" "); print(fib_loop(i))
print("Additions needed for loop definition:", end=" "); print(ADDITION)
ADDITION = 0
print("The memoization definition finds:", end=" "); print(fib_mem(i))
print("Additions needed for memoization definition:", end=" "); print(ADDITION)
print("--------------------")
</code></pre> | 2 |
Publishing from sbt to a local maven repo | <p>I added the following to the <code>build.sbt</code></p>
<pre><code>publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository")))
publishMavenStyle := true
</code></pre>
<p>Publishing does not seem to have been affected: the following</p>
<pre><code> sbt publishLocal
</code></pre>
<p>The result is apparently still going to the <code>ivy</code> instead of <code>.m2</code> repo:</p>
<pre><code>Packaging /git/msSCSCTEL/streaming-reconciler/target/scala-2.10/streaming-reconciler_2.10-0.1.0-SNAPSHOT-javadoc.jar ...
Done packaging.
published streaming-reconciler_2.10 to /Users/myuser/.ivy2/local/com.mycomp/streaming-reconciler_2.10/0.1.0-SNAPSHOT/poms/streaming-reconciler_2.10.pom
published streaming-reconciler_2.10 to /Users/myuser/.ivy2/local/com.mycomp/streaming-reconciler_2.10/0.1.0-SNAPSHOT/jars/streaming-reconciler_2.10.jar
published streaming-reconciler_2.10 to /Users/myuser/.ivy2/local/com.mycomp/streaming-reconciler_2.10/0.1.0-SNAPSHOT/srcs/streaming-reconciler_2.10-sources.jar
published streaming-reconciler_2.10 to /Users/myuser/.ivy2/local/com.mycomp/streaming-reconciler_2.10/0.1.0-SNAPSHOT/docs/streaming-reconciler_2.10-javadoc.jar
published ivy to /Users/myuser/.ivy2/local/com.mycomp/streaming-reconciler_2.10/0.1.0-SNAPSHOT/ivys/ivy.xml
</code></pre>
<p>What is missing/incorrect to publish to maven instead?</p> | 2 |
localhost REST API request error ionic2 angular2 | <p>I am making a get/post request to my locally hosted REST API server in an Ionic 2 app. The errow below shows up afer a couple of seconds.</p>
<blockquote>
<p>3 387557 group EXCEPTION: Response with status: 0 for URL: null</p>
<p>4 387558 error EXCEPTION: Response with status: 0 for URL: null </p>
<p>5 387558 groupEnd </p>
<p>6 387568 error Uncaught Response with status: 0 for URL: null, <a href="http://localhost:8100/build/js/app.bundle.js" rel="nofollow">http://localhost:8100/build/js/app.bundle.js</a>, Line: 88826</p>
</blockquote>
<p>I am able to make a successful curl request to the local server. Here is my code for reference.</p>
<p>app.js</p>
<pre class="lang-js prettyprint-override"><code>var express = require("express");
var mysql = require("mysql");
var bodyParser = require("body-parser");
var SHA256 = require("sha256");
var rest = require("./REST.js");
var app = express();
function REST(){
var self = this;
self.connectMysql();
};
REST.prototype.connectMysql = function() {
var self = this;
var pool = mysql.createPool({
connectionLimit : 100,
host : 'host',
user : 'user',
password : 'password',
database : 'database',
debug : false
});
pool.getConnection(function(err,connection){
if(err) {
self.stop(err);
} else {
self.configureExpress(connection);
}
});
}
REST.prototype.configureExpress = function(connection) {
var self = this;
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var router = express.Router();
app.use('/api', router);
var rest_router = new rest(router,connection,SHA256);
self.startServer();
}
REST.prototype.startServer = function() {
app.listen(3000, function() {
console.log("All right ! I am alive at Port 3000. OKAY BUDDY");
});
}
REST.prototype.stop = function(err) {
console.log("ISSUE WITH MYSQL n" + err);
process.exit(1);
}
new REST();
</code></pre>
<p>REST.js</p>
<pre class="lang-js prettyprint-override"><code>var mysql = require("mysql");
function REST_ROUTER(router, connection, SHA256) {
var self = this;
self.handleRoutes(router, connection, SHA256);
}
REST_ROUTER.prototype.handleRoutes= function(router,connection,SHA256) {
router.get("/",function(req,res){
res.json({'foo': 'bar'});
});
});
</code></pre>
<p>login.js (component)</p>
<pre class="lang-js prettyprint-override"><code>import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {AuthProvider} from '../../providers/auth/auth';
/*
Generated class for the LoginPage page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
templateUrl: 'build/pages/login/login.html',
providers: [AuthProvider]
})
export class LoginPage {
static get parameters() {
return [[NavController], [AuthProvider]];
}
constructor(nav, AuthProvider) {
this.nav = nav;
this.authProvider = AuthProvider;
this.form = {};
}
login(form) {
this.authProvider.login(form).then(res => {
alert(JSON.stringify(res));
});
}
}
</code></pre>
<p>auth.js (provider)</p>
<pre class="lang-js prettyprint-override"><code>import {Injectable} from '@angular/core';
import {Http, Headers, RequestOptions} from '@angular/http';
import 'rxjs/add/operator/map';
/*
Generated class for the Auth provider.
See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular 2 DI.
*/
@Injectable()
export class AuthProvider {
static get parameters(){
return [[Http]]
}
constructor(http) {
this.url = 'http://localhost:3000/api';
this.http = http;
}
login(form) {
return new Promise(resolve => {
this.http.get(this.getUrl)
.map(res => res.json())
.subscribe(data => {
resolve(data);
});
});
}
}
</code></pre> | 2 |
Data URI default charset | <p>Is there a default charset for data URIs? I read <a href="https://www.rfc-editor.org/rfc/rfc2397" rel="nofollow noreferrer">the spec</a> but I don't see one.</p>
<p>For instance, if I have a data URI for a source map which I expect to be reliably interpreted across browsers, is it OK to omit the charset?</p>
<pre><code>//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJza...
</code></pre>
<p>vs</p>
<pre><code>//@ sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJza...
</code></pre>
<p>I see in <a href="https://github.com/substack/node-browserify/issues/753" rel="nofollow noreferrer">this GitHub issue</a> that people have had problems using Chinese characters in source-mapped files without an explicit <code>charset=utf-8</code>. So if there is a default (or, at least, if we could expect browsers to have chosen one), it doesn't seem like <code>utf-8</code> is the one...</p> | 2 |
Adding value to a list of item in a class c# | <p>Below are my 3 methods,</p>
<pre><code>public class abcOrder
{
public Items items { get; set; }
}
public class Item
{
public string orderrefno { get; set; }
public string sku { get; set; }
public string qty { get; set; }
}
public class Items
{
public List<Item> item { get; set; }
}
</code></pre>
<p>now i want to assign like below,</p>
<pre><code>abcOrder.items.item.Add(new Item
{
orderrefno = "12345",
sku = "sk8765",
qty = 3
});
</code></pre>
<p>But i am getting items as null in abcOrder.items .Please help.</p> | 2 |
Nginx (111: Connection refused) pfp7-fpm.sock (or 9000 port) not found | <p>I have installed PHP 7.0.8 ( ZTS ) on Debian <a href="https://github.com/kasparsd/php-7-debian" rel="nofollow">GitHub Installation</a>. Debian server work with nginx 1.10.1.</p>
<blockquote>
<p>I have an 111 nginx error :</p>
<blockquote>
<p>[error] 25942#25942: *1 connect() failed (111: Connection refused) while connecting to upstream, request: "GET /phpinfo.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9007"</p>
</blockquote>
</blockquote>
<p>I found on the web that my error is the pfp7-fpm configuration.
I havn't the file on my server : php7-fpm.sock</p>
<p>Port number 9000 and 9007 don't work and I don't see php-fpm with the following commande : <code>netstat -lntp</code></p>
<p>My php configuration :</p>
<pre><code>--prefix=/usr/local/php7 \
--with-config-file-scan-dir=/usr/local/php7/etc/conf.d \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-dba \
--enable-ftp \
--with-gettext \
--with-gd \
--with-jpeg-dir \
--enable-mbstring \
--with-mcrypt \
--with-mhash \
--enable-mysqlnd \
--with-mysql=mysqlnd \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--enable-pcntl \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-zlib \
--enable-zip \
--with-readline \
--with-curl \
--enable-fpm \
--enable-fastcgi \
--enable-maintainer-zts \
--with-fpm-user=www-data \
--with-fpm-group=www-data"
</code></pre>
<p>How I can remove this error ?</p> | 2 |
Div to take entire height of viewport, until scroll to next div | <p>I have 5 div containers. I want to render the first div to be the entire height of the viewport. And on scroll, next div takes over entire height of viewport. How would I do this?</p>
<p>HTML Code:</p>
<pre><code><div class="wrapper">
<div id="first-container" >
<p> hello </p>
</div>
<div id="second-container">
<p> hello </p>
</div>
<div id="third-container">
<p> hello </p>
</div>
<div id="four-container">
<p> hello </p>
</div>
<div id="five-container">
<p> hello </p>
</div>
</div>
</code></pre>
<p>I found this simple CSS code. It works on the first div but then doesn't allow me to scroll to the next div. </p>
<pre><code>#first-container{
position: fixed !important;
position: absolute;
top:0;
right:0;
bottom:0;
left:0;
}
#second-container{
background-image: url("blue-gradient.png");
}
#third-container{
background-color: #A8CEFF;
}
#four-container{
background-image: url("green-gradient.png");
}
#five-container{
background-color: #394457;
}
</code></pre> | 2 |
PostgreSQL : Can I retrieve log_min_duration_statement as an integer? | <p>My problem is the following :</p>
<p>I update the setting "log_min_duration_statement" described as an integer in postgreSQL documentation (version 9.5 is used). I use the following query to update it : "<strong>SET log_min_duration_statement to [numberOfMilliseconds]</strong>"</p>
<p>When I try to fetch the updated value I get a duration <strong>string</strong> formatted either in milliseconds (like <strong>"250ms"</strong>) or in seconds (like <strong>"10s"</strong>). I use <strong>"SHOW log_min_duration_statement"</strong> to retrieve the value. I would like to retrieve that value <strong>as an integer representing milliseconds</strong> instead of having it formatted as text with varying units.</p>
<p>Does anyone know about a way to do that ?</p>
<p>Thanks a lot for your time !</p> | 2 |
angular-translate nested JSON and filter | <p>When using <a href="https://angular-translate.github.io/" rel="nofollow noreferrer">angular-translate</a> I can filter my strings like so:</p>
<pre><code><ANY>{{'TRANSLATION_ID' | translate}}</ANY>
</code></pre>
<p>It works very well with the following flat JSON:</p>
<pre><code> {
TRANSLATION_ID: 'A value',
};
</code></pre>
<p>However, I can't figure out how to get it to work using nested translations:</p>
<pre><code><ANY>{{'NAMESPACE.TRANSLATION_ID' | translate}}</ANY>
</code></pre>
<p>And the nested JSON:</p>
<pre><code>{
"NAMESPACE": {
"TRANSLATION_ID": "A value"
}
};
</code></pre>
<p>I am successfully loading the translation using <code>$translateProvider.useStaticFilesLoader({prefix: 'i18n/locale-', suffix: '.json'});</code>, and I make use of other functions of the provider such as <code>$translateProvider.addInterpolation('$translateMessageFormatInterpolation');</code>.</p>
<p>The <a href="https://angular-translate.github.io/docs/#/guide" rel="nofollow noreferrer">documentation</a> shows examples of nested translation using the <a href="https://angular-translate.github.io/docs/#/guide/03_using-translate-service" rel="nofollow noreferrer">service</a> directly, but not the <a href="https://angular-translate.github.io/docs/#/guide/04_using-translate-filter" rel="nofollow noreferrer">filter</a>.</p>
<p><a href="https://stackoverflow.com/questions/33537395/angular-translate-using-usestaticfilesloader-to-load-nested-json">I found a possibly related issue here</a>.
First of all, using the code in the JSFifddle breaks the <code>$translateProvider</code> functions (I got it somehow fixed by extending the replacing variable like so: <code>$TranslateProvider = angular.extend(m, $TranslateProvider);</code> after injecting <code>$translateProvider</code> as <code>m</code> and add <code>pascalprecht.translate</code> as a module dependency, and add <code>var</code> declarations to be able to <code>'use strict'</code>) - so right off the bat it doesn't seem to be a solid solution.</p>
<p>With that JSFiddle code, I got the <em>directive</em> to work, at least for non-nested cases (which are fine and all, but not what's needed here, so I didn't bother testing the nested cases) but not the filter (which I need working for both nested and non-nested translations).</p>
<p>It seems to me namespaced translations should be a pretty big deal, and therefore should be available for all the 3 translation methods (service, directive and filter).</p>
<p>"service" method is rather limited ($translate service doesn't provide a two-way data binding which means more code to listen to events - <a href="https://angular-translate.github.io/docs/#/guide/03_using-translate-service#using-$translate-service_things-to-keep-in-mind" rel="nofollow noreferrer">see doc</a> - and, well, the fact that loading all the interface's string translation in the app's controller/service seems to be a pretty bad practice ; views/templates are here for that if I'm not mistaken).</p>
<p>Has anyone found a solution to that, or is that angular-translate nested JSON works only for the service?</p> | 2 |
EPPlus and Deleting sheets | <p>So I'm using EPPlus to populate a spreadsheet with data. Under certain conditions a sheet will be intentionally deleted, leaving only one sheet with data. The code runs without errors and runs when all sheets are left in, but when after I delete sheets, save and open the workbook I get a series of warnings and errors. The workbook <em>will</em> open normally after that and my process others seems to work fine. Any thoughts? Is deleting the sheets causing the OOXML to be come invalid, and I'm missing a step? Thanks.</p>
<p><a href="https://i.stack.imgur.com/cLUES.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cLUES.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/GvyIG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GvyIG.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/8CBxv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8CBxv.png" alt="enter image description here"></a></p>
<pre><code> Using template As New MemoryStream(My.Resources.POWER_DOCKET_V2_Template)
Using excel As New ExcelPackage(template)
For worksheet = excel.Workbook.Worksheets.Count To 1 Step -1
Dim grid = CType(radPageViewList.Find(Function(page) page.Name = pageGridSheetMap.Find(Function(sheet) sheet.WorksheetName = excel.Workbook.Worksheets(worksheet).Name).PageViewPageName).Controls(0), RadGridView)
Dim workSheetForSelectedGrid As ExcelWorksheet = excel.Workbook.Worksheets(pageGridSheetMap.Find(Function(g) g.RadGridViewName = selectedGid.Name).WorksheetName)
Dim rowRange As String = pageGridSheetMap.Find(Function(r) r.RadGridViewName = grid.Name).RowRange
Dim sheetRange As String = pageGridSheetMap.Find(Function(r) r.RadGridViewName = grid.Name).SheetRange
Dim rightMostColumn As Integer = pageGridSheetMap.Find(Function(r) r.RadGridViewName = grid.Name).RightMostColumn
If exportSelectedGridOnly = True And excel.Workbook.Worksheets(worksheet).Name <> workSheetForSelectedGrid.Name Then
excel.Workbook.Worksheets.Delete(worksheet)
Else
WriteRows(excel.Workbook.Worksheets(worksheet), grid, rowRange, sheetRange, rightMostColumn)
End If
Next worksheet
If Not Directory.Exists(ConfigurationManager.AppSettings("OutlawTempFolder")) Then Directory.CreateDirectory(ConfigurationManager.AppSettings("OutlawTempFolder"))
excel.SaveAs(New FileInfo(filename))
Process.Start(filename)
End Using
End Using
</code></pre> | 2 |
laravel 5.2 NotFoundHttpException in RouteCollection.php line 161: | <p>source code
the link i used is nav.blade.php : </p>
<pre><code>{{link_to_route('register','Sign Up',null,['class'=>'signup-btn tbutton small'])}}
</code></pre>
<p>and routes.php</p>
<pre><code>Route::get('create',[
'as'=>'register',
'uses'=>'RegistrationController@create'
]);
</code></pre>
<p>error :</p>
<p>Sorry, the page you are looking for could not be found.</p>
<pre><code>1/1
NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 821
at Router->findRoute(object(Request)) in Router.php line 691
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
</code></pre>
<p>thanks</p> | 2 |
Is there a way to use html buttons to add text or number values to an input field using javascript | <p>Basically I'm trying to make a page that looks and works like a simple calculator. Can I use html buttons that when clicked add a number to the input field, then when another button is clicked, another number is added to the string.<br>
Here is the html I've used to set up the buttons and "text" entry field. The function writeNumbers is where I intended to write the JS code to make this work. Any ideas on how to set up this functionality would be greatly welcomed!</p>
<pre><code><p id=demo><p>
<input id="text" type="text">
<button id="seven" type="button" onclick=writeNumbers()>7</button>
<button id="eight" type="button" onclick=writeNumbers()>8</button>
<button id="nine" type="button" onclick=writeNumbers()>9</button>
<br>
<button id="four" type="button" onclick=writeNumbers()>4</button>
<button id="five" type="button" onclick=writeNumbers()>5</button>
<button id="six" type="button" onclick=writeNumbers()>6</button>
<br>
<button id="one" type="button" onclick=writeNumbers()>1</button>
<button id="two" type="button" onclick=writeNumbers()>2</button>
<button id="three" type="button" onclick=writeNumbers()>3</button>
<br>
<button id="cancel" type="button" onclick=writeNumbers()>C</button>
<button id="zero" type="button" onclick=writeNumbers()>0</button>
<button id="equals" type="button" onclick=writeNumbers()>=</button>
</code></pre>
<p>I was considering using adding text to the text to the "p" element with 'demo' id as below but thought this was impractical</p>
<pre><code>document.getElementById("demo").innerHTML = "7";
</code></pre>
<p>I had also tried using an event listener for the button with a document.write link thing but the number would not be entered into the box. Don't think document.write can be used with input fields. Plus this the code below is not an exact excerpt </p>
<pre><code>document.getElementById("seven").addEventListener("click", document.write("7").);
</code></pre>
<p>Tried using the javascript code in the link below, it seemed ideal and could work if I add to it</p>
<p><a href="https://stackoverflow.com/questions/13941055/add-a-string-of-text-into-an-input-field-when-user-clicks-a-button">add-a-string-of-text-into-an-input-field-when-user-clicks-a-button</a></p>
<p>I hope this helps clarifies what the aim is, please ask if you guys need anything else</p> | 2 |
How does netstat know the number of bytes received and sent? | <p>I want to create a simple application that displays the number of bytes downloaded and uploaded. I noticed that <code>netstat</code> does just that (when using the <code>-e</code> switch):</p>
<p><a href="https://i.stack.imgur.com/F3H43.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F3H43.png" alt="enter image description here"></a></p>
<p>How does <code>netstat</code> knows this information, does it call a Windows API function or something?</p> | 2 |
Cordova wait until user gave premission to use location services | <p>I have to check if the user disabled the location services i do this like so: </p>
<pre><code>cordova.plugins.diagnostic.isLocationEnabled(function(enabled) {
if (enabled === false) {
$state.go("errorTwo");
}
}, function(error) {
alert("The following error occurred: " + error);
});
}
</code></pre>
<p>But the problem is, that if the user starts the app the first time, the error already runs. The function should wait until the user gave premission to use the location services. How can I do this?
Any help much appreciated! </p> | 2 |
Redirect thank you messages based on conditional form field selects using javascript | <p>I am very new to javascript so this may be easy to some. I am trying to generate a thank you message based on if a visitor selects option "0 to 120,000" <strong>AND</strong> "option 0 to 6 months". Any help with this is greatly appreciated.</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-js lang-js prettyprint-override"><code>function redirect() {
var businessrev = document.getElementById("annual_business_revenue");
var time = document.getElementById("Time")
for (var i = 0; i < selections.options.length; i++) {
if ((businessrev.options[i].selected == 1) && (time.options[i].selected == 1)) {
location.href = "http://www.bing.com";
} else {
location.href = "http://www.google.com";
}
}
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><form action="javascript:redirect();">
<select name="annual_business_revenue">
<option value="revenue1">0 to 120,000</option>
<option value="revenue2">NOT 0 to 120,000</option>
</select>
<select name="Time">
<option value="time1">0 to 6months</option>
<option value="time2">NOT 0 to 6months</option>
</select>
<input type="submit" value="Submit" />
</form></code></pre>
</div>
</div>
</p> | 2 |
update array in mongoDB document by variable index | <p>How can I update an array in a mongoDB document by index, which is stored in a variable?</p>
<pre><code>{
_id: 'IDString',
field: [ bla, bla, old, bla ];
}
let i = 2;
Collection.update(
{ _id: 'IDString' },
{ $set:
{ 'field.$.i': 'new' }
}
);
</code></pre>
<p>So the result should be:</p>
<pre><code>{
_id: 'IDString',
field: [ bla, bla, new, bla ];
}
</code></pre>
<p>My code wouldn't work, as I want to use the <em>variable</em> <code>i</code>.</p> | 2 |
Initialize a view of different layout in Main Activity | <p>i am building the login screen which takes the details. i Am trying to put those details on the navigation View where your name-email can be seen. i saved the details using shared preference.
The problem is when i am updating those views its throwing NULL POINT EXCEPTION. SO, how to intialize a view of another layout in MAin Activity</p>
<p>My LOG</p>
<pre><code>07-05 12:02:39.549 24377-24377/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: rishabh.example.com.navigationdrawer, PID: 24377
java.lang.RuntimeException: Unable to start activity ComponentInfo{rishabh.example.com.navigationdrawer/rishabh.example.com.navigationdrawer.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.addView(android.view.View)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.addView(android.view.View)' on a null object reference
at rishabh.example.com.navigationdrawer.MainActivity.onCreate(MainActivity.java:58)
at android.app.Activity.performCreate(Activity.java:6010)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
</code></pre>
<p>Part of the code from MainActivity which is initializing the view.</p>
<pre><code>protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
linearLayout=(LinearLayout)findViewById(R.id.base_navbar_id);
LayoutInflater inflater= (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v=inflater.inflate(R.layout.navigation_drawer_head,null);
name1= (TextView)v.findViewById(R.id.name_navDrawer);
//login window which runs only one time when app is installed
myPreferences = new MyPreferences();
if (MyPreferences.isFirst(this)) {
Intent intent=new Intent(this,LoginActivity.class);
startActivity(intent);
}
SharedPreferences sharedPreferences=((DataProvider)getApplicationContext()).getSharedPreferences("MY_LOGIN",MODE_PRIVATE);
if(sharedPreferences.getBoolean("IS_TRUE",false)) {
Log.i("tag", "data:" + sharedPreferences.getString("MY_NAME", "Name"));
name1.setText(sharedPreferences.getString("MY_NAME", "Name"));
linearLayout.addView(name1);
}
</code></pre>
<p>My navigation_drawer_head.xml file</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="140dp"
android:id="@+id/base_navbar_id"
android:background="@android:color/holo_orange_light">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:id="@+id/imageView"
android:src="@drawable/my_image"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="56dp"
android:layout_marginStart="56dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7"
android:layout_marginTop="30dp"
android:hint="Name"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="25dp"
android:id="@+id/name_navDrawer" />
</LinearLayout>
</code></pre>
<p>activity_main.xml</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawerLayout"
tools:context="rishabh.example.com.navigationdrawer.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include android:layout_height="wrap_content"
android:layout_width="match_parent"
layout="@layout/toolbar_layout"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container_fragment">
</FrameLayout>
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/navView"
android:layout_gravity="start"
app:menu="@menu/drawer_menu"
app:headerLayout="@layout/navigation_drawer_head"
>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
</code></pre> | 2 |
How to run Protractor in Bamboo CI | <p>I am trying to run my protractor test case in Bamboo CI but it throws an installation error. </p>
<p>I am able to install node modules using npm task but somehow I am not able to install and run protractor in my bamboo plan. Is there a different way of doing it or I am doing something wrong.</p>
<p>Please find attach the snapshot from my bamboo plan :</p>
<p>Npm install
<a href="https://i.stack.imgur.com/lwcEZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lwcEZ.png" alt="enter image description here"></a></p>
<p>Protractor Task</p>
<p><a href="https://i.stack.imgur.com/GOSBa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GOSBa.png" alt="enter image description here"></a></p>
<p>And my error log is as follow </p>
<pre><code>/tmp/RDMPDEV-MAP-JOB1-91-ScriptBuildTask-6009702493071779000.sh: line 1: protractor: command not found
</code></pre>
<p>Please advice</p> | 2 |
How to use vbApplicationModal with button and icon values in MsgBox | <p>I'm working on a personal project in VBScript, and I want to use the <code>vbApplicationModal</code> constant, whereby clicking out of the window will cause it to flash, like an error message would. Problem is, I have no idea where to put it in the MsgBox. I have:</p>
<pre><code>X=MsgBox("Your details from this computer are being harvested using an altered malicious build of IBM Watson.", 0+48+4096, "IBM Watson")
</code></pre>
<p>However, I do not know where to put <code>vbApplicationModal</code>, or the alternative value (0). As you can see, I already used the values for icons and buttons rather than their vb codes (0 means there is only 'OK', 48 means there is a yellow triangular <strong><em>!</em></strong>, 4096 means the window is always on top of other windows) because it is shorter. Do I have to use the value as well, or can I mix vb values and codes?</p> | 2 |
SQL - format INT to date and add condition | <p>I have a table with a date column. This column is an INT and contains dates in the format YYYYMMDD (for example 20160713). Now I want to get all rows where these dates are after today. I tried the following:</p>
<pre><code>SELECT ID, startdate, comment
FROM comments
WHERE startdate > getdate
</code></pre>
<p>But that results in to following error:</p>
<blockquote>
<p>Arithmetic overflow error converting expression to data type datetime.</p>
</blockquote>
<p>So I tried it by formatting it to a dd/mm/yyyy format</p>
<pre><code>CONVERT(VARCHAR(10), (convert(date,CONVERT(varchar(10),[startdate],103))),103) > getdate()
</code></pre>
<p>but that results into this error:</p>
<blockquote>
<p>The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.</p>
</blockquote>
<p>Any ideas how to do this?</p> | 2 |
tomee webservice doesn't deploy - asm error - Unable to create annotation scanner for web module simple-webservice: 43626 | <p>I am trying to deploy basic webservice template to tomee, I have tried windows 7 64 bit and windows 8 64 bit with java versions 1.8.0_25(64bit), 1.8.0_91(64bit) (this java version used to build code and run tomee). The webservice is basic example taken from internet - suorce code is below and well as the stack trace. Tomee 1.7.0 and 1.7.1 strait downloaded from internet with no code changes or jar changes. What could possibly cause this issue - do I need to replace default tomee jar(s) ?</p>
<p>code:</p>
<pre><code>package org.superbiz.calculator.ws;
import javax.ejb.Stateless;
import javax.jws.WebService;
@Stateless
@WebService ( portName = "CalculatorPort" ,
serviceName = "CalculatorService" ,
targetNamespace = "http://superbiz.org/wsdl" ,
endpointInterface = "org.superbiz.calculator.ws.CalculatorWs" )
public class Calculator implements CalculatorWs
{
public int sum( int add1 , int add2 )
{
return add1 + add2;
}
public int multiply( int mul1 , int mul2 )
{
return mul1 * mul2;
}
public String hello()
{
return "hello";
}
}
/* ################################## */
package org.superbiz.calculator.ws;
import javax.jws.WebService;
@WebService ( targetNamespace = "http://superbiz.org/wsdl" )
public interface CalculatorWs
{
public int sum( int add1 , int add2 );
public int multiply( int mul1 , int mul2 );
public String hello();
}
</code></pre>
<p>stack trace:</p>
<pre><code>INFO - ------------------------- localhost -> /host-manager
INFO - Configuring enterprise application: C:\apache-tomee-plus-7.0.0\webapps\host-manager
INFO - Enterprise application "C:\apache-tomee-plus-7.0.0\webapps\host-manager" loaded.
INFO - Assembling app: C:\apache-tomee-plus-7.0.0\webapps\host-manager
INFO - using context file C:\apache-tomee-plus-7.0.0\webapps\host-manager\META-INF\context.xml
INFO - Deployed Application(path=C:\apache-tomee-plus-7.0.0\webapps\host-manager)
INFO - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TL
Ds were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO - Deployment of web application directory C:\apache-tomee-plus-7.0.0\webapps\host-manager has finished in 391 ms
INFO - Deploying web application directory C:\apache-tomee-plus-7.0.0\webapps\manager
INFO - ------------------------- localhost -> /manager
INFO - Configuring enterprise application: C:\apache-tomee-plus-7.0.0\webapps\manager
INFO - Enterprise application "C:\apache-tomee-plus-7.0.0\webapps\manager" loaded.
INFO - Assembling app: C:\apache-tomee-plus-7.0.0\webapps\manager
INFO - using context file C:\apache-tomee-plus-7.0.0\webapps\manager\META-INF\context.xml
INFO - Deployed Application(path=C:\apache-tomee-plus-7.0.0\webapps\manager)
INFO - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TL
Ds were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO - Deployment of web application directory C:\apache-tomee-plus-7.0.0\webapps\manager has finished in 69 ms
INFO - Deploying web application directory C:\apache-tomee-plus-7.0.0\webapps\ROOT
INFO - ------------------------- localhost -> /
INFO - Configuring enterprise application: C:\apache-tomee-plus-7.0.0\webapps\ROOT
INFO - Enterprise application "C:\apache-tomee-plus-7.0.0\webapps\ROOT" loaded.
INFO - Assembling app: C:\apache-tomee-plus-7.0.0\webapps\ROOT
INFO - Deployed Application(path=C:\apache-tomee-plus-7.0.0\webapps\ROOT)
INFO - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TL
Ds were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO - Deployment of web application directory C:\apache-tomee-plus-7.0.0\webapps\ROOT has finished in 60 ms
INFO - Deploying web application directory C:\apache-tomee-plus-7.0.0\webapps\simple-webservice
INFO - ------------------------- localhost -> /simple-webservice
SEVERE - ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/simple-webservice]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module simple-webse
rvice: 43626
at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2256)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1151)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1112)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5093)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 10 more
Caused by: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module simple-webservice: 43626
at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:883)
at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:231)
at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2254)
... 16 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 43626
at org.apache.xbean.asm5.ClassReader.readClass(Unknown Source)
at org.apache.xbean.asm5.ClassReader.accept(Unknown Source)
at org.apache.xbean.asm5.ClassReader.accept(Unknown Source)
at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1170)
at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:147)
at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:160)
at org.apache.openejb.config.FinderFactory$OpenEJBAnnotationFinder.<init>(FinderFactory.java:546)
at org.apache.openejb.config.FinderFactory.newFinder(FinderFactory.java:267)
at org.apache.openejb.config.FinderFactory.create(FinderFactory.java:80)
at org.apache.openejb.config.FinderFactory.createFinder(FinderFactory.java:69)
at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:875)
... 18 more
SEVERE - Error deploying web application directory C:\apache-tomee-plus-7.0.0\webapps\simple-webservice
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Stan
dardHost[localhost].StandardContext[/simple-webservice]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:730)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
INFO - Deployment of web application directory C:\apache-tomee-plus-7.0.0\webapps\simple-webservice has finished in 61 ms
INFO - Starting ProtocolHandler [http-nio-8080]
INFO - Starting ProtocolHandler [ajp-nio-8009]
INFO - Server startup in 621 ms
</code></pre> | 2 |
html/css - html website with multiple pages - have one menu that can be called? | <p>MY SERVER IS TOO BASIC TO SUPPORT PHP/JAVASCRIPT, ANY SUGGESTIONS? </p>
<p>I have a HTML website with multiple pages. I am using an identical menu on all pages and when I add a page I have to each page and edit the code.</p>
<p>I am wondering is there a way of adding a menu page that can be called?</p>
<p>I am using CSS/HTML is it possible to do anything to help? I have researched a bit and I think it involves PHP, but can PHP be used in conjuncion with CSS/HTML?</p> | 2 |
OpenGL - How to track a moving object? | <p>I want to learn how I can track a moving object in OpenGL. The position of the object will be a continuous input. Also, what if when the object moves out of the screen?</p> | 2 |
Windows Driver: ZwReadFile returns STATUS_INVALID_HANDLE | <p>In learning how to write Windows drivers, I am modifying the <a href="https://github.com/Microsoft/Windows-driver-samples" rel="nofollow">Windows Driver Sample</a> for the AvsCamera.</p>
<p>I want to replace the simulated image with one from a bitmap file. In the <code>Synthesizer.cpp</code> file, I have commented out the calls to <code>SynthesizeBars()</code>, <code>ApplyGradient()</code>, and <code>EncodeNumber()</code> within the <code>Synthesize()</code> method, and replaced them with this code:</p>
<pre><code>KIRQL level = KeGetCurrentIrql();
if( level == PASSIVE_LEVEL ) {
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Ok to perform file io.");
UNICODE_STRING filename;
OBJECT_ATTRIBUTES fileAttr;
IO_STATUS_BLOCK fhStatus;
HANDLE fh;
NTSTATUS status;
RtlInitUnicodeString(&filename, L"\\SystemRoot\\AvsCameraTest.bmp");
InitializeObjectAttributes(&fileAttr, &filename, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
status = ZwOpenFile(&fh, FILE_READ_DATA, &fileAttr, &fhStatus, 0, FILE_RANDOM_ACCESS);
if( NT_SUCCESS(status) ) {
status = ZwReadFile(&fh, NULL, NULL, NULL, &fhStatus, m_Buffer, m_Length, /*&byteOffset*/NULL, NULL);
if( NT_SUCCESS(status) ) {
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Read bitmap file success.\n");
} else DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Unable to read bitmap file [0x%x].\n", status);
ZwClose(fh);
} else DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Unable to open bitmap file [0x%x].\n", status);
} else DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Do not perform file io at IRQ level 0x%x.\n", level);
</code></pre>
<p>This is my first step: I am aware that I'm ignoring the bmp header.</p>
<p>The call to <code>ZwOpenFile()</code> is successful, but <code>ZwReadFile()</code> returns <code>STATUS_INVALID_HANDLE</code>.</p>
<p>I've tried using a <code>LARGE_INTEGER byteOffset</code>, and <code>FILE_SYNCHRONOUS_IO_NONALERT</code> instead of <code>FILE_RANDOM_ACCESS</code>. I've also tried using <code>ZwCreateFile()</code> with <code>GENERIC_READ</code> and <code>FILE_ATTRIBUTE_READONLY</code> parameters.</p>
<p>I have been successful in writing to a file using similar code.</p>
<p>What is the issue with my attempt at acquiring the proper filehandle for reading?</p> | 2 |
reactjs lifecycle is there a visual flowchart? | <p>I'm running into alot of issues with reactjs mainly because I'm not exactly sure of the component lifecycle and at <em>precisely</em> what point things like setState do things.</p>
<p>I am aware there is a page titled "Component Lifecycle" but I need a much more detailed visual diagram showing how reactjs lifecycle works, in particular showing where and when setState does things.</p>
<p>Is there such a diagram?</p> | 2 |
Error while setting up local cluster with service fabric SDK version 2.1.150.X | <p>While creating local cluster with latest service fabric SDK, I got following errors with <strong>Visual Studio 2013 Update 5</strong> while it works fine with Visual Studio 2015 Update 3:</p>
<pre>
Cluster manifest validation failed with exception System.ArgumentException: Error occurs in section Federation, parameter System.
Fabric.Management.ServiceModel.SettingsOverridesTypeSectionParameter...
OR
Cluster manifest validation failed with exception System.ArgumentException: Section FaultAnalysisService found in cluster manifest but not Configurations.csv in system.fabric.management.dll
</pre>
<p><b>What I did to fix it?</b></p>
<p>If you closely look into error, you will find that following two files settings are not compatible.
C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\Configurations.csv
and
C:\Program Files\Microsoft SDKs\Service Fabric\ClusterSetup\NonSecure\ClusterManifestTemplate.xml</p>
<p>Just disable following in ClusterManifestTemplate.xml:</p>
<pre><code><Section Name="Federation">
<Parameter Name="NodeIdGeneratorVersion" Value="V3" />
<!-- <Parameter Name="UnresponsiveDuration" Value="0" /> -->
</Section>
and
<!-- <Section Name="FaultAnalysisService">
<Parameter Name="TargetReplicaSetSize" Value="5" />
<Parameter Name="MinReplicaSetSize" Value="3" />
</Section> -->
</code></pre> | 2 |
Cannot set block-no-empty to false in stylelint | <p>Given the following in <code>package.json</code>:</p>
<p><code>"stylelint": {
"extends": "stylelint-config-standard",
"rules": {
"string-quotes": "single",
"block-no-empty": false,
"indentation": 2
}
}
</code>
I'm having trouble figuring out how to override <code>block-no-empty</code>. If I set it to <code>false</code>, I get the error:</p>
<p><code>Invalid Option: Unexpected option value "false" for rule "block-no-empty"</code></p>
<p>Am I missing some kind of override syntax?</p> | 2 |
Sending file to VirusTotal with MVC | <p>I am a student trying out another mini project where the user can upload a CSV file to the web server. But before I can create another program to execute the file, I would like to send the file to virustotal to have it check for virus. </p>
<p>I tried but I got an error: "cannot convert from 'string' to 'System.IO.FileInfo'"</p>
<p>Here is my codes: </p>
<p><strong>Controller</strong></p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VirusTotalNET;
namespace Testing_1.Controllers
{
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
public ActionResult Upload(HttpPostedFileBase file)
{
string filename = file.FileName;
VirusTotal vtObj = new VirusTotal("%API KEY%");
string resID = vtObj.ScanFile(file.FileName);
string path = Server.MapPath("~/CSV/" + file.FileName);
file.SaveAs(path);
ViewBag.Path = path;
return View();
}
}
}
</code></pre>
<p><em>I got the error at this line: string resID = vtObj.ScanFile(file.FileName);</em></p>
<p><strong>Index</strong></p>
<pre><code>@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="File" id="file"/>
<input type="submit" value="Upload" />
}
</code></pre>
<p><strong>Upload</strong></p>
<pre><code>@{
ViewBag.Title = "Upload";
}
<h2>Uploaded: @ViewBag.Path</h2>
</code></pre>
<p>Please help me Thank you </p> | 2 |
java gui paintComponent refresh | <p>I am learning java gui interface and wrote a program that has a button. Each time the button is clicked, a random sized rectangle will be added to the screen. But instead of adding it to the screen, the program keeps erasing the old one, which I want to keep on the screen. Here is my code. I tried to do paint() and it did not work. Thanks in advance.</p>
<pre><code>import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class SimpleGui implements ActionListener {
JFrame frame = new JFrame();
public static void main(String[] args){
SimpleGui gui = new SimpleGui();
gui.go();
}
public void go(){
JButton button = new JButton("Add a rectangle");
MyDrawPanel panel = new MyDrawPanel();
button.addActionListener(this);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(BorderLayout.SOUTH, button);
frame.getContentPane().add(BorderLayout.CENTER, panel);
frame.setSize(300, 300);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent event){
frame.repaint();
}
class MyDrawPanel extends JPanel{
public void paintComponent(Graphics g){
g.setColor(Color.blue);
int height = (int) (Math.random()*120 + 10);
int width = (int) (Math.random()*120 + 10);
int x = (int) (Math.random()*40 + 10);
int y = (int) (Math.random()*40 + 10);
g.fillRect(x, y, height, width);
}
}
}
</code></pre> | 2 |
Canvas arc and fill with gradient | <p>I have the following source code:</p>
<p><strong>HTML:</strong></p>
<pre><code><canvas id="main" width="500" height="500" style="border:1px solid black;"></canvas>
</code></pre>
<p><strong>JavaScript:</strong></p>
<pre><code>function myRnd(val)
{
return parseInt(Math.random() * val);
}
function rndCircles() {
var maxCircles = 30;
for (var r = 1; r <= maxCircles; r++) {
var c = document.getElementById("main");
var x = myRnd(c.clientWidth);
var y = myRnd(c.clientHeight);
var radius = parseInt(Math.random() * 30);
var ctx = c.getContext("2d");
// Create gradient
var grd = ctx.createRadialGradient(75, 50, 5, 90, 60, 100);
grd.addColorStop(0, 'rgb(' + myRnd(255) + ', ' + myRnd(255) + ',' + myRnd(255) + ')');
grd.addColorStop(1, 'white');
ctx.beginPath();
ctx.arc(x, y, radius, 0, 2 * Math.PI,false);
// Fill with gradient
ctx.fillStyle = grd;
ctx.fill();
ctx.lineWidth = 5;
//ctx.strokeStyle = '#003300';
ctx.stroke();
}
}
rndCircles();
</code></pre>
<p>I cannot see each arc filled with a different color/gradient on Chrome. Why? Am I missing something?</p>
<p>Fiddle here:
<a href="https://jsfiddle.net/j9wst2yd/" rel="nofollow">https://jsfiddle.net/j9wst2yd/</a></p> | 2 |
Clickable html button counter using php or js | <p>I am very new to php and javascript and I was wondering how I could make a global counter that adds 1 to it every time a user presses a button. The number would stay the same even if someone is on a different computer or refreshes the page. I had this using javascript: </p>
<pre><code><script type="text/javascript">
var clicks = 0
function onClick() {
clicks += 1;
document.getElementById("clicks").innerHTML = clicks;
};
</script>
<button type="button" onClick="onClick()">Click me</button>
<footer>Clicks: <a id="clicks">0</a></footer>
</code></pre>
<p>But when ever someone refreshes the page, it resets the number, and it is not global. I tried making something in php which is:</p>
<pre><code><?php
$clicks = 0
public function clickButton()
{
$clicks = $clicks + 1
}
?>
</code></pre>
<p>but I have no idea what I'm doing and how to call the php function or display the php variable.</p> | 2 |
#Bootstrap 3.2.0 #modal-dialogs #jquery | <p>following is the code for which modal-dialog is not popping up.I am using Bootstrap 3.2.0 and jquery is also above 1.9.0.Help me out if i am missing something.And please let me know for any further information and Thanks in advance.</p>
<pre><code><div class="modal fade" id = "login" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModal">Login or Registeration </h4>
</div>
<div class="modal-body">
<form action="#" method="POST">
<div class="form-group">
<input type="email" class="form-control" placeholder="Email">
</div>
<div class="form-group">
<input type="password" class="form-control" placeholder="Password">
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Login">
<input type="submit" class="btn btn-primary" value="Register">
</div>
</form>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-primary" data-dismiss="modal">
Forgot Password?</a>
</div>
</div>
</div>
</div>
<div class="jumbotron" id="home">
<div class="container-fluid">
<h1>The Design Store</h1>
<p>fdgdhfjgkhloj;jlkhhjgfdshjkl
sgdhfjgkhkjlrtyguuhjkoxcvbn
dgfhmb,nm,asdfghjkl;';lklkjhjhgfddfghjhg'..</p>
<p>wefrgdthyjgukiosdfghjkgh
ssdfghjklertyuwertyuicvbnm,
sdfghjklsdfghjkljjhgfdsdfghjkjhgddsadfg</p>
<p><a href="#" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#login">My Account</a></p>
</div>
</div>
</code></pre> | 2 |
Android - equivalent of UITableViewCell? | <p>Is there an equivalent of a <code>UITableViewCell</code>for a <code>RecyclerView</code> or (any other recyclable view) in Android ? None of my searches have given me any direction. Some help would be really appreciated.</p>
<p>I understand that a <code>RecyclerView</code> has a position that corresponds to a row in the case of a list. But is this correct, is this the equivalent of <code>UITableViewCell</code> in Android ?</p> | 2 |
Are Twilio video and client Javascript SDK cross-platform? | <p>I wanted to know if I can use Twilio Video or Client JavaScript SDK for both web and mobile development. </p>
<p>I have no background in iOS or Android Development so it would be good if I can just use JavaScript SDK use react native or wrap it in Cordova.</p> | 2 |
How to install and import angular 2 '@angular/router'? | <p>I'm trying to use @angular/router from this <a href="https://angular.io/docs/ts/latest/guide/router.html" rel="nofollow">documentation</a>. I tried to install this module using npm: <code>npm install @angular/router --save</code>
And I tried to import this module:</p>
<pre><code>import { ROUTER_DIRECTIVES } from '@angular/router';
</code></pre>
<p>I get an error "Cannot find module '@angular/router'"
I looked at node_modules/@angular/router directory. It has 2 directories: angular1 and angular2. Should I import this module using:</p>
<pre><code>import { ROUTER_DIRECTIVES } from '@angular/router/angular2/router.js';
</code></pre>
<p>Or this is incorrect module? It has only 3 files in angular2 directory: router.js, router.dev.js, router.min.js</p> | 2 |
graphlab create sframe how to get SArray median | <p>I'm studying graphlab create
with </p>
<pre><code>data=graphlab.SFrame.read_csv('test.csv')
</code></pre>
<p>im trying to get median of one of columns</p>
<pre><code>data_train.fillna(('Credit_History',data_train['Credit_History'].median()))
</code></pre>
<p>but I got error</p>
<pre><code>---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-247-50ed3eb09dcc> in <module>()
----> 1 data_train.fillna(('Credit_History',data_train['Credit_History'].median()))
AttributeError: 'SArray' object has no attribute 'median'
</code></pre>
<p>data.show() will show median of this column though
anyone knows how to fix this? </p> | 2 |
Socket.io and Node.Js multiple servers | <p>I'm new to Web Sockets in general, but get the main concept.</p>
<p>I am trying to build a simple multiplayer game and would like to have a server selection where I can run sockets on multiple IPs and it will connect the client through that, to mitigate connections in order to improve performance, this is hypothetical in the case of there being thousands of players at once, but would like some insight into how this would work and if there are any resources I can use to integrate this before hand, in order to prevent extra work at a later date. Is this at all possible, as I understand it Node.Js runs on a server and uses the Socket.io dependencies to create sockets within that, so I can't think of a possible solution to route it through another server unless I had multiple sites running it separately.</p> | 2 |
Less.js aggressively caching imported less files | <p>I'm running Less through JavaScript right now, with <code>less = { env: ‘development’ };</code>, and I have a primary file, called main.less, which houses all my <code>@import</code>, however none of my imported "children" .less files are updating, and appears to just be using the old cached styles. </p>
<p>Put a line of code into main.less, compiles. Remove it and put into nav.less, compiles main.less, and appears to yank nav.less from the cache. Ugh.</p>
<p>I've tried <code>less.refresh();</code>, and even tried <code>localStorage.clear();</code>, but nothing seems to change the outcome. </p>
<p>I feel so defeated by this. </p> | 2 |
Have AND Clause if variable is not null in MySQL Select | <p>Hello I am trying to make an If statement inside SQL Select query, I would like to apply only if variable $department is different than NULL. if the variable is different then Null place <code>P2.department = P1.department</code> as AND Clause. </p>
<p>The query line is as follows: </p>
<pre><code>,(SELECT SUM(P2.fee) FROM cases P2 WHERE
IF('$department' IS NULL, 0, P2.department = P1.department) AND curency = 1) as fee_USD
</code></pre>
<p>In the current situation the query is working but it displays wrong results. My question is this is the best way to include <code>P2.department = P1.department AND</code> inside the query. Any help is welcome. </p>
<p>Here is the full query: </p>
<pre><code> SELECT
P1.id
,P1.department
,P1.curency
,P1.fee
,count(P1.id) as count_cases
,(SELECT SUM(P2.fee) FROM cases P2 WHERE
IF('$department' IS NULL, 0, P2.department = P1.department)
AND curency = 1) as fee_USD
FROM cases P1 WHERE 1";
if (!empty($department)) { $sql .= " AND P1.department = '$department'"; }
if (!empty($status)) { $sql .= " AND P1.status = '$status'"; }
</code></pre> | 2 |
Calculate number of days excluding sunday in Hive | <p>I have two timestamps as input. I want to calculate the time difference in hours between those timestamps excluding Sundays.</p>
<p>I can get the number of days using <strong><em>datediff</em></strong> function in hive.</p>
<p>I can get the day of a particular date using <strong><em>from_unixtime(unix_timestamp(startdate), 'EEEE').</em></strong></p>
<p>But I dont know how to relate those functions to achieve my requirement or is there any other easy way to achieve this.</p>
<p>Thanks in Advance.</p> | 2 |
Workaround for NoSuchAlgorithmException not working | <p>I'm getting the following exception when I enable SSL debug via <em>-Djavax.net.debug=ssl</em>:</p>
<pre><code>java.security.NoSuchAlgorithmException: EC AlgorithmParameters not available
</code></pre>
<p>I'm running Centos 6.7, Open JDK 1.8.0_91 & Tomcat 7.0.63</p>
<p>My research indicates that this is a known bug: <a href="https://bugs.centos.org/view.php?id=9482" rel="nofollow noreferrer">https://bugs.centos.org/view.php?id=9482</a></p>
<p>I found numerous sources indicating that a workaround for this is to disable the Elliptic Curve cipher algorithms by setting the following property in the <em>jre/lib/security/java.security</em> file:</p>
<pre><code>jdk.tls.disabledAlgorithms=EC,ECDHE,ECDH
</code></pre>
<p>I looked at my <em>java.security</em> file and found that these algorithms were already disabled:</p>
<pre><code>jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keysize < 768, EC, ECDHE, ECDH
</code></pre>
<p>I tried changing this property to be exactly as shown in the examples I found and that did not work either. I also tried removing the <em>jre/lib/ext/sunec.jar</em> file, which again had no effect.</p>
<p>I've carefully traced my installation of Tomcat to ensure that the <em>jre/lib/security/java.security</em> file I'm modifying is the one Tomcat is running on.</p>
<p>If anyone has any ideas about what is going on here or how I can work around this problem I would be very grateful to get your input.</p>
<p>This question is related to <a href="https://stackoverflow.com/questions/28999410">OpenJDK on OpenShift: "NoSuchAlgorithmException: EC AlgorithmParameters not available"</a> except I'm not using OpenShift and I am able to edit my <em>java.security</em> file to attempt the <em>well known</em> workaround. My problem is that the workaround does not work for me.</p> | 2 |
Parse string to HTML in AngularJs | <p><strong>Source code:</strong></p>
<pre><code><tr ng-repeat="x in orderCsList">
<td class="ctn"><input type="checkbox" ng-model="x.checked"></td>
<td class="ctn">{{ x.wdate }}</td>
<td class="text-left">{{ x.wid }}</td>
<td class="text-left">{{ x.content }}</td>
<td class="text-left">{{ x.suc_yn }}</td>
</tr>
</code></pre>
<p>I have a property(x.contents) that the value is TEST<code><br></code>TEST. How can I "parse" it to <code>HTML</code>?</p>
<p><em>Actual result:</em></p>
<pre><code>TEST`<br>`TEST
</code></pre>
<p><em>Expected result:</em></p>
<p><code>TEST</code><br><code>TEST</code></p> | 2 |
Python, Find the drive letter with windows installed | <p>I started making a program for fun when I encountered a problem. The problem was that I wanted to find the drive letter with windows installed on it (root drive). I assumed there was a function already made for that but I searched for a while and could not find one. </p>
<p>I wrote this code to do what I just described. Is this code redundant and am I being an idiot? There is probably a much easier way...</p>
<pre><code>def root():
root = ""
i = 0
drives = win32api.GetLogicalDriveStrings()
drives = drives.split("\000")[:-1]
for i in range(0, len(drives)):
drives[i] = drives[i].replace("\\", "/")
i = 0
for i in range(0, len(drives)):
if os.path.exists(drives[i] + "Windows"):
root = drives[i]
break
return root
</code></pre>
<p>I suppose someone can use this for testing purposes or what not.</p> | 2 |
Mysql syntax error with stored procedure (workbench) | <p>Ok so this is my current code</p>
<pre><code>delimiter //
Create procedure addFish(in_color varchar(45), in_pattern varchar(45))
BEGIN
INSERT INTO ZenFish
(`ZenColorsID`,`Pattern`, `Hatched` )
VALUES
(
(select idZenColors from ZenColors where ColorName = in_color),
in_pattern,
CURRENT_TIMESTAMP()
);
END
delimiter ;
</code></pre>
<p>It does NOTHING when I press run in mysql workbench. Before I added the delimiter marks it at least gave me a syntax error. Adding delimiter lines seems to be what everyone else on stackoverflow was told to do with this problem, so I did it and now... just nothing happens when I press run, or select it all and press run, or run this statement. De nada.</p> | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.