Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
35,646,446 | android get contentView id | > hi, now i develope android,
>
> and i want to get viewId.
>
> for example,
>
> `onCreat(){
> setContentView(R.layout.a) button bt1 = findViewId(R.id.bt); bt.setOnClickListener(new OnClickListener{ });`
>
> so now, i want to get view Id in `onClickListener`. I think, view Id
> same `R.layout.content` and i try to `findViewId(R.id.content)` but
> this viewid different to `R.layout.a` how can i get viewId? | <android><view> | 2016-02-26 08:01:36 | LQ_EDIT |
35,647,035 | Need of multiple Routes in Asp.net MVC | <p>What is the actual need for multiple routes in an Asp.net MVC application?
We can done all using the default route</p>
| <asp.net-mvc> | 2016-02-26 08:39:18 | LQ_CLOSE |
35,647,569 | Regular expression to allow space between two string? | <p>I have following pattern to validate the String</p>
<pre><code>pattern ="^[a-zA-Z0-9_{}#$\/\-\+@!?()^%$`~|:,.=\[\]]*$"
</code></pre>
<p>But here it is not accepting space between two string as well.Can someone please tell me what changes i have to do in above pattern so it will allow space between two string? But Space should not be allowed at the beginning and end of string.</p>
| <java><regex> | 2016-02-26 09:09:47 | LQ_CLOSE |
35,647,921 | C++ and for/in (?) loops | <p>I'm a bit rusty on C++ (still). Will the "getChildren()" function to the right be called every loop?</p>
<pre><code>for (Node* node : this->m_stage->getChildren()) {
}
</code></pre>
<p>On a side note, what would be the name of this kind of loop? </p>
| <c++> | 2016-02-26 09:28:04 | LQ_CLOSE |
35,649,053 | I can't Set UILable to nil in Swift | I have just started working with Swift. I have a table and I wanna Set it to nil so that I can use an action on it to change its text , right now without nil it shows "optional" text!
@IBOutlet var nameLable: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func helloworldaction(nameTextField: UITextField) {
nameLable.text = "\(nameTextField.text)"
}
but it shows errors when I change it to this:
@IBOutlet var nameLable: UILabel = nil
what should I do?? | <ios><swift><uilabel> | 2016-02-26 10:19:10 | LQ_EDIT |
35,651,097 | How to Pass List<> to Store Proc | I am trying to pass alist to database (sql server 2008 r2) using user defined table types but get some errors my code is:
public int DAL_SaveIncramentSalary(tbl_Employee_Master obj, List<dtIncrementSalary> tbl)
{ try { SqlParameter[] objSqlParameter = new SqlParameter[4]; objSqlParameter[0] = new SqlParameter("@Company_ID", obj.Company_ID); objSqlParameter[1] = new SqlParameter("@Employee_ID", obj.Employee_ID); objSqlParameter[2] = new SqlParameter("@Salary_Month", obj.Govt_DA);
objSqlParameter[3] = new SqlParameter("@dt", SqlDbType.Structured); objSqlParameter[3].Value = tbl; objSqlParameter[3].Direction = ParameterDirection.Input; DataSet fdd = SqlHelper.ExecuteDataset(_cnnString2, "usp_Insert_Increment_Salary_List", CommandType.StoredProcedure, bjSqlParameter); DataSet fddd = SqlHelper.ExecuteDataset(_cnnString2, "usp_Insert_Increment_Salary_List", objSqlParameter); DataSet ds = SqlHelper.ExecuteDataset(_cnnString2, CommandType.StoredProcedure, "usp_Insert_Increment_Salary_List", objSqlParameter); return SqlHelper.ExecuteNonQuery(_cnnString2, CommandType.StoredProcedure, "usp_Insert_Increment_Salary_List", objSqlParameter); } catch (Exception ex) { throw new Exception(ex.Message); } } I got error like this: Dataset dff error : Parameter count does not match Parameter Value count. DataSet fddd error : ailed to convert parameter value from a List`1 to a IEnumerable`1. DataSet ds error :Failed to convert parameter value from a List`1 to a IEnumerable`1.
sql user defined type CREATE TYPE dtIncrementSalary AS TABLE(Head_Id int null,
SalAmt numeric(18,2) null, Per float null, OldSalAmt numeric(18,2) null, OldPer float null ) sql proc alter PROCEDURE [dbo].[usp_Insert_Increment_Salary_List] ( @Company_ID int, @Employee_ID int, @Salary_Month int, @dt dtIncrementSalary readonly ) AS
BEGIN select * from @dt END
| <c#><sql><asp.net><sql-server-2008-r2> | 2016-02-26 11:57:38 | LQ_EDIT |
35,652,717 | DropDownList - ASP.NET Problems | <p>Having trouble with a drop down list in my ASP site</p>
<p>Ok, what am i trying to do? </p>
<p>i want to select a item from my drop list and then fire some code, an example when i click Hek, it loads the correct information i'm after, when i click Dodixie after the page refreshes but not loading the new values, also when i click on a name the drop down text keeps defaulting to Jita again. </p>
<p>here is some code:</p>
<p>Front End: </p>
<pre><code><asp:DropDownList ID="stationSelect" runat="server" CssClass="OverviewText" AutoPostBack="true" OnSelectedIndexChanged="stationSelect_SelectedIndexChanged" >
<asp:ListItem value="0">Jita</asp:ListItem>
<asp:ListItem value="1">Hek</asp:ListItem>
<asp:ListItem value="2">Dodxie</asp:ListItem>
<asp:ListItem value="3"> Armar</asp:ListItem>
<asp:ListItem value="4">Rens</asp:ListItem>
</asp:DropDownList>
</code></pre>
<p>Back End: </p>
<pre><code>protected void stationSelect_SelectedIndexChanged(object sender, EventArgs e)
{
stationSelect.ClearSelection();
stationSelect.SelectedIndex = stationSelect.Items.IndexOf(stationSelect.Items.FindByValue("0"));
{
string OrePriceA = "http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&usesystem=30002187";
XmlDocument xdoc = new XmlDocument();
xdoc.Load(OrePriceA);
TriPrAmarB.Text = GetStat(xdoc, 34, TranType.Buy, StatType.Max);
TriPrAmarS.Text = GetStat(xdoc, 34, TranType.Sell, StatType.Max);
PyrPrAmarB.Text = GetStat(xdoc, 35, TranType.Buy, StatType.Max);
PyrPrAmarS.Text = GetStat(xdoc, 35, TranType.Sell, StatType.Max);
MexPrAmarB.Text = GetStat(xdoc, 36, TranType.Buy, StatType.Max);
MexPrAmarS.Text = GetStat(xdoc, 36, TranType.Sell, StatType.Max);
IsoPrAmarB.Text = GetStat(xdoc, 37, TranType.Buy, StatType.Max);
IsoPrAmarS.Text = GetStat(xdoc, 37, TranType.Sell, StatType.Max);
NocPrAmarB.Text = GetStat(xdoc, 38, TranType.Buy, StatType.Max);
NocPrAmarS.Text = GetStat(xdoc, 38, TranType.Sell, StatType.Max);
ZydPrAmarB.Text = GetStat(xdoc, 39, TranType.Buy, StatType.Max);
ZydPrAmarS.Text = GetStat(xdoc, 39, TranType.Sell, StatType.Max);
MegPrAmarB.Text = GetStat(xdoc, 40, TranType.Buy, StatType.Max);
MegPrAmarS.Text = GetStat(xdoc, 40, TranType.Sell, StatType.Max);
MorPrAmarB.Text = GetStat(xdoc, 11399, TranType.Buy, StatType.Max);
MorPrAmarS.Text = GetStat(xdoc, 11399, TranType.Sell, StatType.Max);
};
stationSelect.ClearSelection();
stationSelect.SelectedIndex = stationSelect.Items.IndexOf(stationSelect.Items.FindByValue("1"));
{
string OrePriceH = "http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&usesystem=30003394";
XmlDocument xdocH = new XmlDocument();
xdocH.Load(OrePriceH);
TriPrAmarB.Text = GetStat(xdocH, 34, TranTypeH.Buy, StatTypeH.Max);
TriPrAmarS.Text = GetStat(xdocH, 34, TranTypeH.Sell, StatTypeH.Max);
PyrPrAmarB.Text = GetStat(xdocH, 35, TranTypeH.Buy, StatTypeH.Max);
PyrPrAmarS.Text = GetStat(xdocH, 35, TranTypeH.Sell, StatTypeH.Max);
MexPrAmarB.Text = GetStat(xdocH, 36, TranTypeH.Buy, StatTypeH.Max);
MexPrAmarS.Text = GetStat(xdocH, 36, TranTypeH.Sell, StatTypeH.Max);
IsoPrAmarB.Text = GetStat(xdocH, 37, TranTypeH.Buy, StatTypeH.Max);
IsoPrAmarS.Text = GetStat(xdocH, 37, TranTypeH.Sell, StatTypeH.Max);
NocPrAmarB.Text = GetStat(xdocH, 38, TranTypeH.Buy, StatTypeH.Max);
NocPrAmarS.Text = GetStat(xdocH, 38, TranTypeH.Sell, StatTypeH.Max);
ZydPrAmarB.Text = GetStat(xdocH, 39, TranTypeH.Buy, StatTypeH.Max);
ZydPrAmarS.Text = GetStat(xdocH, 39, TranTypeH.Sell, StatTypeH.Max);
MegPrAmarB.Text = GetStat(xdocH, 40, TranTypeH.Buy, StatTypeH.Max);
MegPrAmarS.Text = GetStat(xdocH, 40, TranTypeH.Sell, StatTypeH.Max);
MorPrAmarB.Text = GetStat(xdocH, 11399, TranTypeH.Buy, StatTypeH.Max);
MorPrAmarS.Text = GetStat(xdocH, 11399, TranTypeH.Sell, StatTypeH.Max);
};
stationSelect.ClearSelection();
// ENTER TEXT HERE
{
string OrePriceD = "http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&usesystem=30002659";
XmlDocument xdocD = new XmlDocument();
xdocD.Load(OrePriceD);
TriPrAmarB.Text = GetStat(xdocD, 34, TranTypeD.Buy, StatTypeD.Max);
TriPrAmarS.Text = GetStat(xdocD, 34, TranTypeD.Sell, StatTypeD.Max);
PyrPrAmarB.Text = GetStat(xdocD, 35, TranTypeD.Buy, StatTypeD.Max);
PyrPrAmarS.Text = GetStat(xdocD, 35, TranTypeD.Sell, StatTypeD.Max);
MexPrAmarB.Text = GetStat(xdocD, 36, TranTypeD.Buy, StatTypeD.Max);
MexPrAmarS.Text = GetStat(xdocD, 36, TranTypeD.Sell, StatTypeD.Max);
IsoPrAmarB.Text = GetStat(xdocD, 37, TranTypeD.Buy, StatTypeD.Max);
IsoPrAmarS.Text = GetStat(xdocD, 37, TranTypeD.Sell, StatTypeD.Max);
NocPrAmarB.Text = GetStat(xdocD, 38, TranTypeD.Buy, StatTypeD.Max);
NocPrAmarS.Text = GetStat(xdocD, 38, TranTypeD.Sell, StatTypeD.Max);
ZydPrAmarB.Text = GetStat(xdocD, 39, TranTypeD.Buy, StatTypeD.Max);
ZydPrAmarS.Text = GetStat(xdocD, 39, TranTypeD.Sell, StatTypeD.Max);
MegPrAmarB.Text = GetStat(xdocD, 40, TranTypeD.Buy, StatTypeD.Max);
MegPrAmarS.Text = GetStat(xdocD, 40, TranTypeD.Sell, StatTypeD.Max);
MorPrAmarB.Text = GetStat(xdocD, 11399, TranTypeD.Buy, StatTypeD.Max);
MorPrAmarS.Text = GetStat(xdocD, 11399, TranTypeD.Sell, StatTypeD.Max);
};
stationSelect.ClearSelection();
}
// Dodixie
enum TranTypeD { Buy, Sell, All };
enum StatTypeD { Volume, Avg, Max, Min, StdDev, Median, Percentile };
private static string GetStat(XmlDocument xdocD, int id, TranTypeD tranType, StatTypeD statType)
{
string xpath = string.Format("/evec_api/marketstat/type[@id = {0}]/{1}/{2}",
id, tranType.ToString().ToLower(), statType.ToString().ToLower());
return GetFirstElementText(xdocD, xpath);
}
// Hek
enum TranTypeH { Buy, Sell, All };
enum StatTypeH { Volume, Avg, Max, Min, StdDev, Median, Percentile };
private static string GetStat(XmlDocument xdocH, int id, TranTypeH tranType, StatTypeH statType)
{
string xpath = string.Format("/evec_api/marketstat/type[@id = {0}]/{1}/{2}",
id, tranType.ToString().ToLower(), statType.ToString().ToLower());
return GetFirstElementText(xdocH, xpath);
}
// Jita
enum TranType { Buy, Sell, All };
enum StatType { Volume, Avg, Max, Min, StdDev, Median, Percentile };
private static string GetStat(XmlDocument xdoc, int id, TranType tranType, StatType statType)
{
string xpath = string.Format("/evec_api/marketstat/type[@id = {0}]/{1}/{2}",
id, tranType.ToString().ToLower(), statType.ToString().ToLower());
return GetFirstElementText(xdoc, xpath);
}
</code></pre>
<p>A picture to give you a better idea: </p>
<p><a href="https://i.stack.imgur.com/eVqWO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eVqWO.jpg" alt="enter image description here"></a></p>
| <c#><asp.net> | 2016-02-26 13:14:49 | LQ_CLOSE |
35,653,089 | want to move next activity after palying a audio clip | I am creating a app, where activity move will in the next activity after play a audio clip. but when i wrote the code only audio part is working, next page not coming. i am giving my code. please help.
}[enter image description here][1]
[1]: http://i.stack.imgur.com/MtUdw.png | <java><android><audio> | 2016-02-26 13:32:50 | LQ_EDIT |
35,653,685 | Why is the id attribute needed when we have classes? | <p>Both <code>id</code> and <code>class</code> can be used to identify HTML elements. Any HTML element that can be identified with an ID could be similarly identified if you added the ID as a class instead. I can see some vague contours of a semantic reason why id and classes are both nice to have, but it hardly seems justifiable if we could do the exact same thing with one of them. Am I missing some important usages of <code>id</code> which cannot be done with <code>class</code>?</p>
| <html> | 2016-02-26 14:00:28 | LQ_CLOSE |
35,655,945 | array reverse based on index javascript | How to Reverse an javascript array based on passing of index value.
similar like array.reverse(5);
input: array=[0,1,2,3,4,5,6];
for 5:
output:array[4,3,2,1,6,5];
| <javascript><arrays><reverse> | 2016-02-26 15:43:09 | LQ_EDIT |
35,658,040 | Create full-rank matrix in matlab | I wanna to create a full-ranked matrix (named <code>A</code>) with 100 column and 100 rows.
How can I do it in Matlab? | <matlab><matrix> | 2016-02-26 17:27:13 | LQ_EDIT |
35,658,188 | What does "naive" bays mean on Machine learning? | What does "naive" bays mean on Machine learning?
I need a brief explanation.
| <machine-learning><naivebayes><data-science> | 2016-02-26 17:35:20 | LQ_EDIT |
35,658,894 | Ruby on rails geting to the codes | <p>How do I get to where I can change the code of the web site? I cant find the file but I can not change the HTML of the site.</p>
| <javascript><html><css><ruby-on-rails> | 2016-02-26 18:16:30 | LQ_CLOSE |
35,659,848 | How to check whether openpyxl package exist and if it is not exist how to download and install it within the script in Python 3.5.1? | I started writing python codes two weeks ago and until now I have manipulate some excel data after converting it to txt file. I want to manipulate excel data directly, so I need to install openpyxl package. However, my script will be used in many different places and computers (note that: all of them either OS X or a Linux distrubution) which might (probably do not) contain openpyxl package installed. I want my script to check whether this package exist, and if it does not exit, then download and install it.
For that purpose, as I searched and found that I could check the existence of the package by first importing the pip module and then pip.get_installed_distributions() method. However, I am not sure whether I am in a wrong way or not. Beside, I have no idea how to download and install openpyxl package "without leaving the script".
Would you like to help me ? | <python><python-3.x><python-3.5> | 2016-02-26 19:12:14 | LQ_EDIT |
35,660,046 | iOS Development - Executing Code After Leaving a tab in a tabbed application | <p>I want to execute some code whenever a user leaves one of the tabs in my tabbed application. What should I do?</p>
| <ios><swift> | 2016-02-26 19:25:35 | LQ_CLOSE |
35,660,595 | C# how to pass an array as a ref parameter | I appreciate some help translating the VB code below, to C#.
I am stucked in obSMS.GetEstado(vMessages). I am invoking an external service that is supposed to retun me vMessages,
an array like the one described at the bottom. Each row of the array has 4 elements (0, 1 ,2 3).
Please I need a int in how to traslate obSMS.GetEstado(vMessages) to C#.
Thanks a lot
Dim obSMS As SMSEmpresarial.clsSMS
Dim vMessages As Object
Dim i As Integer
obSMS = New SMSEmpresarial.clsSMS
obSMS.GetEstado(vMessages)
For i = 0 To UBound(vMessages, 1) - 1
Me.ListBox1.Items.Add("Cod:" & CStr(vMessages(i, 0)) &
":Tel:" & CStr(vMessages(i, 1)) & ":Est:" & CStr(vMessages(i, 2)) &
":Obs:" & CStr(vMessages(i, 3)))
Next
obSMS = Nothing
Exit Sub
How vMessages array looks like:
row 0 AAAAA BBBBB CCCCC DDDD
row 1 KKKKK PPPPP GGGGG HHHH
row 2 MMMMM FFFFF XXXXX ZZZZ | <c#><vb.net> | 2016-02-26 19:57:12 | LQ_EDIT |
35,660,726 | VBA to export rows in source doc to an existing document and save as new file | 'I am trying to make a vba code to open an existing spreadsheet and populate the first row of that existing spreadsheet with the row of the information from the source spreadsheet then auto save it as the project name listed in a specific cell of the source. Can anyone help me out. I am not a coder, just copying codes that I have found. I am using this code.
Sub Button1_Click()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
On Error GoTo PROC_ERROR
Dim ThisWorkbook As Workbook, NewBook As Workbook
Dim ThisWorksheet As Worksheet, NewWs As Worksheet
Dim i As Integer, j As Integer, k As Integer, ExportCount As Integer
Set ThisWorkbook = ActiveWorkbook
Set ThisWorksheet = ThisWorkbook.Sheets("Sheet1")
ExportCount = 0
For i = 2 To Aslong
If ThisWorksheet.Cells(i, 1) <> "" Then
Set NewBook = Workbooks.Open("F:\DBA\Land Opportunities\Set-Up Templates\FOR SALE TEMPLATE.xlsx")
Set NewWs = Existing.Sheets("Project")
For j = 2 To 13
If ThisWorksheet.Cells(i, j) <> "" Then
NewWs.Cells(1, 1) = ThisWorksheet.Cells(i, j)
End If
Next j
With NewBook
.Sheets("Sheet2").Delete
.Sheets("Sheet3").Delete
.Title = ThisWorksheet.Cells(i, 3)
.SaveAs Filename:=ThisWorksheet.Cells(i, 3) & ".csv", FileFormat:=xlCSV, CreateBackup:=False
End With
ExportCount = ExportCount + 1
End If
Next i
PROC_ERROR:
If Err.Number <> 0 Then
MsgBox "This macro has encountered an error and needs to exit. However, some or all of your exported workbooks may still have been saved. Please try again." _
& vbNewLine & vbNewLine & "Error Number: " & Err.Number & vbNewLine & "Error Description: " & Err.Description, vbInformation
ExportCount = 0
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Exit Sub
Else
MsgBox "Successfully exported " & ExportCount & " workbooks!", vbInformation
ExportCount = ExportCount
End If
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
| <vba><excel> | 2016-02-26 20:03:39 | LQ_EDIT |
35,662,981 | Making a Lottery in python and it seems Like i cant win | This is my code buy no matter how many times i run it all i get is you lost. Whats wrong with the code?
import random
# Creates a number to count the amount of plays
count = 1;
# Creates a variable to store the amount of starting money
money = 10;
# Creates a variable telling you how much money you start with
startingCash = "You start with $" + str(money) + "!";
while (count < 101):
# Variables for the lottery numbers
lottery1 = random.randint(1,9);
lottery2 = random.randint(1,9);
lottery3 = random.randint(1,9);
lottery4 = random.randint(1,9);
# Lottery variables in one single variable
lotteryTotal = (lottery1, lottery2, lottery3, lottery4);
# Variables for the drawn ticket
drawn1 = random.randint(1,9);
drawn2 = random.randint(1,9);
drawn3 = random.randint(1,9);
drawn4 = random.randint(1,9);
# Variable for the drawn ticket in one single variable
drawnTotal = (drawn1, drawn2, drawn3, drawn4);
# Variable that changes the money variable so the player has 2 less dollars
money = money - 2;
it seems like the == sign gets ignored or acts differently. I wanted it to do the "if" if they are equal to eachother.
if( drawnTotal == lotteryTotal):
count = count + 1;
money = money + 5;
print ("Lottery Numbers: " + str(lotteryTotal));
print ("Your Numbers: " + str(drawnTotal));
print ("You Won $5!");
input("Press Enter to continue")
else:
print ("Lottery Numbers: " + str(lotteryTotal));
print ("Your Numbers: " + str(drawnTotal));
print ("You Lost!");
input("Press Enter to continue");
| <python> | 2016-02-26 22:34:23 | LQ_EDIT |
35,663,480 | GUI development with Python | <p>I want to BUILD a client-side app with Python (ex: Atom Text-Editor). However, I do not want to use Tkinter, I prefer to know how to write it from scratch, or some decent frameworks for doing so</p>
| <python><user-interface> | 2016-02-26 23:17:14 | LQ_CLOSE |
35,664,134 | Converting C code to Java | <p>Can someone explain to me what the two pieces of code below do, and what the equivalent would look like in Java?</p>
<pre><code>double* ptr;
ptr = (double*)malloc(10*_R_CONST*sizeof(double)+2048);
</code></pre>
<p>I presumed from my limited knowledge of C that it's declaring a pointer ptr, setting the size of the pointer?</p>
<p>This is what the calls look like later in the same file </p>
<pre><code>ptr[10*n+2]=-RadtoMOA(atan(y/x));
ptr[10*n+0]=x/3;
ptr[10*n+1]=y*12;
ptr[10*n+2]=-RadtoMOA(atan(y/x));
ptr[10*n+3]=t+dt;
</code></pre>
<hr>
<p>There is another similar function, again I'm unfamiliar with C. The two lines with asterisks are the lines I am wondering about particularly. </p>
<pre><code>double GetRange(double* sln, int yardage){
**double size=sln[_R_CONST*10+1];**
if (yardage<size){
**return sln[10*yardage];**
}
else return 0;
}
</code></pre>
<hr>
<p>For the first portion of this question here's the full code, incl. the excerpts above.</p>
<pre><code>double* ptr;
ptr = (double*)malloc(10*_R_CONST*sizeof(double)+2048);
double t=0;
double dt=0.5/Vi;
double v=0;
double vx=0, vx1=0, vy=0, vy1=0;
double dv=0, dvx=0, dvy=0;
double x=0, y=0;
double headwind=HeadWind(WindSpeed, WindAngle);
double crosswind=CrossWind(WindSpeed, WindAngle);
double Gy=GRAVITY*cos(DegtoRad((Angle + ZAngle)));
double Gx=GRAVITY*sin(DegtoRad((Angle + ZAngle)));
vx=Vi*cos(DegtoRad(ZAngle));
vy=Vi*sin(DegtoRad(ZAngle));
y=-SightHeight/12;
int n=0;
for (t=0;;t=t+dt){
vx1=vx, vy1=vy;
v=pow(pow(vx,2)+pow(vy,2),0.5);
dt=0.5/v;
// Compute acceleration using the drag function retardation
dv = retard(DragFunction,DragCoefficient,v+headwind);
dvx = -(vx/v)*dv;
dvy = -(vy/v)*dv;
// Compute velocity, including the resolved gravity vectors.
vx=vx + dt*dvx + dt*Gx;
vy=vy + dt*dvy + dt*Gy;
if (x/3>=n){
ptr[10*n+0]=x/3; // Range in yds
ptr[10*n+1]=y*12; // Path in inches
ptr[10*n+2]=-RadtoMOA(atan(y/x)); // Correction in MOA
ptr[10*n+3]=t+dt; // Time in s
ptr[10*n+4]=Windage(crosswind,Vi,x,t+dt); // Windage in inches
ptr[10*n+5]=RadtoMOA(atan(ptr[10*n+4])); // Windage in MOA
ptr[10*n+6]=v; // Velocity (combined)
ptr[10*n+7]=vx; // Velocity (x)
ptr[10*n+8]=vy; // Velocity (y)
ptr[10*n+9]=0; // Reserved
n++;
}
// Compute position based on average velocity.
x=x+dt*(vx+vx1)/2;
y=y+dt*(vy+vy1)/2;
if (fabs(vy)>fabs(3*vx)) break;
if (n>=R_CONST+1) break;
}
ptr[10*_R_CONST+1]=(double)n;
*Solution = ptr;
return n;
</code></pre>
<p>}</p>
| <java><c><pointers> | 2016-02-27 00:24:54 | LQ_CLOSE |
35,664,561 | C memory pool storing | <p>I am writing small memory allocation system. Having: </p>
<pre><code>typedef struct _POOL
{
int size; /*size of memory pool*/
void* memory; /*pointer to pool location in memory*/
} Pool;
Pool* allocatePool(int n) {
Pool *myPool = malloc(sizeof(Pool) + n);
if (myPool){
myPool->size = n;
myPool->memory = myPool+1;
}
return myPool;
}
</code></pre>
<p>I am trying to write function that will store arbitrary object of n size at location offset within the pool.</p>
<pre><code>void store(Pool* pool, int offset, int size, void *object) {
char *ptrHelper;
ptrHelper = &(pool->memory); /*copy pool memory address*/
ptrHelper += offset; /*increment to match offset*/
memcpy(ptrHelper, &object, size); /*copy object in to the pool*/
}
</code></pre>
<p>Questions:</p>
<p>ptrHelper = &(pool->memory) is there another correct way of getting pool memory address?</p>
<p>What to do in case I want to store values grater than size of void *object (4 bytes in my case)?</p>
<p>How to correctly handle strings without changing functions parameter structure?
Thank you.</p>
| <c><pointers><memory><memory-management> | 2016-02-27 01:17:09 | LQ_CLOSE |
35,664,737 | Turning a string that contains a equation into an integer | <p>I would like to be able to convert a string such as "(5+6)*6" and get the resulting integer from that equation. It is important that it starts out as a string. </p>
| <c++> | 2016-02-27 01:47:30 | LQ_CLOSE |
35,665,109 | PHP MYSQLI not updating | So I have been trying to make a form where I can update two fields one field is going be admin_welcomebox and admin_author and I'm trying update it by the id so here go my code
<div class="col-lg-6">
<div class="panel panel-color panel-inverse">
<div class="panel-heading">
<h3 class="panel-title">Welcome Box Update</h3>
</div>
<?php
if(isset($_POST["submit"])){
$servername = "localhost";
$username = "trres";
$password = "sss";
$dbname = "txxxs";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE admin_news SET welcomebox = '{$admin_news}' SET author = {$admin_author} id='{$id}'";
if ($conn->query($sql) === TRUE) {
echo "<h4 class='bg-success'>You have updated admin welcome box.</h4>";
} else {
echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>";
}
$conn->close();
}
?>
<div class="panel-body">
<form method="post" action="">
<div class="form-group">
<label for="welcomebox">Welcome Box</label>
<textarea type="text" name="welcomebox" id="welcomebox" placeholder="Enter Your Message" class="form-control"></textarea>
</div>
<div class="form-group">
<label for="author">Author Name</label>
<input type="text" name="author" id="author" placeholder="Author Name" class="form-control" / >
</div>
<div class="form-group text-right m-b-0">
<button class="btn btn-primary waves-effect waves-light" type="submit" name="submit" id="submit">
Update Info
</button>
</div>
</form>
</div>
</div>
</div>
When i try update it just refresh the page nothing else. | <php><mysqli> | 2016-02-27 02:50:07 | LQ_EDIT |
35,665,163 | scala - how to find Minimum in a tuple | A = tuples of Medication(patientid,date,medicine)
B = A.groupby(x => x.patientid)
example B would look like below - now I need to find the minimum date, how to do that in scala??
(478009505-01,CompactBuffer(Some(Medication(478009505-01,Fri Jun 12 10:30:00 EDT 2009,glimepiride)), Some(Medication(478009505-01,Fri Jun 12 10:30:00 EDT 2009,glimepiride)), Some(Medication(478009505-01,Fri Jun 12 10:30:00 EDT 2009,glimepiride))) | <scala><sorting><apache-spark><minimum> | 2016-02-27 02:58:55 | LQ_EDIT |
35,666,457 | Checking GPS Status in android permanently | <p>I have an android application ,I want to show GPS status permanently in my application , I used timer before to check GPS status every 3 seconds , it works correct,But I don't want to use timer now. I just want when GPS turned on , my application notify and when GPS terned off that notifiy.</p>
| <android><gps> | 2016-02-27 06:17:00 | LQ_CLOSE |
35,666,894 | Mysterious character output in C | I had come across this code in K & R:
int scanline (char str [], int lim) /* Line will be read in 'str []', while lim is the maximum characters to be read */
{
int c, len, j; /* 'len' will have the length of the read string */
j = 0; /* Initializing 'j' */
for (len = 0; (c = getchar ()) != EOF && c != '\n'; ++len) /* Reading a character one by one, till the user enters '\n', and checking for failure of 'getchar' */
{
if (len < (lim -2)) /* Checking that string entered has not gone beyond it's boundaries. '-2' for '\n' and '\0' */
{
str [j] = c; /* Copying read character into 'string [j]' */
++ j; /* Incrementing 'j' by 1 */
}
}
if (c == '\n') /* Checking if user has finished inputting the line */
{
str [j] = c; /* Copying newline into string */
++j;
++ len;
}
return len; /* Returning number of characters read */
}
In the K & R, it is known as `getline`, but I made changes, added comments, and thus defined it as `scanline`. To test this, I made a demo program:
#include <mocl/cancel.h>
int main (int argc, char **argv)
{
int len;
char str [50];
len = scanline (str, 50);
printf ("len = %d\n str = %s\n", len, str);
return 0;
}
The required headers and the function was in my own library, `cancel.h`. Then when I compiled my program, it was successful. Although, when I ran the executable, I got unexpected output (I cannot type it as I get a character which when I copy, it just gets pasted as 'm'):
[![enter image description here][1]][1]
The mysterious character is [![enter image description here][2]][2] which when I copy, gets copied as the letter `m`. Also, when I run my program with different inputs, I get different mysterious outputs:
[![enter image description here][3]][3]
In another case, I get perfect output, just that a blank line is printed:
[![enter image description here][4]][4]
I had also come across [this](http://stackoverflow.com/questions/35651800/what-is-this-mysterious-output-in-c) question, in which the user gets the same symbol.
------------
**_What have I done till now?_**
I searched a lot, and I could not find any clue about [![enter image description here][5]][5] this character, but if you see carefully, in the second image, I get more characters when I enter "hi this is ashish". One of them is the slash, and one is [![enter image description here][6]][6]. But I get another character [![enter image description here][7]][7]. I got [this](https://rosettacode.org/wiki/Strip_control_codes_and_extended_characters_from_a_string#C) link which was showed how to reproduce it, and explained it, although I could not understand. When you run the code given there, you get a lot of characters, and one of them is [![enter image description here][8]][8]. Although, even the author of that article could not copy it, and has not posted it. So here's the output:
[![enter image description here][9]][9]
That was the actual output, as that's not clear, here's a cut out version:
[![enter image description here][10]][10]
So basically I got to know that both the characters [![enter image description here][11]][11] and [![enter image description here][12]][12] are extended characters from a string. At that point, I actually figured out what was causing the problem in `scanline`.
The lines
if (c == '\n') /* Checking if user has finished inputting the line */
{
str [j] = c; /* Copying newline into string */
++j;
++ len;
}
were causing the problems as you were copying a newline into the string. It worked, but I'm not sure why, as doing that was just a guess. I searched but still could not find the reason.
---------------
**_My Questions_**
- How does removing those lines make the program work properly?
- What are the characters [![enter image description here][13]][13] and [![enter image description here][14]][14]? What are they supposed to do and how did they appear over here?
- Are there any more characters like this?
- Why can't those characters be copied?
- Is it Undefined Behavior?
**NOTE:** I know this questions lengthy, but I'll make sure and offer a bounty once that "question eligible for bounty in 2 days" gets over.
[1]: http://i.stack.imgur.com/gJzPb.png
[2]: http://i.stack.imgur.com/IWP35.png
[3]: http://i.stack.imgur.com/UKqpI.png
[4]: http://i.stack.imgur.com/8EKne.png
[5]: http://i.stack.imgur.com/EbMX9.png
[6]: http://i.stack.imgur.com/h0yCq.png
[7]: http://i.stack.imgur.com/qu9oW.png
[8]: http://i.stack.imgur.com/8XL0F.png
[9]: http://i.stack.imgur.com/SxxxQ.png
[10]: http://i.stack.imgur.com/dW876.png
[11]: http://i.stack.imgur.com/RfafD.png
[12]: http://i.stack.imgur.com/W5Wam.png
[13]: http://i.stack.imgur.com/MVrgF.png
[14]: http://i.stack.imgur.com/ecu9R.png | <c++><c><string><special-characters><newline> | 2016-02-27 07:12:28 | LQ_EDIT |
35,667,548 | calling delegate method on Ibaction | i unable to call
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
on IBaction
- (IBAction)button:(UIButton *)sender {
}
help me | <ios><objective-c><iphone> | 2016-02-27 08:34:20 | LQ_EDIT |
35,667,549 | arrow keys navigation to input text which inside a div in js | *emphasized text*
http://jsfiddle.net/uJ4PJ/
I used this jsfiddle for arrow key navigation,(for same function) but if I use this html, how can I do the same ?(I have to skip br tag)
<div class='move'>
<input type="text" /><br>
<input type="text" /><br>
<input type="text" />
</div>
Thanks in Advance. | <javascript> | 2016-02-27 08:34:45 | LQ_EDIT |
35,667,798 | I am working on the fragments. but I get struct at the point..please help me to solve this | I want to pass the listener parameter to the fragment but I am getting the error at
i have declared the editTextAge globally
editTextAge.setOnClickListener(new View.OnClickListener() {
DlgNumberPickerFragm newFragment = new DlgNumberPickerFragm();
@Override
public void onClick(View v) {
DlgNumberPickerFragm.dlgAgePicker(R.string.app_name, R.drawable.imgdialogbox, "\t\t\tSelect Age", AdptCardUI.this).show(this.newFragment.getFragmentManager(), "first");
}
});
at AdptCardUI.this).show(this.newFragment.getFragmentManager(), "first");
}
});
i have tried
this).show(this.getFragmentManager();
this).show(this.getChildFragmentManager();
this).show(this.newFragment.getFragmentManager();
AdptCardUI.this).show(this.newFragment.getFragmentManager();
but i didnt got any answer please help me in this | <android><android-fragments> | 2016-02-27 09:02:53 | LQ_EDIT |
35,668,322 | CheckBox: Is it possible to change check symbol? | <p>Is is possible to change the "tick" in checkbox to "X" on selection of it?</p>
<p>If yes, then please let me know how can i get it working using anything like HTML,CSS,Kendo UI?</p>
<p>Thanks!</p>
| <html><css><checkbox><kendo-ui> | 2016-02-27 09:57:18 | LQ_CLOSE |
35,668,512 | my app don't working in android 6.0 platform | <p>I did an SMS application. My app working from platform 10 to platform 22. But doesn't work on platform 23 (so android 6 platform). I'm using Android studio. Why my app don't work on android 23 platform?</p>
<p>(Note: On Android 23 platform my app enjoying "stopped error")</p>
| <android> | 2016-02-27 10:19:59 | LQ_CLOSE |
35,668,819 | How to just make a specific link colorful? | <p>I did not want to make all links on my custom blog red. Just specific ones. Only the "Destiny" text and "Read more" should be red color. As you can see the titles is also red and that's what I don't want. All links should be red but not the titles!</p>
<p>Screenshot: <a href="https://gyazo.com/daaa771613ffd444b65e38119c45c2dd" rel="nofollow">https://gyazo.com/daaa771613ffd444b65e38119c45c2dd</a></p>
<p>How can I fix this, what needs to be done?</p>
<p>Thank you</p>
| <php><css> | 2016-02-27 10:54:55 | LQ_CLOSE |
35,669,270 | What jquery / javascript files to define $? | I want to make a simple sliding Div over another div.
This Fiddle (http://jsfiddle.net/cf7u73pn/1/) is exactly what i want to make, but since i'm a noob in this world of coding, i get the warning 'Uncaught ReferenceError: $ is not defined' after copying the codes to my own files.
<div class="hidden" id="slide">INFORMATION ABOUT IMAGE APPEARS ON CLICK</div>
<div class="image"><br>THERE'S A NICE IMAGE HERE</div>
$(document).ready(function() {$('#slide').click(function() {
var hidden = $('.hidden');
if (hidden.hasClass('visible')) {
hidden.animate({"top": "160px"}, "slow").removeClass('visible');
}
else {
hidden.animate({"top": "0px"}, "slow").addClass('visible');
}
});
});
I now understand that i have to link a/several (?) file(s) in my HTML head to define my $. Can someone please help me find the right files and tell me how to link these into my html?
Thank you very much! | <javascript><jquery><html><css> | 2016-02-27 11:43:05 | LQ_EDIT |
35,669,695 | i can't run this code of coverting an array into a list | I'm trying to convert an array into a list and this is the code :
void tab2list(int n, list **T)
{
int t[z];
int i;
for (i=0;i<n;i++)
{
printf("Entrez l'element %d du tableau\n",i+1);
scanf("%d",&t[i]);
insert_end(t[i],&T);
}
}
and this is how i call it in the main function
tab2list(n,&tete); | <c> | 2016-02-27 12:19:42 | LQ_EDIT |
35,670,154 | android-Going to next line | I am using LinearyLayout as you see and my problem is why cant i see the imageview at the firstline and the button at the secondline?
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
` | <android><android-layout> | 2016-02-27 13:05:45 | LQ_EDIT |
35,670,302 | What is this regex means? | <p>I found this regex as an email validation but i can't understand what is means, I tried to enter multiple forms of emails but they didn't work, I think there is a problem in this regex.</p>
<p><strong>^[A-Z0-9][A-Z0-9._%+-]{0,63}@(?:[A-Z0-9]{1,63}.){1,125}[A-Z]{2,63}$</strong></p>
<p>can anyone explain what is this regex means and give an example for it.</p>
<p>Thanks in advance.</p>
| <regex><email-validation> | 2016-02-27 13:19:53 | LQ_CLOSE |
35,670,718 | Player and Blocks collision (Terraria) | <p>I am creating a game like Terraria. I already have a player and I can place blocks and delete them by clicking on an existing block. But I can´t figure out how to make player and block collision. I want to create physics like in terraria. Can you help me somehow?
Here are my 3 classes (I have 4 but the 4. class is only JFrame class):</p>
<p>Here is my Main Class (gameloop): </p>
<pre><code>package Package;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.JPanel;
import javax.swing.Timer;
public class Game extends JPanel implements ActionListener, MouseListener, KeyListener {
Timer gameLoop = new Timer(5, this);
private static final long serialVersionUID = 1L;
public static final int WIDTH = 1500;
public static final int HEIGHT = 900;
public static final Dimension windowSize = new Dimension(WIDTH, HEIGHT);
Player player = new Player();
public static ArrayList<Block> blocks = new ArrayList<Block>();
private int xDistance;
private int yDistance;
public Game() {
setPreferredSize(windowSize);
setFocusable(true);
addMouseListener(this);
addKeyListener(this);
setBackground(Color.WHITE);
for (int i = 0; i < Game.WIDTH; i += 50) {
for (int j = Game.HEIGHT - 150; j < Game.HEIGHT; j += 50) {
blocks.add(new Block(i, j));
}
}
start();
}
public void start() {
gameLoop.start();
}
public void stop() {
gameLoop.stop();
}
public void paint(Graphics g) {
for (Block b : blocks) {
b.render(g);
}
player.render(g);
}
public void actionPerformed(ActionEvent e) {
player.move();
player.offScreen();
repaint();
}
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
int mouseX = e.getX();
int mouseY = e.getY();
boolean foundBlock = false;
xDistance = mouseX % 50;
yDistance = mouseY % 50;
for (Block b : blocks) {
if (b.x == mouseX - xDistance && b.y == mouseY - yDistance) {
if (mouseX >= player.x - 150 && mouseX <= player.x + 200 && mouseY >= player.y - 150 && mouseY <= player.y + 250) {
blocks.remove(b);
foundBlock = true;
break;
}
}
}
if (foundBlock == false) {
if (mouseX >= player.x - 150 && mouseX <= player.x + 200 && mouseY >= player.y - 150 && mouseY <= player.y + 250) {
blocks.add(new Block(mouseX - xDistance, mouseY - yDistance));
}
}
}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void keyTyped(KeyEvent e) {}
public void keyPressed(KeyEvent e) {
int arrows = e.getKeyCode();
if (arrows == KeyEvent.VK_D) {
player.xSpeed = 2;
}
if (arrows == KeyEvent.VK_A) {
player.xSpeed = -2;
}
}
public void keyReleased(KeyEvent e) {
int arrows = e.getKeyCode();
if (arrows == KeyEvent.VK_D) {
player.xSpeed = 0;
}
if (arrows == KeyEvent.VK_A) {
player.xSpeed = 0;
}
}
}
</code></pre>
<p>Here is my Player class:</p>
<pre><code>package Package;
import java.awt.Color;
import java.awt.Graphics;
public class Player {
public int x = 14 * 50;
public int y = Game.HEIGHT - (5 * 50);
public int xSpeed = 0;
public int ySpeed = 0;
public boolean jump = false;
public int ticks = 6;
public void render(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(x, y, 50, 100);
}
public void move() {
x += xSpeed;
y += ySpeed;
}
public void offScreen() {
if (x <= 0) {
xSpeed = 0;
} else if (x + 50 >= Game.WIDTH) {
xSpeed = 0;
}
}
}
</code></pre>
<p>Here is my Block Class:</p>
<pre><code>package Package;
import java.awt.Color;
import java.awt.Graphics;
public class Block {
public int x;
public int y;
public Block(int x, int y) {
this.x = x;
this.y = y;
}
public void render(Graphics g) {
g.setColor(Color.GRAY);
g.fillRect(x, y, 50, 50);
g.setColor(Color.BLACK);
g.drawRect(x, y, 50, 50);
}
}
</code></pre>
| <java> | 2016-02-27 14:05:07 | LQ_CLOSE |
35,671,138 | The name does not exist in the current context. Why? | <p>My code is:</p>
<pre><code> if (textBox1.Text != "")
{
StreamReader tx = new StreamReader(textBox1.Text);
}
else
{
StreamReader tx = new StreamReader("new.txt");
}
string line;
while ((line = tx.ReadLine()) != null)
{
</code></pre>
<p>If i delete "if" and leave it as:</p>
<pre><code> StreamReader tx = new StreamReader("new.txt");
string line;
while ((line = tx.ReadLine()) != null)
{
</code></pre>
<p>Everything works. Why does if mess up my code?</p>
| <c#> | 2016-02-27 14:47:29 | LQ_CLOSE |
35,671,581 | FATAL EXCEPTION: main android.os.NetworkOnMainThreadException | <p>i want upload images but cant run this because show:
FATAL EXCEPTION: main
android.os.NetworkOnMainThreadException`public class FileUploader {
private final String boundary;
private static final String LINE_FEED = "\r\n";
private HttpURLConnection httpConn;
private String charset;
private OutputStream outputStream;
private PrintWriter writer;</p>
<pre><code>public FileUploader(String requestURL, String charset)
throws IOException {
this.charset = charset;
// creates a unique boundary based on time stamp
boundary = "===" + System.currentTimeMillis() + "===";
URL url = new URL(requestURL);
httpConn = (HttpURLConnection) url.openConnection();
httpConn.setUseCaches(false);
httpConn.setDoOutput(true); // indicates POST method
httpConn.setDoInput(true);
httpConn.setRequestProperty("Content-Type",
"multipart/form-data; boundary=" + boundary);
httpConn.setRequestProperty("User-Agent", "CodeJava Agent");
httpConn.setRequestProperty("Test", "Bonjour");
outputStream = httpConn.getOutputStream();
writer = new PrintWriter(new OutputStreamWriter(outputStream, charset),
true);
}
/**
* Adds a form field to the request
* @param name field name
* @param value field value
*/
public void addFormField(String name, String value) {
writer.append("--" + boundary).append(LINE_FEED);
writer.append("Content-Disposition: form-data; name=\"" + name + "\"")
.append(LINE_FEED);
writer.append("Content-Type: text/plain; charset=" + charset).append(
LINE_FEED);
writer.append(LINE_FEED);
writer.append(value).append(LINE_FEED);
writer.flush();
}
/**
* Adds a upload file section to the request
* @param fieldName name attribute in <input type="file" name="..." />
* @param uploadFile a File to be uploaded
* @throws IOException
*/
public void addFilePart(String fieldName, File uploadFile)
throws IOException {
String fileName = uploadFile.getName();
writer.append("--" + boundary).append(LINE_FEED);
writer.append(
"Content-Disposition: form-data; name=\"" + fieldName
+ "\"; filename=\"" + fileName + "\"")
.append(LINE_FEED);
writer.append(
"Content-Type: "
+ URLConnection.guessContentTypeFromName(fileName))
.append(LINE_FEED);
writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED);
writer.append(LINE_FEED);
writer.flush();
FileInputStream inputStream = new FileInputStream(uploadFile);
byte[] buffer = new byte[4096];
int bytesRead = -1;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.flush();
inputStream.close();
writer.append(LINE_FEED);
writer.flush();
}
/**
* Adds a header field to the request.
* @param name - name of the header field
* @param value - value of the header field
*/
public void addHeaderField(String name, String value) {
writer.append(name + ": " + value).append(LINE_FEED);
writer.flush();
}
/**
* Completes the request and receives response from the server.
* @return a list of Strings as response in case the server returned
* status OK, otherwise an exception is thrown.
* @throws IOException
*/
public List<String> finish() throws IOException {
List<String> response = new ArrayList<String>();
writer.append(LINE_FEED).flush();
writer.append("--" + boundary + "--").append(LINE_FEED);
writer.close();
// checks server's status code first
int status = httpConn.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(
httpConn.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
response.add(line);
}
reader.close();
httpConn.disconnect();
} else {
throw new IOException("Server returned non-OK status: " + status);
}
return response;
}
</code></pre>
<p>}
`</p>
<p>please help me :(</p>
| <android><image-uploading> | 2016-02-27 15:28:06 | LQ_CLOSE |
35,671,630 | Logical negation in front of variable c++ | <p>I got this statement in a program.</p>
<p>I don't know what is the use of "!".</p>
<pre><code> while(ams && !ev);
</code></pre>
| <c++> | 2016-02-27 15:33:06 | LQ_CLOSE |
35,673,316 | test a java method in netbeans | <p>Let's say I found this piece of code and I want to test it in Netbeans before I incorporate it:</p>
<pre><code>ArrayList list;
for(String s: list)
{
Integer c = stringsCount.get(s);
if(c == null) c = new Integer(0);
c++;
stringsCount.put(s,c);
}
</code></pre>
<p>Is there a way to test the above code in Netbeans without having to create a temp class with a main? I believe there is a way in Eclipse but I am looking for a way in Netbeans. Thank you.</p>
| <java><netbeans> | 2016-02-27 17:55:52 | LQ_CLOSE |
35,673,448 | Submitting forms without server side scripts | <p>I would like to be able to submit forms without server side scripts. Is this possible? I want it to be like prompt, where the user's input is stored in a variable. Is there a way to make it so whenever the user clicks the submit button, whatever they entered in the form is saved in a variable? Thanks!</p>
| <javascript><html><css><forms> | 2016-02-27 18:08:18 | LQ_CLOSE |
35,675,282 | Write text on images. Facing error | I have two images one on left and one on right. I am facing issues in writing text on both images. I am pasting html code and css code. Please correct it.
Html code
<div id="header">
<img src="images/banner-img1.jpg"alt="" class="left" > <p id="text"> jhcjdhdjshdjdhjd</p>
<img src="images/banner-img2.jpg"alt="" class="right"><p id="text"> jgdhdgdhddhhsd </p>
</div>
Css Code.
#container {
height: 400px;
width: 400px;
position: relative;
}
#image {
position: absolute;
left: 0;
top: 0;
}
#text {
z-index: 100;
position: absolute;
color: white;
font-size: 24px;
font-weight: bold;
left: 150px;
top: 600px;
}
| <html><css> | 2016-02-27 20:49:58 | LQ_EDIT |
35,675,854 | meta random redirect random X seconds | <p>meta random redirect with random seconds.</p>
<pre><code><?php
$offers = array(
"http://www.url1.com",
"http://www.url2.com",
"http://www.url3.com",
"http://www.url4.com"
);
$referer = $_SERVER['HTTP_REFERER'];
if($referer == "") {
$url = $offers[rand(0, count($offers) - 1)];
echo "<meta http-equiv='refresh' content='0;url=$url'>";
}
else
{
echo "<meta http-equiv='refresh' content='0;url=http://www.firstpage.com'>";
}
?>
</code></pre>
<p>i need some one to add the random seconds ..
thank you</p>
| <javascript><php><meta> | 2016-02-27 21:49:20 | LQ_CLOSE |
35,676,333 | How do I check for 2 seperate classes when using the .is_a? method | I am trying to define a method that returns true if the array contains any strings or numbers. Basically I want it to return true as long as their is something in the array.
This is what I have tried so far and it is not working:
def any_strings_or_numbers?(a)
a.any? {|num| num.is_a?(String || Integer) }
end
And here's what I mean for what I want this method to return
a = [ 1, 2, 3, "string" ]
any_strings_or_numbers?(a)
#=> true
b = [ "no numbers" ]
any_strings_or_numbers?(b)
#=> true
c = [ 1.0 ]
any_strings_or_numbers?(c)
#=> true
c = [ ]
any_strings_or_numbers?(c)
#=> false | <ruby> | 2016-02-27 22:37:27 | LQ_EDIT |
35,676,880 | Regex for phone number that starts with + | <p>For example +4456689854333 is a correct match</p>
| <regex> | 2016-02-27 23:43:02 | LQ_CLOSE |
35,677,232 | Getting before first underscore | Given a string say prod175100210_cat40510788__ I want only prod175100210. But when I do prod.*[^_] This regex, doesnot work. What should be legit regex for extracting only before first under score. | <regex> | 2016-02-28 00:26:59 | LQ_EDIT |
35,678,111 | What do html.oldie mean in CSS? | I find a code line in CSS; html.oldie .hero-gallery{height:860px}.
What do html.ordie mean? I guess this is for different browser's view, but I don't know what exactly this mean.
Thanks! | <css> | 2016-02-28 02:47:29 | LQ_EDIT |
35,681,799 | how to start youtube video with autoplay after 10 sec of page loads? | <p>Hello I want to start youtube video with autoplay after 10 seconds when the page load is completed. Is there any way to do this jQuery or javascript. I want to do this in a wordpress website.
the development site link:-</p>
<p><a href="http://www.mediationadvantage.com/" rel="nofollow">http://www.mediationadvantage.com/</a> (the video on left side need to be started)</p>
<p>Please give some idea or show some example on jsfiddle.</p>
<p>Thanks</p>
| <javascript><jquery><wordpress><youtube> | 2016-02-28 11:18:50 | LQ_CLOSE |
35,682,554 | Getting country name from country code | <p>I have found the answer for this for objective-c but Im having a hard time doing this in swift. </p>
<p>I have used this to get the country code for the current location:</p>
<pre><code> let countryCode = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String
print(countryCode)
// printing for example US
</code></pre>
<p>But how do I convert this country code to a country name, like in this example converting "US" to "United States"?</p>
| <swift><location> | 2016-02-28 12:31:05 | HQ |
35,682,703 | Display percentage values on a pie chart | <p>I am trying to draw a pie chart with ggplot2. My code is shown below.</p>
<pre><code>df <- data.frame(
variable = c("australia","hungary","germany","france","canada"),
value = c(632,20,491,991,20)
)
ggplot(df, aes(x = "", y = value, fill = variable)) +
geom_bar(width = 1, stat = "identity") +
scale_fill_manual(values = c("red", "yellow","blue", "green", "cyan")) +
coord_polar(theta = "y") +
labs(title = "pie chart")
</code></pre>
<p>I would like to display percentage values. How can I do that? </p>
| <r><ggplot2><pie-chart> | 2016-02-28 12:46:13 | LQ_CLOSE |
35,683,615 | How to find the executation time of code in C? | I found this code [here][1]. If i divite `(t2-t1)/CLOCK_PER_SEC`will i get time in seconds? How to I find CLOCK_PER_SEC? Is there any better way to find the executation time of a code or a function?
#include<time.h>
main()
{
clock_t t1=clock();
// Your code that takes more than 1 sec;
clock_t t2=clock();
printf("The time taken is.. %g ", (t2-t1));
[1]: http://stackoverflow.com/questions/13171846/c-program-measure-execution-time-for-an-instruction | <c><time> | 2016-02-28 14:18:36 | LQ_EDIT |
35,683,884 | Remove whitespace from SVG | <p>I cannot find a way to alter the code below to remove the whitespace from a SVG image. What should I modify or remove to achieve this? I am editing the code using this website: <a href="https://petercollingridge.appspot.com/svg-editor/" rel="noreferrer">https://petercollingridge.appspot.com/svg-editor/</a></p>
<p>How the SVG image looks like with this code: See <a href="http://i.stack.imgur.com/Y8ad8.png" rel="noreferrer">here</a>.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" width="250.0px" height="100.0px" overflow="visible" viewBox="0.0 0.0 250.0 100.0" enable-background="new 0.0 0.0 250.0 100.0">
<defs>
<radialGradient id="Grad1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.0021972656 0.0 0.0 0.0040893555 120.8 38.55)" r="819.2" cx="0" cy="0">
</radialGradient>
<linearGradient id="Grad2" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.0 0.001739502 -0.015563965 0.0 108.05 40.25)" x1="-819.2" y1="0" x2="819.2" y2="0">
</linearGradient>
<radialGradient id="Grad3" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-0.0021972656 0.0 0.0 0.0040893555 95.3 38.55)" r="819.2" cx="0" cy="0">
</radialGradient>
<linearGradient id="Grad4" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.0 -0.001953125 0.015563965 0.0 108.05 36.95)" x1="-819.2" y1="0" x2="819.2" y2="0">
</linearGradient>
</defs>
<g>
<g transform="matrix(1.0 0.0 0.0 1.0 0.0 0.0)">
<path fill="#DC0100" stroke-linecap="round" stroke-linejoin="round" d="M 232.05 57.75 L 230.45 60.6 L 221.85 68.25 L 221.5 67.9 C 221.2 67.6 220.84999 67.36666 220.45 67.2 L 221.9 61.85 L 223.5 62.4 L 226.05 57.25 L 227.2 57.85 L 229.95 55.95 L 232.05 57.75 Z M 227.85 82.2 L 226.65 83.0 L 226.65 86.35 L 224.2 87.15 L 222.5 84.45 L 219.6 84.75 L 219.0 84.7 L 219.25 80.35 L 219.35 80.35 C 221.61667 80.35 223.61667 79.75 225.35 78.55 L 227.85 82.2 Z M 212.3 82.8 C 211.23334 82.166664 210.25 81.416664 209.35 80.55 L 207.8 78.75 L 212.6 75.35 L 213.5 76.35 L 214.5 77.25 L 217.1 73.7 L 218.45 74.35 L 216.4 81.6 C 215.4 81.36667 214.46666 81.01667 213.6 80.55 L 212.3 82.8 Z M 205.15 70.3 L 201.75 68.9 L 202.25 65.6 L 205.85 65.6 C 206.45 63.8 207.4 62.15 208.7 60.65 L 207.25 58.15 L 209.1 56.2 L 211.7 58.1 L 213.75 61.2 C 213.11667 61.566666 212.53334 62.033333 212.0 62.6 C 210.43333 64.166664 209.45 65.96667 209.05 68.0 L 208.85 70.25 L 205.15 70.3 Z M 208.85 70.25 L 208.85 70.3 Z M 218.15 67.9 L 217.8 68.2 C 217.4 68.63333 217.18332 69.15 217.15 69.75 L 211.1 68.45 C 211.43333 66.816666 212.23334 65.36667 213.5 64.1 L 214.9 62.95 L 218.15 67.9 Z M 232.15 70.2 C 232.15 72.13333 231.76666 73.916664 231.0 75.55 L 223.55 72.0 C 223.78333 71.46667 223.9 70.88333 223.9 70.25 L 223.85 69.7 L 232.1 68.65 L 232.15 70.2 Z"/>
<path fill="#6C0B0B" stroke-linecap="round" stroke-linejoin="round" d="M 226.05 57.25 L 223.5 62.4 L 221.9 61.85 L 220.45 67.2 C 220.85 67.36666 221.20001 67.6 221.5 67.9 L 221.85 68.25 L 230.45 60.6 C 231.85 62.166668 232.85 63.9 233.45 65.8 L 233.45 65.9 L 235.95 65.9 L 236.4 66.15 L 236.9 68.4 C 235.96666 68.86667 235.01666 69.35 234.05 69.85 L 234.05 69.95 L 234.05 70.3 C 234.05 72.23333 233.73334 74.01666 233.1 75.65 L 235.3 78.35 L 233.85 80.2 L 230.95 79.35 L 229.85 80.55 L 228.05 82.1 L 227.85 82.2 L 225.35 78.55 C 223.61667 79.75 221.61667 80.35 219.35 80.35 L 219.25 80.35 L 219.0 84.7 L 218.75 84.7 L 216.65 84.45 L 214.7 87.15 L 212.3 86.35 L 212.3 82.8 L 213.6 80.55 C 214.46666 81.01667 215.4 81.36667 216.4 81.6 L 218.45 74.35 L 217.1 73.7 L 214.5 77.25 L 213.5 76.35 L 212.6 75.35 L 207.8 78.75 L 205.55 80.35 L 203.85 78.2 L 206.05 75.5 C 205.45 73.9 205.15 72.16667 205.15 70.3 L 208.85 70.3 L 209.05 68.0 C 209.45 65.96667 210.43333 64.166664 212.0 62.6 C 212.53334 62.033333 213.11667 61.566666 213.75 61.2 L 211.7 58.1 C 213.43333 56.93333 215.35 56.216663 217.45 55.95 L 218.3 52.9 L 220.9 52.9 L 221.7 55.95 C 223.23334 56.11667 224.68333 56.550003 226.05 57.25 Z M 219.0 84.7 L 219.0 84.75 Z M 208.85 70.3 L 208.85 70.25 Z M 217.8 68.2 L 218.15 67.9 L 214.9 62.95 L 213.5 64.1 C 212.23334 65.36667 211.43333 66.816666 211.1 68.45 L 217.15 69.75 C 217.18333 69.15 217.40001 68.63333 217.8 68.2 Z M 231.0 75.55 C 231.76666 73.916664 232.15 72.13333 232.15 70.2 L 232.1 68.65 L 223.85 69.7 L 223.9 70.25 C 223.9 70.88333 223.78333 71.46667 223.55 72.0 L 231.0 75.55 Z"/>
</g>
</g>
</svg>
</code></pre>
| <html><svg> | 2016-02-28 14:42:12 | HQ |
35,683,991 | Kotlin: Make an internal function visible for unit tests | <p>In case the tests are in a different module than the production code (which is common), what's the best way to make internal functions visible for tests?</p>
<p>In Java, I would have the production code and the test in the same package and make the methods-to-be-tested package-private (plus, add a <code>@VisibleForTest</code> annotation if the only reason for having it package-private rather than private is the test). Unfortunately, Kotlin doesn't have the concept of package-private.</p>
| <unit-testing><kotlin><package-private> | 2016-02-28 14:52:27 | HQ |
35,684,864 | How to do an if statement in perl? | <p>Having a problem with if statement in Perl, my if statement is not working. What am I doing wrong, because I'm using strict and warnings module, but still my if statement is not working.</p>
<pre><code>#!/usr/bin/env perl
use strict;
use warnings;
sub Granted
{
print "\n\nAccess Granted\n\n";
}
sub Access
{
print "\n\n\n\n";
sleep 1;
print "Enter your name: ";
my $name = <STDIN>;
sleep 1;
if ("$name" eq "jake")
{
Granted
}
}
Access
</code></pre>
| <perl><perl-module> | 2016-02-28 16:08:29 | LQ_CLOSE |
35,684,882 | Running a program after compiling with Javac | I have a source file named Plane.java. I am trying to compile and run the program in terminal but i can't !
I am compiling it with :
javac Plane.java
So , i am getting with ls my classes
CargoBay.class
CleaningEmployee.class
Employee.class
EquipmentComponent.class
MaintenanceEmployee.class
PassengerComponent.class
Plane.class
Plane.java
PlaneComponent.class
PrivateComponent.class
SecurityEmployee.class
Now , i have no idea how to run it ! I am trying with java Plane but i am getting errors , any ideas ?
The program runs just fine in netbeans | <java><compilation> | 2016-02-28 16:10:01 | LQ_EDIT |
35,685,635 | Retrofit v2 Does Call.cancel() remove Callback? | <p>I've read in the <a href="https://github.com/square/retrofit/issues/297" rel="noreferrer">Retrofit v2 API Spec</a> that calling the cancel() method on the Call class returned from your custom retrofit interface should set the Callback passed in to null.</p>
<blockquote>
<p>cancel() is a no-op after the response has been received. In all other
cases the method will set any callbacks to null (thus freeing strong
references to the enclosing class if declared anonymously)</p>
</blockquote>
<p>Going through the code I can't see that the Callback is explicitly set to null when cancel is called. I can see the callback being referenced in the <a href="https://github.com/square/retrofit/blob/6269b91f2d7436c6afed47fb5f2be80c566f412a/retrofit/src/main/java/retrofit2/OkHttpCall.java" rel="noreferrer">OkHttpCall</a> class (although not explicitly stored). Calling cancel will in turn call cancel on the RealCall class which takes care of the Http side of canceling, but does not concern itself with the stored callback in the AsyncCall class (which is put in the readyAsyncCalls and runningAsyncCalls queues in the Dispatcher class. It is unfamiliar code to me so I might be missing something.</p>
<p>Can someone confidently confirm that calling cancel() on my call object will remove reference to the Callback I've passed in so I don't leak memory?</p>
<p>Simplified code example:</p>
<pre><code>@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
api = retrofit.create(Api.class);
}
@Override
public void onStart() {
super.onStart();
call = api.getPokedex();
call.enqueue(new Callback<Pokedex>() {
@Override
public void onResponse(Call<Pokedex> call, Response<Pokedex> response) {
populate(response.body());
}
@Override
public void onFailure(Call<Pokedex> call, Throwable t) {
error(t.getMessage());
}
});
}
@Override
public void onStop() {
call.cancel();
super.onStop();
}
</code></pre>
| <java><android><retrofit2><okhttp3> | 2016-02-28 17:13:55 | HQ |
35,685,726 | UIBezierPath doesn't work in TopRight corner and BottomRight corner | <p>I want to round my right corners, but only works for Left corners</p>
<pre><code>let path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: [UIRectCorner.TopLeft, UIRectCorner.TopRight], cornerRadii: CGSizeMake(20.0, 20.0))
let maskLayer = CAShapeLayer()
maskLayer.path = path.CGPath
view.layer.mask = maskLayer
view.layer.masksToBounds = true
</code></pre>
| <swift><uibezierpath> | 2016-02-28 17:23:00 | HQ |
35,686,281 | How to compare value 3.0.1 with 3.0.2 where these two numeric values are in String ? | <p>I have 3.0.1 and 3.0.2 in string data type java. Now I want to check which value is larger therefore I was converting these two into float using Float.parseFloat(str).</p>
<p>But Its throwing number format exception.</p>
<p>Any Help?</p>
<p>Thanks
Pravin</p>
| <java><android><core> | 2016-02-28 18:09:12 | LQ_CLOSE |
35,686,363 | Filters vs interceptors in web application | <p>I could not get the correct difference between filters and interceptors. So
Please explain me the exact
use of filters and interceptors
in java based web application with some sample snippet.</p>
| <java> | 2016-02-28 18:15:59 | HQ |
35,687,353 | React-Bootstrap link item in a navitem | <p>I'm having some styling issues using react-router and react-bootstrap. below is a snippet of the code</p>
<pre><code>import { Route, RouteHandler, Link } from 'react-router';
import AuthService from '../services/AuthService'
import { Button, Nav, Navbar, NavDropdown, MenuItem, NavItem } from 'react-bootstrap';
<Nav pullRight>
<NavItem eventKey={1}>
<Link to="home">Home</Link>
</NavItem>
<NavItem eventKey={2}>
<Link to="book">Book Inv</Link>
</NavItem>
<NavDropdown eventKey={3} title="Authorization" id="basic-nav-dropdown">
<MenuItem eventKey="3.1">
<a href="" onClick={this.logout}>Logout</a>
</MenuItem>
</NavDropdown>
</Nav>
</code></pre>
<p>This is what it looks like when it renders.</p>
<p><a href="https://i.stack.imgur.com/h6aUI.png"><img src="https://i.stack.imgur.com/h6aUI.png" alt="enter image description here"></a></p>
<p>I know that the <code><Link></Link></code> is causing this but I don't know why? I would like for this to be in-line.</p>
| <react-router><react-bootstrap> | 2016-02-28 19:44:54 | HQ |
35,688,407 | Piping a file into docker run | <p>I need to pipe (inject) a file or some data into docker as part of the run command and have it written to a file within the container as part of the startup. Is there best practise way to do this ? </p>
<p>I've tried this.</p>
<pre><code>cat data.txt | docker run -a stdin -a stdout -i -t ubuntu /bin/bash -c 'cat >/data.txt'
</code></pre>
<p>But can't seem to get it to work. </p>
| <docker><pipe> | 2016-02-28 21:19:49 | HQ |
35,688,553 | Does a thread waiting on IO also block a core? | <p>In the synchronous/blocking model of computation we usually say that a thread of execution will wait (be <em>blocked</em>) while it waits for an IO task to complete.</p>
<p>My question is simply will this usually cause the CPU core executing the thread to be idle, or will a thread waiting on IO usually be context switched out and put into a waiting state until the IO is ready to be processed?</p>
| <multithreading><asynchronous><blocking><synchronous><cpu-architecture> | 2016-02-28 21:33:04 | HQ |
35,689,080 | How to read child_process.spawnSync stdout with stdio option 'inherit' | <pre><code>var childProcess = cp.spawnSync(command, args, {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
encoding: 'utf-8'
});
</code></pre>
<p>childProcess.output always eq [null, null, null]</p>
<p>process.stdout.write hook doesn't give me any output</p>
| <node.js><child-process><spawn> | 2016-02-28 22:26:57 | HQ |
35,689,283 | How to find the median for an array of numbers for java? | <pre><code>public double median(){
double input =0;
double answer =sum() * (input) / data.length;
return answer;
}
</code></pre>
<p>This is my code I have for median but it keeps returning as zero when I run the program. The array of numbers are: {3.0, 15.0, 7.0, 27.0};</p>
| <java><arrays><median> | 2016-02-28 22:49:35 | LQ_CLOSE |
35,690,354 | Unable to start activity ComponentInfo{com.ceit.worldofgravity/com.ceit.worldofgravity.MainMenu}: : java.lang.NullPointerException | <p>I really don't where does this NullPointerException takes place...
I checked my xml files and it's declaration..still there is a NULL...</p>
<p>This the CatLog..</p>
<pre><code>02-29 00:15:12.988: E/AndroidRuntime(1287): FATAL EXCEPTION: main
02-29 00:15:12.988: E/AndroidRuntime(1287): java.lang.RuntimeException:Unable to start activity ComponentInfo{com.ceit.worldofgravity/com.ceit.worldofgravity.MainMenu}: java.lang.NullPointerException
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.os.Handler.dispatchMessage(Handler.java:99)
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.os.Looper.loop(Looper.java:137)
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.app.ActivityThread.main(ActivityThread.java:5041)
02-29 00:15:12.988: E/AndroidRuntime(1287): at java.lang.reflect.Method.invokeNative(Native Method)
02-29 00:15:12.988: E/AndroidRuntime(1287): at java.lang.reflect.Method.invoke(Method.java:511)
02-29 00:15:12.988: E/AndroidRuntime(1287): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-29 00:15:12.988: E/AndroidRuntime(1287): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-29 00:15:12.988: E/AndroidRuntime(1287): at dalvik.system.NativeStart.main(Native Method)
02-29 00:15:12.988: E/AndroidRuntime(1287): Caused by: java.lang.NullPointerException
02-29 00:15:12.988: E/AndroidRuntime(1287): at com.ceit.worldofgravity.MainMenu.onCreate(MainMenu.java:33)
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.app.Activity.performCreate(Activity.java:5104)
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-29 00:15:12.988: E/AndroidRuntime(1287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-29 00:15:12.988: E/AndroidRuntime(1287): ... 11 more
</code></pre>
<p>Main Menu.java</p>
<p>=================================================================</p>
<pre><code>package com.ceit.worldofgravity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class MainMenu extends Activity{
RelativeLayout Btn;
ImageView ImageButton;
TextView txt;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Btn = (RelativeLayout) findViewById(R.id.btn_start);
ImageButton = (ImageView) findViewById(R.id.imageView2);
Typeface Custom = Typeface.createFromAsset(getAssets(),"Sketch 3D.otf");
txt.setTypeface(Custom);
Btn.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
return false;
}
});
Btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(MainMenu.this, Game.class);
startActivities(myIntent);
}
});
}
protected void startActivities(Intent myIntent) {
}
}
</code></pre>
<p>main.xml</p>
<pre><code> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bb"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainMenu" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="550dp"
android:layout_height="160dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/title" android:contentDescription="TODO"/>
<RelativeLayout
android:id="@+id/btn_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/play" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/start_game"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</code></pre>
<p></p>
| <android><eclipse> | 2016-02-29 00:58:34 | LQ_CLOSE |
35,690,474 | C# substring text of a textbox and datetime picker to a maskbox | I use to generate the permanent code with a button after I entered everything.
like so:
mskCodePer.Text = txtNom.Text.Substring(0, 3) + txtPrenom.Text.Substring(0, 1) + dptNaisc.Text.Substring(8, 2) + dptNaisc.Text.Substring(4, 4) + dptNaisc.Text.Substring(2, 3);
But my teacher force me to do it in a way that it happens automatically as I type, but I don't understand how.... I tried to code into the textchanged event but each time I only get to type one letter, it crash and tells me the ArgumentOutOfRangeException has not been generated | <c#><winforms><substring> | 2016-02-29 01:16:11 | LQ_EDIT |
35,690,736 | Handling changes to files with --skip-worktree from another branch | <p>On my machine, I've set <code>--skip-worktree</code> to <code>config/database.yml</code>.</p>
<pre><code>git update-index --skip-worktree config/database.yml
</code></pre>
<p>Another developer has committed and merged into the develop branch changes to <code>config/database.yml</code> while working on the project.</p>
<p>Now, when I do <code>git pull origin develop</code>, I get</p>
<pre><code>Andrews-Air:[project] agrimm$ git pull origin develop
From bitbucket.org:[company]/[project]
* branch develop -> FETCH_HEAD
Updating [SHA]..[Another SHA]
error: Your local changes to the following files would be overwritten by merge:
config/database.yml
Please, commit your changes or stash them before you can merge.
Aborting
</code></pre>
<p>How should I handle such a change? Should I do</p>
<pre><code>git update-index --no-skip-worktree config/database.yml
git stash save "Save changes to config/database.yml"
git pull origin develop
git stash apply
# Fix any conflicts
git update-index --skip-worktree config/database.yml
</code></pre>
<p>Or is there a less hacky approach?</p>
| <git><branching-and-merging><git-skip-worktree> | 2016-02-29 01:51:12 | HQ |
35,691,051 | Difference between scope and authority in UAA | <p>In UAA There are two Concepts, Authority and Scope.</p>
<p>These concepts seems to overlap. I would like to know exact difference and purpose</p>
<p>For example , oauth.login</p>
| <cloudfoundry-uaa> | 2016-02-29 02:35:19 | HQ |
35,691,380 | Localising a UILabel with attributed string from a Storyboard | <p>I have a UILabel with text set as "attributed" in a storyboard. When I generate the Main.strings file for translating into a different language the text for this label does not appear.</p>
<p>I tried to add manually an entry into the Main.strings file by copying the object id. I tried setting the "text" property and the "attributedText" property but when I run the app the translated string is not used.</p>
<p>So, how do I localise an UILabel set as "attributed" on a storyboard?</p>
| <ios><objective-c><localization><nsattributedstring> | 2016-02-29 03:17:22 | HQ |
35,691,851 | load rtf file into UITextView in Swift 2 | <p>Can somebody help me to load an rtf text into UITextView with Swift 2? The answers I've gotten are old and out of date. The text is instructions on how to play the game I'm writing in an app. So far, all I've been able to do is to copy and paste all the rtf text into the placeholder box. This works for iPhones in the simulator, but when trying it in the iPad simulator or iPhone 6 Plus there appears double vertical scroll bars when I do this. It looks messy.</p>
<p>I also now have a real plain text of the same file, so we can try that too.</p>
| <ios><swift2><uitextview> | 2016-02-29 04:12:04 | HQ |
35,691,858 | Typescript hasOwnProperty equivalent | <p>In javascript if I want to loop through a dictionary and set properties of another dictionary, I'd use something like this:</p>
<pre><code>for (let key in dict) {
if (obj.hasOwnProperty(key)) {
obj[key] = dict[key];
}
}
</code></pre>
<p>If <code>obj</code> is a Typescript object (instance of a class), is there a way to perform the same operation?</p>
| <javascript><object><typescript><typescript1.8> | 2016-02-29 04:12:28 | HQ |
35,692,265 | How to load resource in cocoapods resource_bundle | <p>I have struggled a lot to how to load resource in cocoapods resource_bundle. </p>
<p>The following is what i put in the <code>.podspecs</code> file.</p>
<pre><code>s.source_files = 'XDCoreLib/Pod/Classes/**/*'
s.resource_bundles = {
'XDCoreLib' => ['XDCoreLib/Pod/Resources/**/*.{png,storyboard}']
}
</code></pre>
<p>This is what I am trying to do from the main project.</p>
<pre><code>let bundle = NSBundle(forClass: XDWebViewController.self)
let image = UIImage(named: "ic_arrow_back", inBundle: bundle, compatibleWithTraitCollection: nil)
print(image)
</code></pre>
<p>I did see the picture in the <code>XDCoreLib.bundle</code>, but it return a nil.</p>
| <ios><cocoapods> | 2016-02-29 05:00:40 | HQ |
35,692,507 | plot several image files in matplotlib subplots | <p>I would like to create a matrix subplot and display each BMP files, from a directory, in a different subplot, but I cannot find the appropriate solution for my problem, could somebody helping me?.</p>
<p>This the code that I have:</p>
<pre><code>import os, sys
from PIL import Image
import matplotlib.pyplot as plt
from glob import glob
bmps = glob('*trace*.bmp')
fig, axes = plt.subplots(3, 3)
for arch in bmps:
i = Image.open(arch)
iar = np.array(i)
for i in range(3):
for j in range(3):
axes[i, j].plot(iar)
plt.subplots_adjust(wspace=0, hspace=0)
plt.show()
</code></pre>
<p>I am having the following error after executing:</p>
<p><a href="https://i.stack.imgur.com/7ysnN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7ysnN.png" alt="enter image description here"></a></p>
| <matplotlib> | 2016-02-29 05:23:25 | HQ |
35,692,630 | How to do retrieve slq data and display in php page | i want to retrieve particular cell data from mysql. and it should display in a php page.
details-
db name: register,
columns are: username, fullname, email, password.
i want to display 'fullname' column first row data in php.
how to do that. | <php><mysql> | 2016-02-29 05:36:14 | LQ_EDIT |
35,693,218 | Angularjs ui bootstrap: how to vertical center modal component? | <p>Recently I am learning angularjs. I have used bootstrap before. With jquery, I can easily change the position of the modal component position to make it vertical align. Now with angularjs, it seems not very easy to do that. Here is a plunker link of ui bootstrap modal, Does anyone know how to make it vertical align?</p>
<p><a href="http://plnkr.co/edit/TvLQkPh0cs4McxfLpE9u?p=preview" rel="noreferrer">ui bootstrap modal component</a></p>
<p>1.index.html </p>
<pre><code> <!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.2.1.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="ModalDemoCtrl">
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3 class="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body">
This is modal body
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>
</script>
<button type="button" class="btn btn-default" ng-click="open()">Open me!</button>
</div>
</body>
</html>
</code></pre>
<p>2.example.js</p>
<pre><code> angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function($scope, $uibModal, $log) {
$scope.items = ['item1', 'item2', 'item3'];
$scope.animationsEnabled = true;
$scope.open = function(size) {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
size: size,
resolve: {
items: function() {
return $scope.items;
}
}
});
};
});
angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function($scope, $uibModalInstance, items) {
$scope.ok = function() {
$uibModalInstance.close($scope.selected.item);
};
$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
});
</code></pre>
| <angularjs><angular-ui-bootstrap><bootstrap-modal> | 2016-02-29 06:29:14 | HQ |
35,693,727 | syntax error, unexpected '<', expecting ';' or '\n' | <p>Tried to include a module in another one, but something goes wrong</p>
<pre><code>ruby pipboy.rb
pipboy.rb:3: syntax error, unexpected '<', expecting ';' or '\n'
def Pipboy < Person
^
pipboy.rb:22: syntax error, unexpected keyword_end, expecting end-of-input
</code></pre>
| <ruby> | 2016-02-29 07:07:49 | LQ_CLOSE |
35,693,905 | How to encrypt and decrypt the password in android | <p>I have explored a lot to search encryption and decryption of passwords in android, I have found many algorithms but not able to find the one which is most secure.
I want to first encrypt the password using some key and that should be decrypted using the same key.
Which algorithm should I use for this ? Can someone please give an example for this.</p>
<p>Thanks a lot for all your help.</p>
| <android><encryption> | 2016-02-29 07:20:28 | LQ_CLOSE |
35,694,273 | What's the difference between gRPC and WCF? | <p>I know we are comparing 2 different technologies, but I would like to know pros and cons of both. WCF is present for almost a decade now. Didn't anything similar exist in java world until now? </p>
| <wcf><grpc> | 2016-02-29 07:44:35 | HQ |
35,694,378 | Javascript/jquery : Count monday in a given date range | please help me to count the Monday in a given date range using javascript or jquery, date range like
(2016-02-22 to 2016-02-29).
I searched a lot but in the last I got nothing.
Thanks in advance
| <javascript><jquery><date> | 2016-02-29 07:53:29 | LQ_EDIT |
35,694,827 | remove more then one id sql server | how to remove more then one id remove, except number 1 id please see below image, i want query how do this
[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/YawZD.jpg | <sql><sql-server><sql-server-2008> | 2016-02-29 08:25:13 | LQ_EDIT |
35,694,905 | Laravel validation pdf mime | <p>I have tried below mime types for validating PDF files.but none of them doesnt pass the validation .</p>
<pre><code> $rules = [
....
"file" => "required|mimes:application/pdf, application/x-pdf,application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf|max:10000"
....
]
</code></pre>
| <validation><laravel><mime> | 2016-02-29 08:30:03 | HQ |
35,695,160 | How to edit a text file in my terminal | <p>I'm using Linux mint and using the vi command to create text files, now that I created a text file and saved it. How do I get back into to edit the text file again? </p>
<pre><code>vi helloWorld.txt
</code></pre>
| <linux><terminal><text-files> | 2016-02-29 08:46:03 | HQ |
35,695,839 | Android ExoPlayer not resuming after network is connected | <p>Im using <a href="https://github.com/google/ExoPlayer" rel="noreferrer">Exoplayer</a> for HLS Streaming in my App. Its playing nicely but when i disconnect the internet connection and enable it again,Exo player does not resume the video play.</p>
<p>Exoplayer is handling this by default or do i need to manually handle this? </p>
<p>here is my code..`</p>
<pre><code> public class PlayerActivity extends Activity implements SurfaceHolder.Callback, OnClickListener,
DemoPlayer.Listener, DemoPlayer.CaptionListener, DemoPlayer.Id3MetadataListener,
AudioCapabilitiesReceiver.Listener { public class PlayerActivity extends Activity implements SurfaceHolder.Callback, OnClickListener,
DemoPlayer.Listener, DemoPlayer.CaptionListener, DemoPlayer.Id3MetadataListener,
AudioCapabilitiesReceiver.Listener {
// For use within demo app code.
public static final String CONTENT_ID_EXTRA = "content_id";
public static final String CONTENT_TYPE_EXTRA = "content_type";
public static final String PROVIDER_EXTRA = "provider";
// For use when launching the demo app using adb.
private static final String CONTENT_EXT_EXTRA = "type";
private static final String TAG = "PlayerActivity";
private static final int MENU_GROUP_TRACKS = 1;
private static final int ID_OFFSET = 2;
private static final CookieManager defaultCookieManager;
static {
defaultCookieManager = new CookieManager();
defaultCookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
}
private EventLogger eventLogger;
private MediaController mediaController;
private View debugRootView;
private View shutterView;
private AspectRatioFrameLayout videoFrame;
private SurfaceView surfaceView;
private TextView debugTextView;
private TextView playerStateTextView;
private SubtitleLayout subtitleLayout;
private Button videoButton;
private Button audioButton;
private Button textButton;
private Button retryButton;
static TextView bitrateTextView;
private static DemoPlayer player;
private DebugTextViewHelper debugViewHelper;
private boolean playerNeedsPrepare;
private long playerPosition;
private boolean enableBackgroundAudio;
private Uri contentUri;
private int contentType;
private String contentId;
private String provider;
RotateAnimation rotate;
ImageView rotateLoad=null;
ImageView loadMid=null;
FrameLayout videoLoad;
private String vidLink ="";
private String title =""; private TextView vodTitle;
private String description =""; private TextView vodDesc;
private String vodimage =""; private ImageView vodThumb;
private String chimage =""; private ImageView chLogo;
private String datetitle =""; private TextView vodTimeDesc, videoCurrentTime, videoTimeEnd;
private Bitmap vodImgThumb, chImgLogo;
private static FrameLayout guideInfo;
private FrameLayout seekBar;
private FrameLayout playPause;
private int rewindRate = 1;
private int forwardRate = 1, stopPosition ;
private SeekBar sb;
CountDownTimer ct;
int infoFade = 0 , seekFade =0 , height, width;
private boolean isPlaying = false;
static long storeBitRate;
private AudioCapabilitiesReceiver audioCapabilitiesReceiver;
// Activity lifecycle
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.player_activity);
View root = findViewById(R.id.root);
shutterView = findViewById(R.id.shutter);
debugRootView = findViewById(R.id.controls_root);
videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
surfaceView = (SurfaceView) findViewById(R.id.surface_view);
surfaceView.getHolder().addCallback(this);
debugTextView = (TextView) findViewById(R.id.debug_text_view);
playerStateTextView = (TextView) findViewById(R.id.player_state_view);
subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles);
mediaController = new KeyCompatibleMediaController(this);
mediaController.setAnchorView(root);
// retryButton = (Button) findViewById(R.id.retry_button);
// retryButton.setOnClickListener(this);
videoButton = (Button) findViewById(R.id.video_controls);
audioButton = (Button) findViewById(R.id.audio_controls);
textButton = (Button) findViewById(R.id.text_controls);
playPause = (FrameLayout)findViewById(R.id.videoPlayPause);
videoLoad = (FrameLayout) findViewById(R.id.videoLoad);
sb = (SeekBar)findViewById(R.id.seekBar1);
// Guide Info Animator
guideInfo = (FrameLayout)findViewById(R.id.guide_info);
seekBar = (FrameLayout)findViewById(R.id.video_seek);
playPause = (FrameLayout)findViewById(R.id.videoPlayPause);
videoCurrentTime = (TextView)findViewById(R.id.video_timestart);
bitrateTextView=(TextView)findViewById(R.id.bitratetext);
videoTimeEnd = (TextView)findViewById(R.id.video_timeend);
seekBar.setVisibility(View.GONE);
playPause.setVisibility(View.GONE);
root.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE
|| keyCode == KeyEvent.KEYCODE_MENU) {
return false;
}
if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
}
return mediaController.dispatchKeyEvent(event);
}
});
CookieHandler currentHandler = CookieHandler.getDefault();
if (currentHandler != defaultCookieManager) {
CookieHandler.setDefault(defaultCookieManager);
}
audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
audioCapabilitiesReceiver.register();
}
@Override
public void onNewIntent(Intent intent) {
releasePlayer();
playerPosition = 0;
setIntent(intent);
}
@Override
public void onResume() {
super.onResume();
Intent intent = getIntent();
Bundle extras = getIntent().getExtras();
contentUri = intent.getData();
contentType = Util.TYPE_HLS;
title = extras.getString("title", title);
description = extras.getString("description", description);
vodimage = extras.getString("vodimage", vodimage);
chimage = extras.getString("chimage", chimage);
datetitle = extras.getString("datetitle", datetitle);
// Set Data
vodTitle = (TextView)findViewById(R.id.vodTitle);
vodTitle.setText(title);
vodDesc = (TextView)findViewById(R.id.vodDesc);
/* DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(), null);
String dfg=bandwidthMeter.getBitrateEstimate()+"";*/
vodDesc.setText(description);
vodThumb = (ImageView)findViewById(R.id.vodThumb);
chLogo = (ImageView)findViewById(R.id.chLogo);
vodTimeDesc = (TextView)findViewById(R.id.vodTimeDesc);
vodTimeDesc.setText(datetitle);
rotate = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(2000);
rotate.setRepeatCount(Animation.INFINITE);
rotate.setInterpolator(new LinearInterpolator());
rotateLoad= (ImageView) findViewById(R.id.lycaLoadMid_rotate);
loadMid = (ImageView) findViewById(R.id.lycaLoadMid);
rotateLoad.startAnimation(rotate);
videoLoad = (FrameLayout) findViewById(R.id.videoLoad);
//Gathering images
LoadImages loadImage= new LoadImages ();
loadImage.execute(vodimage,chimage);
if (player == null) {
// if (!maybeRequestPermission()) {
preparePlayer(true);
//}
} else {
player.setBackgrounded(false);
}
}
@Override
public void onPause() {
super.onPause();
if (!enableBackgroundAudio) {
releasePlayer();
} else {
player.setBackgrounded(true);
}
shutterView.setVisibility(View.VISIBLE);
}
@Override
public void onDestroy() {
super.onDestroy();
audioCapabilitiesReceiver.unregister();
releasePlayer();
}
// OnClickListener methods
@Override
public void onClick(View view) {
if (view == retryButton) {
preparePlayer(true);
}
}
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
}
// AudioCapabilitiesReceiver.Listener methods
@Override
public void onAudioCapabilitiesChanged(AudioCapabilities audioCapabilities) {
if (player == null) {
return;
}
boolean backgrounded = player.getBackgrounded();
boolean playWhenReady = player.getPlayWhenReady();
releasePlayer();
preparePlayer(playWhenReady);
player.setBackgrounded(backgrounded);
}
// Permission request listener method
// Internal methods
private RendererBuilder getRendererBuilder() {
String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
switch (contentType) {
case Util.TYPE_SS:
return new SmoothStreamingRendererBuilder(this, userAgent, contentUri.toString(),
new SmoothStreamingTestMediaDrmCallback());
case Util.TYPE_DASH:
return new DashRendererBuilder(this, userAgent, contentUri.toString(),
new WidevineTestMediaDrmCallback(contentId, provider));
case Util.TYPE_HLS:
return new HlsRendererBuilder(this, userAgent, contentUri.toString());
case Util.TYPE_OTHER:
return new ExtractorRendererBuilder(this, userAgent, contentUri);
default:
throw new IllegalStateException("Unsupported type: " + contentType);
}
}
private void preparePlayer(boolean playWhenReady) {
if (player == null) {
player = new DemoPlayer(getRendererBuilder());
player.addListener(this);
player.setCaptionListener(this);
player.setMetadataListener(this);
player.seekTo(playerPosition);
playerNeedsPrepare = true;
mediaController.setMediaPlayer(player.getPlayerControl());
mediaController.setEnabled(true);
eventLogger = new EventLogger();
eventLogger.startSession();
player.addListener(eventLogger);
player.setInfoListener(eventLogger);
player.setInternalErrorListener(eventLogger);
//debugViewHelper = new DebugTextViewHelper(player, debugTextView);
// debugViewHelper.start();
}
if (playerNeedsPrepare) {
player.prepare();
playerNeedsPrepare = false;
updateButtonVisibilities();
}
player.setSurface(surfaceView.getHolder().getSurface());
player.setPlayWhenReady(playWhenReady);
guideInfo.setVisibility(View.VISIBLE);
guideInfo.postDelayed(new Runnable() { public void run() { guideInfo.setVisibility(View.GONE); } }, 5000);
}
private void releasePlayer() {
if (player != null) {
debugViewHelper.stop();
debugViewHelper = null;
playerPosition = player.getCurrentPosition();
player.release();
player = null;
eventLogger.endSession();
eventLogger = null;
}
}
// DemoPlayer.Listener implementation
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED) {
showControls();
}
if (playbackState == ExoPlayer.STATE_BUFFERING) {
if(videoLoad.getVisibility()==View.GONE){
videoLoad.setVisibility(View.VISIBLE);
}
}
if (playbackState == ExoPlayer.STATE_READY) {
videoLoad.setVisibility(View.GONE);
}
if (playbackState == ExoPlayer.STATE_ENDED) {
videoLoad.setVisibility(View.GONE);
finish();
}
if(playWhenReady){
}
String text = "playWhenReady=" + playWhenReady + ", playbackState=";
switch(playbackState) {
case ExoPlayer.STATE_BUFFERING:
text += "buffering";
break;
case ExoPlayer.STATE_ENDED:
text += "ended";
break;
case ExoPlayer.STATE_IDLE:
text += "idle";
break;
case ExoPlayer.STATE_PREPARING:
text += "preparing";
break;
case ExoPlayer.STATE_READY:
text += "ready";
break;
default:
text += "unknown";
break;
}
// playerStateTextView.setText(text);
updateButtonVisibilities();
}
@Override
public void onError(Exception e) {
String errorString = null;
if (e instanceof UnsupportedDrmException) {
// Special case DRM failures.
UnsupportedDrmException unsupportedDrmException = (UnsupportedDrmException) e;
errorString = getString(Util.SDK_INT < 18 ? R.string.error_drm_not_supported
: unsupportedDrmException.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown);
} else if (e instanceof ExoPlaybackException
&& e.getCause() instanceof DecoderInitializationException) {
// Special case for decoder initialization failures.
DecoderInitializationException decoderInitializationException =
(DecoderInitializationException) e.getCause();
if (decoderInitializationException.decoderName == null) {
if (decoderInitializationException.getCause() instanceof DecoderQueryException) {
errorString = getString(R.string.error_querying_decoders);
} else if (decoderInitializationException.secureDecoderRequired) {
errorString = getString(R.string.error_no_secure_decoder,
decoderInitializationException.mimeType);
} else {
errorString = getString(R.string.error_no_decoder,
decoderInitializationException.mimeType);
}
}
else {
errorString = getString(R.string.error_instantiating_decoder,
decoderInitializationException.decoderName);
}
}
if (errorString != null) {
Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_LONG).show();
}
playerNeedsPrepare = true;
updateButtonVisibilities();
showControls();
}
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
float pixelWidthAspectRatio) {
shutterView.setVisibility(View.GONE);
videoFrame.setAspectRatio(
height == 0 ? 1 : (width * pixelWidthAspectRatio) / height);
}
// User controls
private void updateButtonVisibilities() {
// retryButton.setVisibility(playerNeedsPrepare ? View.VISIBLE : View.GONE);
videoButton.setVisibility(haveTracks(DemoPlayer.TYPE_VIDEO) ? View.VISIBLE : View.GONE);
audioButton.setVisibility(haveTracks(DemoPlayer.TYPE_AUDIO) ? View.VISIBLE : View.GONE);
textButton.setVisibility(haveTracks(DemoPlayer.TYPE_TEXT) ? View.VISIBLE : View.GONE);
}
private boolean haveTracks(int type) {
return player != null && player.getTrackCount(type) > 0;
}
public void showVideoPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
configurePopupWithTracks(popup, null, DemoPlayer.TYPE_VIDEO);
popup.show();
}
public void showAudioPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
Menu menu = popup.getMenu();
menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
final MenuItem backgroundAudioItem = menu.findItem(0);
backgroundAudioItem.setCheckable(true);
backgroundAudioItem.setChecked(enableBackgroundAudio);
OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item == backgroundAudioItem) {
enableBackgroundAudio = !item.isChecked();
return true;
}
return false;
}
};
configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
popup.show();
}
public void showTextPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
configurePopupWithTracks(popup, null, DemoPlayer.TYPE_TEXT);
popup.show();
}
public void showVerboseLogPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
Menu menu = popup.getMenu();
menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal);
menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose);
menu.setGroupCheckable(Menu.NONE, true, true);
menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true);
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == 0) {
VerboseLogUtil.setEnableAllTags(false);
} else {
VerboseLogUtil.setEnableAllTags(true);
}
return true;
}
});
popup.show();
}
private void configurePopupWithTracks(PopupMenu popup,
final OnMenuItemClickListener customActionClickListener,
final int trackType) {
if (player == null) {
return;
}
int trackCount = player.getTrackCount(trackType);
if (trackCount == 0) {
return;
}
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return (customActionClickListener != null
&& customActionClickListener.onMenuItemClick(item))
|| onTrackItemClick(item, trackType);
}
});
Menu menu = popup.getMenu();
// ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0).
menu.add(MENU_GROUP_TRACKS, DemoPlayer.TRACK_DISABLED + ID_OFFSET, Menu.NONE, R.string.off);
for (int i = 0; i < trackCount; i++) {
menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE,
buildTrackName(player.getTrackFormat(trackType, i)));
}
menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true);
menu.findItem(player.getSelectedTrack(trackType) + ID_OFFSET).setChecked(true);
}
private static String buildTrackName(MediaFormat format) {
if (format.adaptive) {
return "auto";
}
String trackName;
if (MimeTypes.isVideo(format.mimeType)) {
trackName = joinWithSeparator(joinWithSeparator(buildResolutionString(format),
buildBitrateString(format)), buildTrackIdString(format));
} else if (MimeTypes.isAudio(format.mimeType)) {
trackName = joinWithSeparator(joinWithSeparator(joinWithSeparator(buildLanguageString(format),
buildAudioPropertyString(format)), buildBitrateString(format)),
buildTrackIdString(format));
} else {
trackName = joinWithSeparator(joinWithSeparator(buildLanguageString(format),
buildBitrateString(format)), buildTrackIdString(format));
}
return trackName.length() == 0 ? "unknown" : trackName;
}
private static String buildResolutionString(MediaFormat format) {
return format.width == MediaFormat.NO_VALUE || format.height == MediaFormat.NO_VALUE
? "" : format.width + "x" + format.height;
}
private static String buildAudioPropertyString(MediaFormat format) {
return format.channelCount == MediaFormat.NO_VALUE || format.sampleRate == MediaFormat.NO_VALUE
? "" : format.channelCount + "ch, " + format.sampleRate + "Hz";
}
private static String buildLanguageString(MediaFormat format) {
return TextUtils.isEmpty(format.language) || "und".equals(format.language) ? ""
: format.language;
}
private static String buildBitrateString(MediaFormat format) {
String s=format.bitrate == MediaFormat.NO_VALUE ? ""
: String.format(Locale.US, "%.2fMbit", format.bitrate / 1000000f);
// Toast.makeText(con, s, Toast.LENGTH_LONG).show();
return s;
}
private static String joinWithSeparator(String first, String second) {
return first.length() == 0 ? second : (second.length() == 0 ? first : first + ", " + second);
}
private static String buildTrackIdString(MediaFormat format) {
return format.trackId == null ? "" : " (" + format.trackId + ")";
}
private boolean onTrackItemClick(MenuItem item, int type) {
if (player == null || item.getGroupId() != MENU_GROUP_TRACKS) {
return false;
}
player.setSelectedTrack(type, item.getItemId() - ID_OFFSET);
return true;
}
private void toggleControlsVisibility() { /*/////////////////////////////////// Showing defalut controllers */
if (mediaController.isShowing()) {
mediaController.hide();
debugRootView.setVisibility(View.GONE);
} else {
showControls();
}
}
private void showControls() {
mediaController.show(0);
debugRootView.setVisibility(View.VISIBLE);
}
// DemoPlayer.CaptionListener implementation
@Override
public void onCues(List<Cue> cues) {
subtitleLayout.setCues(cues);
}
// DemoPlayer.MetadataListener implementation
@Override
public void onId3Metadata(Map<String, Object> metadata) {
for (Map.Entry<String, Object> entry : metadata.entrySet()) {
if (TxxxMetadata.TYPE.equals(entry.getKey())) {
TxxxMetadata txxxMetadata = (TxxxMetadata) entry.getValue();
Log.i(TAG, String.format("ID3 TimedMetadata %s: description=%s, value=%s",
TxxxMetadata.TYPE, txxxMetadata.description, txxxMetadata.value));
} else if (PrivMetadata.TYPE.equals(entry.getKey())) {
PrivMetadata privMetadata = (PrivMetadata) entry.getValue();
Log.i(TAG, String.format("ID3 TimedMetadata %s: owner=%s",
PrivMetadata.TYPE, privMetadata.owner));
} else if (GeobMetadata.TYPE.equals(entry.getKey())) {
GeobMetadata geobMetadata = (GeobMetadata) entry.getValue();
Log.i(TAG, String.format("ID3 TimedMetadata %s: mimeType=%s, filename=%s, description=%s",
GeobMetadata.TYPE, geobMetadata.mimeType, geobMetadata.filename,
geobMetadata.description));
} else {
Log.i(TAG, String.format("ID3 TimedMetadata %s", entry.getKey()));
}
}
}
// SurfaceHolder.Callback implementation
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (player != null) {
player.setSurface(holder.getSurface());
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
// Do nothing.
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (player != null) {
player.blockingClearSurface();
}
}
private void configureSubtitleView() {
CaptionStyleCompat style;
float fontScale;
if (Util.SDK_INT >= 19) {
style = getUserCaptionStyleV19();
fontScale = getUserCaptionFontScaleV19();
} else {
style = CaptionStyleCompat.DEFAULT;
fontScale = 1.0f;
}
subtitleLayout.setStyle(style);
subtitleLayout.setFractionalTextSize(SubtitleLayout.DEFAULT_TEXT_SIZE_FRACTION * fontScale);
}
@TargetApi(19)
private float getUserCaptionFontScaleV19() {
CaptioningManager captioningManager =
(CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);
return captioningManager.getFontScale();
}
@TargetApi(19)
private CaptionStyleCompat getUserCaptionStyleV19() {
CaptioningManager captioningManager =
(CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);
return CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle());
}
/**
* Makes a best guess to infer the type from a media {@link Uri} and an optional overriding file
* extension.
*
* @param uri The {@link Uri} of the media.
* @param fileExtension An overriding file extension.
* @return The inferred type.
*/
private static int inferContentType(Uri uri, String fileExtension) {
String lastPathSegment = !TextUtils.isEmpty(fileExtension) ? "." + fileExtension
: uri.getLastPathSegment();
return Util.inferContentType(lastPathSegment);
}
private static final class KeyCompatibleMediaController extends MediaController {
private MediaController.MediaPlayerControl playerControl;
public KeyCompatibleMediaController(Context context) {
super(context);
}
@Override
public void setMediaPlayer(MediaController.MediaPlayerControl playerControl) {
super.setMediaPlayer(playerControl);
this.playerControl = playerControl;
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
if (playerControl.canSeekForward() && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
playerControl.seekTo(playerControl.getCurrentPosition() + 15000); // milliseconds
BandwidthMeter bm=player.getBandwidthMeter();
Long l=bm.getBitrateEstimate();
storeBitRate=l;
bitrateTextView.setText(storeBitRate+" bits/sec");
show();
}
return true;
} else if (playerControl.canSeekBackward() && keyCode == KeyEvent.KEYCODE_MEDIA_REWIND) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
playerControl.seekTo(playerControl.getCurrentPosition() - 15000); // milliseconds
show();
}
return true;
}
return super.dispatchKeyEvent(event);
}
}
private class LoadImages extends AsyncTask<String, String, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
//pDialog.setVisibility(View.VISIBLE);
}
protected Void doInBackground(String... args) {
try {
vodImgThumb = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent());
chImgLogo = BitmapFactory.decodeStream((InputStream)new URL(args[1]).getContent());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(Void result) {
super.onPostExecute(result);
vodThumb.setImageBitmap(vodImgThumb);
chLogo.setImageBitmap(chImgLogo);
}
}
}
</code></pre>
<p>`</p>
| <android><exoplayer> | 2016-02-29 09:24:45 | HQ |
35,696,616 | Gridlayout Manager With Recycerview android | <p><a href="https://i.stack.imgur.com/pFihc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pFihc.png" alt="Real Image"></a></p>
<p>I want to create this type of layout using Recycerview.but i am gettting some issue with it.</p>
<pre><code> recyclerView.setLayoutManager(new GridLayoutManager(parentActivity, 2));
</code></pre>
<p>using above line ,i have display list in 2 column .but when height of some view is small then getting blank space..i want to remove that blank space. </p>
<p>issue screenshot:</p>
<p><a href="https://i.stack.imgur.com/zkBva.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zkBva.png" alt="Current Screen"></a></p>
<p>Please give solution to remove that space.</p>
| <java><android><android-recyclerview><gridlayoutmanager> | 2016-02-29 10:00:55 | LQ_CLOSE |
35,696,809 | c++ create an object with constructor or wothout? | <p>I am new to c++.
I have seen some example of classes.
I have difficulty to understand when I have to call the costuctor (whith ()) when I create an object and when I don't have to create it with the consructor.</p>
| <c++> | 2016-02-29 10:10:13 | LQ_CLOSE |
35,697,087 | Splitting datime in PHP | I am doing project to school and need something like this in PHP.
I have 2 datetime value:
$begin = new DateTime( "2015-07-03 12:00:00" );
$end = new DateTime( "2015-07-04 14:00:00" );
and I need to split it to this result:
val11 = 2015-07-03 12:00:00;
val12 = 2015-07-03 23:59:59;
val21 = 2015-07-04 00:00:00;
val22 = 2015-07-04 14:00:00;
Can anybody help me, please?
| <php><datetime> | 2016-02-29 10:22:33 | LQ_EDIT |
35,697,149 | One-time login link in asp.net identity | <p>Some mobile apps like slack have popularized the idea of allowing your users to get a one-time use login link (Slack calls this the magic login link). </p>
<p>The idea is that you enter your email and instead of having to enter your password of a mobile, you request a magic login link that can be used once to log you in by opening that link on your phone.</p>
<p>I'm implementing this in asp.net identity 2.1, and I'm unsure how to ensure that the link that's generated can only be used once.</p>
<p>I generate a token like this:</p>
<pre><code>var token = await _userManager.GenerateUserTokenAsync("MyLoginLink",user.Id);
</code></pre>
<p>This token is added to a URL for the user. The action method that the link redirects you to checks that the link is valid for that user, and then logs you in:</p>
<pre><code>public async Task<ActionResult> LoginLink(string email, string token)
{
var user = await _userManager.FindByNameAsync(email);
// some checks ommited
//check for an expired token:
var result = await _userManager.VerifyUserTokenAsync(user.Id, "MyLoginLink", token);
if (!result)
{
// Failed
return RedirectToAction("Login");
}
await _userManager.UpdateSecurityStampAsync(user.Id);
await SignInAsync(user, true);
</code></pre>
<p>Now - if I update the security stamp with <code>user.UpdateSecurityStamp</code>, that re-generates the security stamp, which will invalidate this token, and ensure it can't be used again. The problem with that is that it also invalidates any existing logins, so if the user is also logged in on a desktop, they'll be forced to logoff and on again.</p>
<p>Is there a relatively simple way to create one-time use token like this in asp.net identity, that doesn't invalidate all existing logins?</p>
| <asp.net-mvc><authentication><asp.net-identity> | 2016-02-29 10:25:39 | HQ |
35,697,325 | How to Descrypt Password in SQL Server 2012 R2 using DES? | I want to decrypt password in sql server 2012 R2 using DES to send that password in the mail using SQL JOB.
Can Anyone help Me ?
Thanks in advance. | <sql-server> | 2016-02-29 10:33:12 | LQ_EDIT |
35,698,004 | difference between 'global varName' and 'self.varName' in python | <p>what is the use of writing 'global varName' in the body of constructor ?
I mean we can achive the same goal by writting 'self.varName' ? For Example</p>
<pre><code>class Mine_Global:
def __init__(self):
global varName
varName = 3
self.newInsVar = 7
if __name__ == "__main__":
global varName
obj1 = Mine_Global()
print varName, obj1.newInsVar;
varName = varName + 2
print varName, obj1.newInsVar;
obj2 = Mine_Global()
print varName, obj2.newInsVar
</code></pre>
| <python><class><global-variables> | 2016-02-29 11:08:04 | LQ_CLOSE |
35,698,741 | I want to save a MP4 Video from array list of frames | <p>i want to extract frames from a video and add effect in this frames then i want to save this frames as mp4 Video
<a href="https://github.com/MuhammadNasser/VideoEffects/blob/master/app/src/main/java/com/example/mondy/videoeffects/MainActivity.java" rel="nofollow">here is</a> what i use in my code and it didn't work </p>
<p>ineed help please </p>
| <java><android><video><mp4><frames> | 2016-02-29 11:48:10 | LQ_CLOSE |
35,699,458 | SSRS Lookup Based on Multiple Conditions | <p>I have a dataset (Volume) looks like this:</p>
<p><a href="https://i.stack.imgur.com/HhzIc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HhzIc.png" alt="enter image description here"></a></p>
<p>In my report, what I want to get is this: </p>
<p><a href="https://i.stack.imgur.com/nd6HP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nd6HP.png" alt="enter image description here"></a> </p>
<p>The Lookup expression: =Lookup (Fields!Id.Value, Fields!Id.Value, Fields!Volume.Value,"Volume") can only lookup on ID. Is there any way I can do lookup on ID first, and then lookup on Sub_Group to get the correct Volume? Thank you.</p>
| <reporting-services><ssrs-2012> | 2016-02-29 12:22:05 | HQ |
35,699,534 | Enum data type memory allocation | <p>How memory allocated for"enum" data type, i found that total size of enum data type is 4 bytes(linux) but some people answers is there is no memory allocation, its like 'macros' with a type(int) so please explain how enum all members function stored while accessing and what is data will be there in that 4 bytes.</p>
<p>Thanks</p>
| <c> | 2016-02-29 12:25:40 | LQ_CLOSE |
35,699,735 | Missing a using directive or an assembly reference for .ToList() | <p>I have this code in the class constructor.</p>
<pre><code>this._images = images.Split('#').ToList();
</code></pre>
<p>It has always worked, but now it gives this error:</p>
<blockquote>
<p>Error CS1061 'string[]' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'string[]' could be found (are you missing a using directive or an assembly reference?).</p>
</blockquote>
<p>What can I do to make it work?</p>
| <c#><asp.net><visual-studio-2015> | 2016-02-29 12:35:43 | LQ_CLOSE |
35,700,038 | Create an array that prompts the user to enter five letters and sort alphabetically | <p>I am a first year student at Rhodes university and as part of my homework i have been tasked to Create a program that creates an array named sortAlpha. It should prompt a user to enter any five letters of the alphabets and arrange them in alphabetical order. I can't make it work, after so many attempts. </p>
| <c#> | 2016-02-29 12:50:49 | LQ_CLOSE |
35,700,063 | Pip install - Python 2.7 - Windows 7 | <p>I download the get-pip.py from <a href="https://pip.pypa.io/en/stable/installing/" rel="noreferrer">https://pip.pypa.io/en/stable/installing/</a> . Then i changed path in: system-variable environment into : C:\Python27\ArcGIS10.3\Lib\site-packages
after that i tried to run in from the cmd and this is the result:</p>
<p><a href="https://i.stack.imgur.com/emDPN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/emDPN.jpg" alt="enter image description here"></a> </p>
| <python-2.7><pip> | 2016-02-29 12:51:51 | HQ |
35,700,750 | Cloundant : Error with running weatherreport to check cluster health | We have three node cluster setup and facing issue to run weather report command.
By looking at error, it is clear that machine from where weatherreport utility is running not able to connect to other two machines. I have checked all machines and they are accessible using fqdn. But from message it looks like it is using shortname while connecting to peer machine. So how to check from where it is taking peer machine names? So I can give a try to change them to full machine name and that might work for me. if there is any other solution then let us know.
Error is coming as
['cloudant_diag17506@machine2031.domain.com'] [crit] Could not run check weatherreport_check_safe_to_rebuild on cluster node 'cloudant@machine2031'
['cloudant_diag17506@machine2031.domain.com'] [crit] Could not run check weatherreport_check_safe_to_rebuild on cluster node 'cloudant@machine2032'
['cloudant_diag17506@machine2031.domain.com'] [crit] Could not run check weatherreport_check_safe_to_rebuild on cluster node 'cloudant@machine2033'
['cloudant@machine2032.domain.com'] [crit] Rebuilding this node will leave the following shard with NO live copies: default/t_alpha e0000000-ffffffff, default/t_alpha a0000000-bfffffff, default/t_alpha 60000000-7fffffff, default/t_alpha 20000000-3fffffff, default/metrics_app e0000000-ffffffff, default/metrics_app a0000000-bfffffff, default/metrics_app 60000000-7fffffff, default/metrics_app 20000000-3fffffff
| <cluster-computing><cloudant> | 2016-02-29 13:26:05 | LQ_EDIT |
35,701,039 | I am trying to install C compiler in RHEL6 without internet | <p>I have been trying to install basic softwares needed for making my linux machine into a development env. I got a machine with RHEL6, however it is not connected to the internet. I am able to connect to the lan and ssh to other machines. I tried to install using yum but failed with the following error.</p>
<pre><code>[root@******* pcre-8.38]#yum install gcc-c++
Loaded plugins: aliases, changelog, downloadonly, kabi, presto, product-id, refresh-packagekit, security, subscription-
: manager, tmprepo, verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
https://www.softwarecollections.org/repos/rhscl/devtoolset-3/epel-6-x86_64/repodata/repomd.xml: [Errno 12] Timeout on https://www.softwarecollections.org/repos/rhscl/devtoolset-3/epel-6-x86_64/repodata/repomd.xml: (28, 'connect() timed out!')
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: rhscl-devtoolset-3-epel-6-x86_64. Please verify its path and try again.
</code></pre>
<p>Prior to this i installed an ngnix web server and tried to do a <em>make</em> but that failed with:</p>
<pre><code>...
checking windows.h presence... no
checking for windows.h... no
configure: error: You need a C++ compiler for C++ support.
make[1]: *** [/home/gunjaj/software/pcre-8.38/Makefile] Error 1
make[1]: Leaving directory `/home/gunjaj/software/nginx-1.8.1'
make: *** [build] Error 2
</code></pre>
<p>Any help is appreciated.</p>
<p>PS: This question is similar to another question <a href="https://stackoverflow.com/questions/13853507/how-to-install-c-compiler-for-gcc-without-internet-connection-rhel6">How to install C compiler for GCC without Internet connection? (RHEL6)</a></p>
<p>but i have absolutely no way of getting internet right now.</p>
| <c++><c><linux><nginx><rhel6> | 2016-02-29 13:39:20 | LQ_CLOSE |
35,701,059 | Get only the latest builds of a module in the same table using mysql and node.js | <p>Let's say I have this kind of table:</p>
<p><a href="https://i.stack.imgur.com/ubscr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ubscr.png" alt="enter image description here"></a></p>
<p>How would I only get these values:</p>
<pre><code>ID | NAME | BUILD
2 | Module1 | 2
4 | Module2 | 2
</code></pre>
| <javascript><mysql><sql><node.js> | 2016-02-29 13:40:17 | LQ_CLOSE |
35,701,179 | Init Array of vector.size() in c++ | <p>I try to compile some c++-Code from the internet
(<a href="http://arma.sourceforge.net/shadows/" rel="nofollow">http://arma.sourceforge.net/shadows/</a>).</p>
<p>When compiling the code I get an error for initializing arrays.
Example (from the code-> GaussianMixtureModel.cpp Line:122):</p>
<pre><code>void function()
{
int k = Vector.size();
uchar* Ptrs[k];
// Does somthing with the Ptrs
}
</code></pre>
<p>I also tried to edit it to the following:</p>
<pre><code>const int k = Vector.size();
</code></pre>
<p>But it didn't work. I would appreciate any help!</p>
<p>I'm using Visual Studio 2012.</p>
<p>Thanks for your answers!</p>
| <c++><arrays><stdvector> | 2016-02-29 13:45:27 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.