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 |
|---|---|---|---|---|---|
34,881,775 | Automatic cookie handling with OkHttp 3 | <p>I am using okhttp 3.0.1. </p>
<p>Every where I am getting example for cookie handling that is with okhttp2 </p>
<pre><code>OkHttpClient client = new OkHttpClient();
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
client.setCookieHandler(cookieManager);
</code></pre>
<p>Can please some one guide me how to use in version 3. setCookieHandler method is not present in the version 3.</p>
| <cookies><okhttp3> | 2016-01-19 16:19:45 | HQ |
34,882,125 | Getting 403 (Forbidden) when loading AWS CloudFront file | <p>I'm working on a video app and storing the files on AWS S3, using the default URL like <code>https://***.amazonaws.com/***</code> works fine but I have decided to use CloudFront which is faster for content delivery.</p>
<p>Using CF, I keep getting <code>403 (Forbidden)</code> using this URL <code>https://***.cloudfront.net/***</code>. Did I miss anything?</p>
<p>Everything works fine until I decide to load the contents from CloudFront which points to my bucket.</p>
<p>Any solution please?</p>
| <amazon-web-services><amazon-s3><amazon-cloudfront> | 2016-01-19 16:36:04 | HQ |
34,883,026 | Django migrations error KeyError: ('list', u'user') | <p>I am trying to run</p>
<pre><code>python manage.py migrate
</code></pre>
<p>or</p>
<pre><code>python manage.py makemigrations
</code></pre>
<p>I got this error:</p>
<pre><code>Running migrations:
No migrations to apply.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 183, in handle
executor.loader.project_state(),
File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 338, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps))
File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/db/migrations/graph.py", line 280, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/db/migrations/migration.py", line 88, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 547, in state_forwards
model_state = state.models[app_label, self.name_lower]
KeyError: ('list', u'user')
</code></pre>
<p>It happen after I pulled another version of my app from the git.</p>
<p>I don't have this error with the same code on the another machine.
I've tried to use <code>--fake</code> with <code>zero</code> or to <code>squashmigrations</code> to previous but this also doesn't help.</p>
<p>Cannot get how to solve it.</p>
| <python><django><migrate><makemigrations> | 2016-01-19 17:17:17 | HQ |
34,884,140 | find and replace all periods that are not followed by punctuation or a space | <p>I'm trying to format user input using PHP, and am frequently running into issues where there are not spaces between sentences (i.e. after a closing period). This creates problems, as this user input gets professionally printed. If we miss these during a manual QC process, it costs the company money, as it has to be fixed and reprinted.</p>
<p>I need to develop a way to search for all periods in a given text string, determine if it's immediately followed by a letter or number, and if so, insert a space after the period. If the period is followed by other punctuation (i.e. a quotation mark, another period as in an ellipsis) or is followed by a space, I want to leave it alone.</p>
| <php><regex> | 2016-01-19 18:17:14 | LQ_CLOSE |
34,885,226 | VB.NET - Query will not update SQL Server | In the below code, my second query will not insert into the SQL database, but the first one will update. I can copy the query (from the msgbox i added for testing) and paste it in SQL Server Management Studio, and it will execute fine. I also do not get any error messages back from SQL, though i'm not sure if that code is correct (it was copied + pasted from another source). Also, can i simplify the code to pass both queries at the same time?
Dim Conn As New System.Data.SqlClient.SqlConnection 'sql server datastream connection
Dim Cmd As New System.Data.SqlClient.SqlCommand 'sql command vars
Dim SqlQuery As String 'string var used to hold various SQL queries
Dim data As System.Data.SqlClient.SqlDataReader 'datareader object variable
Dim MVDataset As New DataSet
Dim MVDatatable As DataTable
Dim MVDatarow As DataRow
Private Sub MVUpdateButton_Click(sender As Object, e As EventArgs) Handles MVUpdateButton.Click
vbyn = MsgBox("Are you sure you want to update Tally Sheet Master Variables?" & vbCrLf & vbCrLf & "Changes to these variables will change the functionality of the Tally Sheet!", vbYesNo, )
Try
Select Case vbyn
Case vbNo
GoTo MVTableUpdateBypass
Case vbYes
'get new data from textboxes
Vers = TextBox1.Text
If TextBox2.Text = True Then
Testing = 1
Else
Testing = 0
End If
FlatFeeCharge = TextBox3.Text
PrepricingCharge = TextBox4.Text
SendMailAcct = TextBox5.Text
SendMailPW = TextBox6.Text
TestingEmail = TextBox7.Text
PrePricingEmail = TextBox8.Text
ImperataEmail = TextBox9.Text
'update existing active row to mark inactive
SqlQuery = "Update MasterVars set Active = 0 where PKEY = " & PKEY & ";"
MsgBox(SqlQuery)
If Conn.State = ConnectionState.Closed Then
Conn.ConnectionString = "Data Source=SQL01;Initial Catalog=TallySheet;Integrated Security=SSPI;"
End If
Conn.Open()
Dim MVDataAdapter As New SqlDataAdapter(SqlQuery, Conn)
Dim MVUpdateCommand As SqlCommand
MVUpdateCommand = New SqlCommand(SqlQuery)
MVDataAdapter.UpdateCommand = MVUpdateCommand
'insert new active row
SqlQuery = "Insert into MasterVars (Vers, Testing, FlatFeeCharge, PrePricingCharge, SendMailAcct, SendMailPW, TestingEmail, PrePricingEmail, ImperataEmail, DTS, UserName, Active) Values (" & "'" & Vers & "', " & Testing & ", '" & FlatFeeCharge & "'" & ", '" & PrepricingCharge & "'" & ", '" & SendMailAcct & "'" & ", '" & SendMailPW & "'" & ", '" & TestingEmail & "'" & ", '" & PrePricingEmail & "'" & ", '" & ImperataEmail & "'" & ", '" & Date.Now & "'," & "'QGDOMAIN\" & Environment.UserName & "'," & 1 & ");"
MsgBox(SqlQuery)
Dim MVInsertCommand As SqlCommand
MVInsertCommand = New SqlCommand(SqlQuery)
MVDataAdapter.InsertCommand = MVInsertCommand
MVDataAdapter.Fill(MVDataset, "MasterVars")
End Select
Catch ex As SqlException
Dim i As Integer
Dim errormessages As String
errormessages = ""
For i = 0 To ex.Errors.Count - 1
errormessages = errormessages & " " & ("Index #" & i.ToString() & ControlChars.NewLine _
& "Message: " & ex.Errors(i).Message & ControlChars.NewLine _
& "LineNumber: " & ex.Errors(i).LineNumber & ControlChars.NewLine _
& "Source: " & ex.Errors(i).Source & ControlChars.NewLine _
& "Procedure: " & ex.Errors(i).Procedure & ControlChars.NewLine)
Next i
Console.WriteLine(errorMessages.ToString())
End Try
'reload form with updated variables
Conn.Close()
Conn.Dispose()
MVTableUpdateBypass:
End Sub | <sql-server><vb.net><winforms> | 2016-01-19 19:19:59 | LQ_EDIT |
34,885,380 | What happen to SketchFlow and what we should use instead? | <p>What is the new <strong>Microsoft way</strong> of UI prototyping since VS2015 doesn't support SketchFlow projects. <em>(I'm having hard time to accept that they removed such a useful tool without providing alternative)</em></p>
<blockquote>
<p>I know we still have <em>PowerPoint StoryBoards</em> for basic UI mock-ups but I would like to use interactive prototypes through Visual Studio. <em><strong>Therefore please do not suggest alternative products</strong></em></p>
</blockquote>
| <visual-studio><sketchflow> | 2016-01-19 19:29:03 | HQ |
34,885,551 | All possible combinations of elements from different bins (one element from every bin) | <p>I have a list, where each element is a set of numbers. Lengths of all sets are different:</p>
<pre><code> a <- list(1,c(2,3),c(4,5,6))
#> a
#[[1]]
#[1] 1
#[[2]]
#[1] 2 3
#[[3]]
#[1] 4 5 6
</code></pre>
<p>I'd like to get all possible combinations of one element from each set. In this example it should be:</p>
<p>1 2 4, 1 2 5, 1 2 6, 1 3 4, 1 3 5, 1 3 6</p>
<p>I feel that some combination of *apply-functions here would be useful, but can't figure out how to do that.</p>
| <r><combinatorics><lapply><sapply> | 2016-01-19 19:40:41 | LQ_CLOSE |
34,886,172 | OKhttp PUT example | <p>My requirement is to use <code>PUT</code>, send a header and a body to server which will update something in the database.</p>
<p>I just read <a href="http://square.github.io/okhttp/">okHttp documentation</a> and I was trying to use their <code>POST</code> example but it doesn't work for my use case <strong>(I think it might be because the server requires me to use <code>PUT</code> instead of <code>POST</code>)</strong>.</p>
<p>This is my method with <code>POST</code>:</p>
<pre><code> public void postRequestWithHeaderAndBody(String url, String header, String jsonBody) {
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON, jsonBody);
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", header)
.build();
makeCall(client, request);
}
</code></pre>
<p>I have tried to search for okHttp example using <code>PUT</code>with no success, if I need to use <code>PUT</code>method is there anyway to use okHttp?</p>
<p>I'm using okhttp:2.4.0 (just in case), thanks on any help!</p>
| <android><retrofit><okhttp><android-networking><androidhttpclient> | 2016-01-19 20:18:13 | HQ |
34,886,407 | SQLAlchemy eager loading multiple relationships | <p>SQLAlchemy supports eager load for relationship, it is basically a <code>JOIN</code> statement. However, if a model has two or more relationships, it could be a very huge join. For example,</p>
<pre><code>class Product(Base):
__tablename__ = 'product'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(255), nullable=False)
orders = relationship('Order', backref='product', cascade='all')
tags = relationship('Tag', secondary=product_tag_map)
class Order(Base):
__tablename__ = 'order'
id = Column(Integer, primary_key=True, autoincrement=True)
date = Column(TIMESTAMP, default=datetime.now())
class Tag(Base):
__tablename__ = 'tag'
id = Column(Integer, primary_key=True, autoincrement=True)
tag_type = Column(String(255), nullable=False)
tag_value = Column(String(255), nullable=False)
q = session.query(Product).join(User.addresses)\
.options(joinedload(Product.orders))\
.options(joinedload(Product.tags)).all()
</code></pre>
<p>The performance of this query is really bad, because the <code>JOIN</code> of <code>Order</code> and <code>Tag</code> will generate a huge table. But the <code>Order</code> and <code>Tag</code> has no relationship in here, so they should not be <code>JOIN</code>. It should be two separated queries. And because the session has some level of caching, so I changed my query to this.</p>
<pre><code>session.query(Product).join(Product.order) \
.options(joinedload(Product.tags)).all()
q = session.query(Product).join(User.addresses) \
.options(joinedload(Product.cases)).all()
</code></pre>
<p>This time the performance is way much better. However, I am not convinced that this is the correct to do it. I am not sure if the caches of tags will be expired when the session ends.</p>
<p>Please let me know the appropriate way for this kind of query. Thank you!</p>
| <python><mysql><sql><sqlalchemy> | 2016-01-19 20:32:05 | HQ |
34,886,461 | Why is it that when i run my code it says "AttributeError: Enemy instance has no attribute 'enemy'"? | <p>my code can both be found and ran here : <a href="https://repl.it/Bda9/10" rel="nofollow">https://repl.it/Bda9/10</a></p>
<p>right now i'm focusing on the 'explore' then 'attack' pathways, but for some reason this code will not run a single attack. I need to get this at least working by tonight. We just started OOP and... well... this is frustrating me.</p>
<p>what is causing that error?
why does the code not recognize enemy (I think that's what the error means)?</p>
| <python> | 2016-01-19 20:35:13 | LQ_CLOSE |
34,886,853 | Unfortunately, APP has stopped error. Are there any view limitations for an activity? | <p>I am trying to develop an app for Android with Android studio.
I have a login page and trying to open an another activity named main with button from login page. I have lots of rows in two table layout. You can find codes there.
When i clicked imagebutton in login, sometimes i get Unfortunately, APP has stopped error. Sometimes dont get <strong>with same codes.</strong></p>
<p>Are there any limitations for number of widgets for an activity page?
I am getting this error on emulator.
Here are the codes.
Thank for your replies.</p>
<p><strong>login.java</strong></p>
<pre><code>protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Button mainBtn = (Button) findViewById(R.id.bt_enter);
mainBtn.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent(login.this, main.class);
startActivity(intent);
}
});
}
</code></pre>
<p><strong>content_main</strong></p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.dasyapi.erp.dait.main"
tools:showIn="@layout/activity_main"
android:background="@drawable/gravis">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/iv_logo"
android:src="@drawable/ust_logo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:baselineAlignBottom="false"
android:adjustViewBounds="true" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_logo"
android:layout_alignLeft="@+id/iv_logo"
android:layout_alignRight="@+id/iv_logo"
android:id="@+id/ly_content"
android:scrollbars="vertical"
android:weightSum="1"
android:paddingTop="20dp"
android:layout_alignEnd="@+id/iv_logo"
android:layout_alignStart="@+id/iv_logo">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:id="@+id/tl_content">
<TableRow
android:id="@+id/tr_1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:measureWithLargestChild="false"
android:gravity="center_horizontal"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ly_ajanda"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginRight="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_ajanda"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/ajanda"
android:clickable="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ly_kasa"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginLeft="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_kasa"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/kasa"
android:clickable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tr_2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:measureWithLargestChild="false"
android:gravity="center_horizontal"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_siparis"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginRight="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_siparis"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/siparis"
android:clickable="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_puantaj"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginLeft="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_puantaj"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/puantaj"
android:clickable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tr_3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:measureWithLargestChild="false"
android:gravity="center_horizontal"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_gelirler"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginRight="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_gelirler"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/gelirler"
android:clickable="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_giderler"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginLeft="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_giderler"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/giderler"
android:clickable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tr_4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:measureWithLargestChild="false"
android:gravity="center_horizontal"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_stoklar"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginRight="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_stoklar"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/stoklar"
android:clickable="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_kritik"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginLeft="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_kritik"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/kritik"
android:clickable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tr_5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:measureWithLargestChild="false"
android:gravity="center_horizontal"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_sikayet"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginRight="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_sikayet"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/sikayet"
android:clickable="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_tutanak"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginLeft="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_tutanak"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/tutanak"
android:clickable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tr_6"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:measureWithLargestChild="false"
android:gravity="center_horizontal"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_is_kazasi"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginRight="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_is_kazasi"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/is_kazasi"
android:clickable="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ly_kamera"
android:weightSum="1"
android:background="@color/dBlueDark"
android:layout_marginLeft="7dp">
<ImageButton
android:layout_width="146dp"
android:layout_height="65dp"
android:id="@+id/ibt_kamera"
android:soundEffectsEnabled="false"
android:adjustViewBounds="true"
android:keepScreenOn="false"
android:background="@drawable/kamera"
android:clickable="true" />
</LinearLayout>
</TableRow>
</TableLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="false"
android:id="@+id/fl_bottom">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:id="@+id/tl_bottom">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal|bottom"
android:id="@+id/tr_bottom">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:id="@+id/ll_personel">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="65dp"
android:id="@+id/ibt_personel"
android:background="@color/dOrange"
android:src="@drawable/personel"
android:adjustViewBounds="true"
android:clickable="true"
android:scaleType="fitXY" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:id="@+id/ll_taseron">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="65dp"
android:id="@+id/ibt_taseron"
android:background="@color/dOrange"
android:src="@drawable/taseron"
android:adjustViewBounds="true"
android:clickable="true"
android:scaleType="fitXY" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:id="@+id/ll_musteri">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="65dp"
android:id="@+id/ibt_musteri"
android:background="@color/dOrange"
android:src="@drawable/musteri"
android:adjustViewBounds="true"
android:clickable="true"
android:scaleType="fitXY" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:id="@+id/ll_threedots">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="65dp"
android:id="@+id/ibt_threedots"
android:background="@color/dOrange"
android:src="@drawable/diger"
android:adjustViewBounds="true"
android:clickable="true"
android:scaleType="fitXY" />
</LinearLayout>
</TableRow>
</TableLayout>
</FrameLayout>
</code></pre>
<p></p>
| <android><android-studio> | 2016-01-19 21:01:11 | LQ_CLOSE |
34,886,921 | What is the ideal target time for rendering a page of a PHP forum? | <p>I am creating this question because I am currently working on my free time (for fun) on a PHP forum, using MySQL for my database. And for a little while now (most of the essential features being implemented), I have been questioning the performance of my scripts.</p>
<p>I already did some profiling of my scripts and improved some of them, but I eventually always end up with the same question: <strong>what is a good target time to render the typical page of a forum ?</strong> In my case, such a page consists in displaying 20 to 50 messages of a given topic (users can decide how many messages per page they want to display) with roughly half of them using features like uploads displayed as a gallery below a message (which involves string parsing and checking the existence of a file with file_exists()).</p>
<p>After reading some topics on performance with PHP on this website, I learned, among others, that Youtube had a target render time of 100ms (= 0,1s). I managed to have load times below this target time for my heaviest pages, but only after a while due to PHP caching with file_exists() (I run my project locally, with a WAMP Server). But I doubt I can really compare my project to a website as heavy in features as Youtube. So,</p>
<ul>
<li><p>When rendering (in HTML/CSS) my "typical" page, what time should I target ? Is it acceptable to stick to the 100ms limit, or should I go way below (for example, below 50ms) ? Are there any known statistics about current state-of-the-art forums I could use for reference ?</p></li>
<li><p>Since I am currently working with WAMP Server, does it introduce bias while profiling my scripts ? Is it equivalent to your average PHP-enabled HTTP server, or does it run slower/faster on average ?</p></li>
</ul>
<p>This question interests me a lot, as some features I designed add some overhead to my scripts (which scales with the amount of messages being displayed). For example, my format code to embed videos is not parsed at the creation of a message, but at its display, as I want to be able to easily change the embed code as well as allowing users to choose how videos are embedded (directly, or with small/HQ thumbnail which is replaced with the embed code upon clicking) for their comfort. Of course, I could as well parse the code at the submission of a new message to reduce the overhead, but I want to be sure this is necessary.</p>
<p>I hope this is not too vague... thank you in advance for your answers.</p>
| <php><mysql><performance><wampserver><forum> | 2016-01-19 21:06:02 | LQ_CLOSE |
34,887,347 | How to detect if webpack-dev-server is running? | <p>How can I determine if <code>webpack.config.js</code> was loaded via <code>webpack</code> vs <code>webpack-dev-server</code>?</p>
| <webpack><webpack-dev-server> | 2016-01-19 21:33:55 | HQ |
34,887,361 | PHP SHA1 function in Java | <p>I was wondering if there is any way to get the PHP SHA1 with raw returning in Java. Just like this in PHP: sha1("abc123", true) Anyone got an idea? It would be appreciated very much.</p>
| <java><php><android><hash> | 2016-01-19 21:34:46 | LQ_CLOSE |
34,887,813 | assertNull J Unit, fails with null pointer (JAVA) | For my project one of the returns has to be null. When testing using assertNull(Null Object here) it fails with a null pointer exception.
Can someone please tell my why?? I thought assertNull is suppose to test for null.
Heres part of my code.
public static UVI calculateUVI(double[] radiation)
{
double calculation = 0.0;
double[] copyRad = new double[radiation.length];
for (int i = 0; i < radiation.length; i++)
{
copyRad[i] = radiation[i];
if (radiation[i] > RADIATION_MAXIMUM)
copyRad[i] = RADIATION_MAXIMUM;
if (radiation[i] < RADIATION_MINIMUM)
copyRad[i] = 0.0;
calculation += (copyRad[i] * MD_WEIGHTS[i]);
}
if (radiation.length != MD_WEIGHTS.length || radiation == null)
{
UVI nulled = null;
return nulled;
}
calculation /= B;
UVI result = new UVI(calculation, true);
return result;
}
My test case is:
double[] test1 = {4., 26., 30., 17., 2.};
double[] test2 = {0., 0., 0., 0., 0.};
double[] test3 = {4., 26., 30., 100., 2.};
double[] test4 = {4., 26., 30., 200., 2.};
double[] test5 = {3.4, 0., 17., 17., 2.};
double[] test6 = {3.4, -10., 17., 17., 2.};
double[] test7 = {1.0};
double[] test8 = {};
double[] test9 = null;
UVI testOne = UVICalculator.calculateUVI(test1);
UVI testTwo = UVICalculator.calculateUVI(test2);
UVI testThree = UVICalculator.calculateUVI(test3);
UVI testFour = UVICalculator.calculateUVI(test4);
UVI testFive = UVICalculator.calculateUVI(test5);
UVI testSix = UVICalculator.calculateUVI(test6);
UVI testSeven = UVICalculator.calculateUVI(test7);
UVI testEight = UVICalculator.calculateUVI(test8);
UVI testNine= UVICalculator.calculateUVI(test9);
assertTrue(8.8956 == testOne.getValue());
assertTrue(0 == testTwo.getValue());
assertTrue(8.9952 == testThree.getValue());
assertTrue(8.9952 == testFour.getValue());
assertTrue(4.027200000000001 == testFive.getValue());
assertTrue(4.027200000000001 == testSix.getValue());
assertNull(testSeven);
assertNull(testEight);
assertNull(testNine);
| <java><junit><null> | 2016-01-19 22:03:07 | LQ_EDIT |
34,887,938 | Convert CURRENT_TIMESTAMP to only Y-m-d | <p>I have a column named "timestamp" in my DB with datatype <code>timestamp</code> and standard <code>CURRENT_TIMESTAMP</code>.</p>
<p>When I echo it (<code>echo $row['timestamp'];</code>) i get this:</p>
<pre><code>2016-01-18 21:06:37
2016-01-19 12:32:16
2016-01-19 20:52:41
</code></pre>
<p>But I want it to turn out like this:</p>
<pre><code>2016-01-18
2016-01-19
2016-01-19
</code></pre>
<p>How should I do that? <code>Strftime</code> or something?</p>
| <php><phpmyadmin> | 2016-01-19 22:12:17 | LQ_CLOSE |
34,888,012 | return statement no result in java | <p>I have declared a method in a class named Teacher used return statement,</p>
<pre><code> public String info(){
return "Name is " +name +"Location is "+location;
</code></pre>
<p>Then I built the constructor then I called it from main class </p>
<pre><code>Teacher t1= new Teacher("Tim","Guildford","Reader");
t1.info();
</code></pre>
<p>However both in cmd windows and intellij , there is no result.</p>
<p>But if I change the method type to void and use system.out.println, every thing is fine.</p>
<p>What is the problem here?</p>
| <java><return> | 2016-01-19 22:17:09 | LQ_CLOSE |
34,888,205 | Insert padding so that points do not overlap with y or x-axis | <p>I have the created this plot in D3: <a href="http://bl.ocks.org/cddesja/aee65f660c24cb2144fd" rel="noreferrer">http://bl.ocks.org/cddesja/aee65f660c24cb2144fd</a></p>
<p>There are two things I would like to change.</p>
<p>1) I would like to make it so that none of my points overlap with the y or x-axis. I thought I could use <code>transform()</code> to create a little bit of a buffer but that creates a gap between the x and y axis lines, something I do not want. How should I do this correctly? </p>
<p>2) I would like to get rid of the tick marks at the intersection of the x and y lines. I am hoping that once I move the tick marks (and subsequently the pts and lines) that these tick marks automagically disappear. I don't know if that's really true or not.</p>
<p>Thanks in advance.
Chris</p>
| <d3.js> | 2016-01-19 22:30:30 | HQ |
34,888,206 | how to proxy to backend server on certain path? | <p>Here is the routes config:</p>
<pre><code><Route path='/' component={CoreLayout}>
<IndexRoute component={HomeView}/>
<Route path='/404' component={NotFoundView}/>
<Redirect from='*' to='/404'/>
</Route>
</code></pre>
<p>Here is the proxy config for webpack-dev-server:</p>
<pre><code>proxy: {
'/service': 'http://localhost:8080'
}
</code></pre>
<p>The express server listens on 3000 port.</p>
<p>I hope that all the requests send to <a href="http://localhost:3000/service" rel="noreferrer">http://localhost:3000/service</a> would be transferred to <a href="http://localhost:8080" rel="noreferrer">http://localhost:8080</a>, but it seems that react-router handles all the requests and the proxy does not work.</p>
<p>Any body knows how to fix this? Thank you in advance</p>
| <react-router><webpack-dev-server> | 2016-01-19 22:30:41 | HQ |
34,888,420 | Crashlytics: How to see user name/email/id in crash details? | <p>I am using Crashlytics for collecting crashes from iOS app.
To make crash more specific I want to see user name/email/id in crash details.<br>
For this goal I use such code:</p>
<pre><code>[Crashlytics setUserIdentifier:@"userID"];
[Crashlytics setUserEmail:@"user@email.com"];
[Crashlytics setUserName:@"userName"];
</code></pre>
<p>When crash happens I cannot find a way to see this information in crash details.<br>
I see such screen:<br>
<a href="https://i.stack.imgur.com/rSajR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rSajR.png" alt="enter image description here"></a></p>
<p>Question: How can I see user name/email/id in crash details?</p>
| <ios><crashlytics> | 2016-01-19 22:46:56 | HQ |
34,888,636 | Change Background color of MenuItem on MouseOver | <p>I want to change the default background color of a MenuItem at mouseOver. Here is my xaml code:</p>
<p><a href="https://i.stack.imgur.com/S5SwM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S5SwM.png" alt="enter image description here"></a></p>
<p>Style :</p>
<pre><code><Style TargetType="{x:Type MenuItem}" x:Key="MenuItemStyle" >
<Setter Property="BorderBrush" Value="White"></Setter>
<Setter Property="BorderThickness" Value="0,0,0,5"></Setter>
<Setter Property="Background" Value="#0264AD"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="FontSize" Value="12"></Setter>
<Setter Property="FontFamily" Value="Arial"></Setter>
<Setter Property="FontWeight" Value="Bold"></Setter>
<Setter Property="Margin" Value="-5,0,0,0"></Setter>
<Setter Property="Padding" Value="0,12,0,12"></Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="LightGray"></Setter>
<Setter Property="Background" Value="#0264AD"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="#0264AD"></Setter>
<Setter Property="Background" Value="Yellow"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</code></pre>
<p>Control : </p>
<pre><code><ContextMenu x:Name="settingContextMenu" Width="220" >
<MenuItem Style="{StaticResource MenuItemStyle}" Name="CustomizeLocationNames" Click="CustomizeLocationNames_Click" >
<MenuItem.Header>
<TextBlock Text="Customize Location Names" VerticalAlignment="Center"></TextBlock>
</MenuItem.Header>
</MenuItem>
<MenuItem Style="{StaticResource MenuItemStyle}" Name="ZoomRoute" Click="ZoomRoute_Click">
<MenuItem.Header>
<TextBlock Text="Zoom Route" VerticalAlignment="Center"></TextBlock>
</MenuItem.Header>
</MenuItem>
<MenuItem Style="{StaticResource MenuItemStyle}" Name="PrintRoute" Click="PrintRoute_Click">
<MenuItem.Header>
<TextBlock Text="Print Route" VerticalAlignment="Center" >/TextBlock>
</MenuItem.Header>
</MenuItem>
</ContextMenu>
</code></pre>
<p>So I have mouse over trigger which should turn background color to yellow if mouse is over, but it is showing default light grey color as shown in snap,</p>
<p>Can anyone tell me how to get background color YELLOW on mouse over?</p>
| <wpf><xaml><wpf-controls> | 2016-01-19 23:05:38 | HQ |
34,888,793 | How to cancel Alamofire.upload | <p>I am uploading images on server via <code>Alamofire.upload</code> as multipart data. Unlike <code>Alamofire.request</code> it's not returning <code>Request</code> object, which I usually use to cancel requests. </p>
<p>But it's very reasonable to be able to cancel such a consuming requests like uploading. What are the options for this in Alamofire?</p>
| <swift><alamofire> | 2016-01-19 23:19:37 | HQ |
34,889,793 | Why did kotlin drop the "new" keyword? | <p>Why did kotlin drop the <strong>new</strong> keyword ?
It makes it harder to see the difference between a function call and an object allocation.</p>
| <kotlin> | 2016-01-20 01:07:06 | HQ |
34,889,957 | A solution to SQLAlchemy temporary table pain? | <p>It seems like the biggest drawback with SQLAlchemy is that it takes several steps backwards when it comes to working with temporary tables. A very common use case, for example, is to create a temporary table that is very specific to one task, throw some data in it, then join against it.</p>
<p>For starters, declaring a temporary table is verbose, and limited. Note that in this example I had to edit it because my classes actually inherit a base class, so what I give here may be slightly incorrect.</p>
<pre><code>@as_declarative(metaclass=MetaBase)
class MyTempTable(object):
__tablename__ = "temp"
__table_args__ = {'prefixes': ['TEMPORARY']}
id = Column(Integer(), primary_key=True)
person_id = Column(BigInteger())
a_string = Column(String(100))
</code></pre>
<p>Creating it is unintuitive:</p>
<pre><code>MyTempTable.__table__.create(session.bind)
</code></pre>
<p>I also have to remember to explictly drop it unless I do something creative to get it to render with ON COMMIT DROP:</p>
<pre><code>MyTempTable.__table__.drop(session.bind)
</code></pre>
<p>Also, what I just gave doesn't even work unless the temporary table is done "top level". I still haven't fully figured this out (for lack of wanting to spend time investigating why it doesn't work), but basically I tried creating a temp table in this manner inside of a nested transaction using session.begin_nested() and you end up with an error saying the relation does not exist. However, I have several cases where I create a temporary table inside of a nested transaction for unit testing purposes and they work just fine. Checking the echo output, it appears the difference is that one renders before the BEGIN statement, while the other renders after it. This is using Postgresql.</p>
<p>What does work inside of a nested transaction, and quite frankly saves you a bunch of time, is to just type out the damned sql and execute it using session.execute. </p>
<pre><code> session.execute(text(
"CREATE TEMPORARY TABLE temp ("
" id SERIAL,"
" person_id BIGINT,"
" a_string TEXT"
") ON COMMIT DROP;"
))
</code></pre>
<p>Of course, if you do this, you still need a corresponding table model to make use of ORM functionality, or have to stick to using raw sql queries, which defeats the purpose of SQLAlchemy in the first place.</p>
<p>I'm wondering if maybe I'm missing something here or if someone has come up with a solution that is a bit more elegant.</p>
| <python><postgresql><sqlalchemy><temp-tables> | 2016-01-20 01:24:51 | HQ |
34,890,654 | How to Add Changing Variable Element to ArrayList in Java | <p>I have a need create an ArrayList to collect positions of some points.</p>
<pre><code>ArrayList<int[]> collection = new ArrayList<int[]> ;
//the position has 2 coordinations.
int[] location = new int[2]
//add first position a,b
location[0] = a;
location[1] = b;
collection.add(location);
//add second position c,d
location[0] = c;
location[1] = d;
collection.add(location);
</code></pre>
<p>When I try to display the collection, all the elements inside are exactly the same as the last one was added (in this case: [c,d])</p>
<p>How do I add the element to my ArrayList properly in this case ? Thank you very much</p>
| <java><arrays><arraylist><element> | 2016-01-20 02:43:53 | LQ_CLOSE |
34,890,747 | Beginner programmer, and I received an error | printf("The rate of train 1 and train 2 respectively are what values?\n");
scanf("%d%d", &rate_1_mph, &rate_2_mph);
printf("What was the total distance the trains were apart initially?\n");
scanf("%d", &distance_total_mile);
printf("The time it takes both trains to arrive side-by-side is %.31f minutes.\n", time_minute);
printf("The distance train 1 had to travel was %.21f miles.\n", distance_1_mile);
printf("The distance train 2 had to travel was %.21f miles.\n", distance_2_mile);
return 0;
}
The error I received was: "warning: format '%f' expects argument of type 'double', but argument 2 has type 'int *".
I've tried looking this up on this site, and I saw the same question solved two different ways but neither seemed to work. I also didn't post the entire code because the other example I saw didn't either, and their question was answered.
| <c> | 2016-01-20 02:55:03 | LQ_EDIT |
34,891,720 | Import excel data using angular js | <p>I am currently working on a web-application using angularjs.I want to import data from excel sheet using angularjs and add it into the ng-grid.Please give me possible solutions.</p>
| <angularjs> | 2016-01-20 04:38:14 | LQ_CLOSE |
34,891,743 | Realm migrations in Swift | <p>I have a Realm Object modeled as so</p>
<pre><code>class WorkoutSet: Object {
// Schema 0
dynamic var exerciseName: String = ""
dynamic var reps: Int = 0
// Schema 0 + 1
dynamic var setCount: Int = 0
}
</code></pre>
<p>I am trying to perform a migration.</p>
<p>Within my <code>AppDelegate</code> I have imported <code>RealmSwift</code>.</p>
<p>Within the function <code>didFinishLaunchWithOptions</code> I call </p>
<pre><code>Migrations().checkSchema()
</code></pre>
<p><em>Migrations</em> is a class declared in another file.</p>
<p>Within that file there is a struct declared as so.</p>
<pre><code>func checkSchema() {
Realm.Configuration(
// Set the new schema version. This must be greater than the previously used
// version (if you've never set a schema version before, the version is 0).
schemaVersion: 1,
// Set the block which will be called automatically when opening a Realm with
// a schema version lower than the one set above
migrationBlock: { migration, oldSchemaVersion in
// We haven’t migrated anything yet, so oldSchemaVersion == 0
switch oldSchemaVersion {
case 1:
break
default:
// Nothing to do!
// Realm will automatically detect new properties and removed properties
// And will update the schema on disk automatically
self.zeroToOne(migration)
}
})
}
func zeroToOne(migration: Migration) {
migration.enumerate(WorkoutSet.className()) {
oldObject, newObject in
let setCount = 1
newObject!["setCount"] = setCount
}
}
</code></pre>
<p>I am getting an error for adding <code>setCount</code> to the model</p>
| <swift><migration><realm><data-migration><data-management> | 2016-01-20 04:41:10 | HQ |
34,892,434 | Update code to swift 2 | <p>How do i update following code to swift 2 i am new</p>
<pre><code>if let rtf = NSBundle.mainBundle().URLForResource("rtfdoc", withExtension: "rtf", subdirectory: nil, localization: nil) {
let attributedString = NSAttributedString(fileURL: rtf, options: [NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType], documentAttributes: nil, error: nil)
textView.attributedText = attributedString
textView.editable = false
</code></pre>
| <ios><swift><swift2><rtf> | 2016-01-20 05:48:22 | LQ_CLOSE |
34,892,478 | git lfs "objects" taking a lot of disk space | <p>I have a project with a lot of binaries (mostly pdfs) that I'm using git-lfs with. The project is about 60mb but I found that my .git/lfs/objects director is about 500mb. I presume these are cached versions of previous commits. Is there a way to gracefully delete these (ie delete them without corrupting the state of git)? The odds of me ever wanting previous versions of the files in LFS are near 0 now especially since the project is over.</p>
| <git><github><git-lfs> | 2016-01-20 05:51:58 | HQ |
34,892,541 | Notice "Undifined Variable" | <p>I am running a PHP script, and keep getting errors like:
<a href="http://i.stack.imgur.com/89eot.png" rel="nofollow">this is my error</a></p>
<p><a href="http://i.stack.imgur.com/YTYKT.png" rel="nofollow">this is script</a></p>
| <php> | 2016-01-20 05:57:59 | LQ_CLOSE |
34,892,601 | what does the weak_alias function do and where is it defined | <p>So I'm looking through the source of gcc compiler and I've come along this in fork.c:</p>
<pre><code>int
__fork ()
{
__set_errno (ENOSYS);
return -1;
}
libc_hidden_def (__fork)
stub_warning (fork)
weak_alias (__fork, fork)
#include <stub-tag.h>
</code></pre>
<p>I'm trying to figure out what weak_alias does. I've used the grep command inside the glibc source files to find all occurrences of #define weak_alias:</p>
<pre><code>grep -r "#define weak_alias"
</code></pre>
<p>I've found many occurrences of the macro:</p>
<pre><code>#define weak_alias(n, a)
</code></pre>
<p>but the macros don't actually explain anything. They just define that statement they don't show how its being replaced. For example one occurrence is in profil.c:</p>
<pre><code>/* Turn off the attempt to generate ld aliasing records. */
#undef weak_alias
#define weak_alias(a,b)
</code></pre>
<p>So any ideas what weak_alias does and where it is being defined?</p>
<p>Thanks in advance</p>
| <c><linux><gcc><compiler-construction><gnu> | 2016-01-20 06:02:20 | HQ |
34,892,696 | how to show selected item in another activityin android | <p>I am new in android. My app is basically is shoppping cart.Now I want help.
when user select items from custom listview.Those items display with image ,name and quantity to next activity such as view cart.I have been searching tutorial but cannot find a complete one. Can anyone guide me through proper code how could I do this?</p>
| <android> | 2016-01-20 06:08:02 | LQ_CLOSE |
34,893,279 | Spring Data Redis Expire Key | <p>I have a One Spring Hibernate Application. In my application, Recently i am implemented Spring data Redis.</p>
<pre><code>spring-servlet.xml
<!-- redis connection factory -->
<bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:use-pool="true"/>
<!-- redis template definition -->
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
p:connection-factory-ref="jedisConnFactory"/>
</code></pre>
<p>And this <code>redisTemplate</code> use in my ServiceImpl class.</p>
<pre><code>RedisServiceImpl
@Autowired
private RedisTemplate<String, T> redisTemplate;
public RedisTemplate<String, T> getRedisTemplate() {
return redisTemplate;
}
public void setRedisTemplate(RedisTemplate<String, T> redisTemplate) {
this.redisTemplate = redisTemplate;
}
</code></pre>
<p>Now I added data in redisServer like this</p>
<pre><code>public void putData(String uniqueKey, String key, Object results) {
redisTemplate.opsForHash().put(uniqueKey, key, results);
}
</code></pre>
<p>Now i want to remove Expire key.</p>
<p>I search in Google, But in google all are saying like this</p>
<pre><code>redisTemplate.expire(key, timeout, TimeUnit);
</code></pre>
<p>In this expire method, We need to provide <code>uniqueKey</code> instead of <code>key</code>.
But I need to Expire <code>key</code> instead of <code>uniqueKey</code>.</p>
<p>So Please help me what can i do for expire <code>Key</code>?</p>
| <java><spring><hibernate><redis> | 2016-01-20 06:49:25 | HQ |
34,893,623 | i want to conect a microcontroller to PC and play audio recived to pc by using naudio | i want to connect a microcontroller to PC and send wave file form micro to PC and play real-time and save it to PC
i can set a connection with USB between micro and PC to receive array
i should play this array and add next array in real-time without gaps in play
and i use C# to programming | <c#><microcontroller><naudio> | 2016-01-20 07:10:04 | LQ_EDIT |
34,895,019 | Node Modular Architecture | <p>I am building a nodejs application that is fairly large now. In an attempt to avoid a monolithic node application I have gone down the architectural route of a more modular system breaking out several components into separate npm modules. These are published using npm and installed in the dependent modules. I have about 6 different modules (which I would want to break out in to more) and now it has become difficult to manage the packages.</p>
<p><strong>The problems</strong> are:</p>
<ol>
<li>There is nested dependency so if I change module A and module B depends on module A and module C depends on module B, then when I update module A I need to publish a new version of it, which then means I need to update it in module B, which means I also need to publish of that and then finally I need to install that new version in module A ... you can see where that might be a pain. What's more the updating of the versions in all the package.json is manual and so error prone, and waiting for each publish is time consuming.</li>
<li>Modules can share npm dependencies and so sometimes conflicts occur when packages get updated. The more modules the higher the chance of conflict.</li>
</ol>
<p><strong>The benefits</strong> are that we have a very modular system where libraries can be reused easily and there is a clear hierarchy of modules enforced as there can't be any circular dependencies.</p>
<p><strong>Possible solutions</strong> are:</p>
<ol>
<li><p><strong>Monolith</strong> - To manage the dependencies as a single app in a single repository with each module just becoming a services. This means that only one update is necessary and all the module apis will be in sync. However, referencing the libraries in the code might be a bit of a pain (as I believe they will have to be referenced relative to the local file), I am not sure how a structural hierarchy between the modules can be enforced and code reuse will be harder with modules outside the repository.</p></li>
<li><p><strong>Microservices</strong> - To make each module a micro service. This maintains all the benefits of the modular system, but I am concerned that it will add a lot of complexity to the build and managing all the services will become a full time job in itself.</p></li>
<li><p><strong>Keep going</strong> - Work out a way to keep the current architecture but remove the trouble of pushing updates etc. Maybe scripts to update versions and shrinkwrap to ensure correct dependencies. I think this would both be difficult and would potentially lead it to being a monolithic system of a different variety.</p></li>
</ol>
<p>Option 1 seems the most manageable to me but I don't want to lose the modular structure if I don't have to.</p>
<p>This is quite a broad question, but any suggestions/advice/comments would be really helpful.</p>
<p>Thanks</p>
| <node.js><architecture><npm> | 2016-01-20 08:32:39 | HQ |
34,896,097 | Nothing displaying in console when using console.log with if statements in for loops | <p>I have two objects:</p>
<pre><code>var obj = { first: "Romeo", last: "Montague" };
var search = { last: "Montague" };
</code></pre>
<p>My goal is to find if the second object (<code>search</code>) is present in the first one, and <code>console.log</code> it if it is.</p>
<p>First, I get the keys of both objects:</p>
<pre><code>var objKeys = Object.keys(obj);
var searchKeys = Object.keys(search);
</code></pre>
<p>Then I am trying to iterate trough both keys and compare them, and if they match, <code>console.log</code> the value from the first obj (<code>obj</code>).</p>
<pre><code>//for every key in object
for(var x = 0; x < objKeys.lenght; x++) {
//for every key in search
for(var y = 0; y < searchKeys.length; y++) {
//see if a key matches
if(searchKeys[y] == objKeys[x]) {
//see if the value matches
if(obj[objKeys[x]] == search[searchKeys[y]]) {
console.log(obj[objKeys[x]]);
}
else {
console.log("value not found");
}
}
else {
console.log("key not found");
}
}
}
</code></pre>
<p>Now when I run this code, nothing displays in the console. No errors or messages. Can anybody point out what I'm doing wrong?</p>
<p>I've create a <a href="https://jsfiddle.net/gdbw58r8/2/" rel="nofollow">jsFiddle</a> of this code, if you want to tinker.</p>
| <javascript> | 2016-01-20 09:25:45 | LQ_CLOSE |
34,897,704 | Use svg as map using leaflet.js | <p>Is it possible to use SVG image as the base map for leaflet.js ?</p>
<p>In my case I have huge svg file and I wish to allow my users to use all of leaflet's features such as zoom, markers, layers.</p>
| <javascript><svg><leaflet> | 2016-01-20 10:39:10 | HQ |
34,897,843 | Why does Go panic on writing to a closed channel? | <p>Why does Go panic on writing to a closed channel?</p>
<p>While one can use the <code>value, ok := <-channel</code> idiom for reading from channels, and thus the ok result can be tested for hitting a closed channel:</p>
<pre><code>// reading from closed channel
package main
import "fmt"
func main() {
ch := make(chan int, 1)
ch <- 2
close(ch)
read(ch)
read(ch)
read(ch)
}
func read(ch <-chan int) {
i,ok := <- ch
if !ok {
fmt.Printf("channel is closed\n")
return
}
fmt.Printf("read %d from channel\n", i)
}
</code></pre>
<p>Output:</p>
<pre><code>read 2 from channel
channel is closed
channel is closed
</code></pre>
<p>Run "reading from closed channel" on <a href="http://play.golang.org/p/oJoLGeRI4S" rel="noreferrer">Playground</a></p>
<p>Writing to a possibly closed channel is more convoluted, because Go will panic if you simply try to write when the channel is closed:</p>
<pre><code>//writing to closed channel
package main
import (
"fmt"
)
func main() {
output := make(chan int, 1) // create channel
write(output, 2)
close(output) // close channel
write(output, 3)
write(output, 4)
}
// how to write on possibly closed channel
func write(out chan int, i int) (err error) {
defer func() {
// recover from panic caused by writing to a closed channel
if r := recover(); r != nil {
err = fmt.Errorf("%v", r)
fmt.Printf("write: error writing %d on channel: %v\n", i, err)
return
}
fmt.Printf("write: wrote %d on channel\n", i)
}()
out <- i // write on possibly closed channel
return err
}
</code></pre>
<p>Output:</p>
<pre><code>write: wrote 2 on channel
write: error writing 3 on channel: send on closed channel
write: error writing 4 on channel: send on closed channel
</code></pre>
<p>Run "writing to closed channel" on <a href="http://play.golang.org/p/qL7z3SVeqX" rel="noreferrer">Playground</a></p>
<p>As far as I know, there is not a simpler idiom for writing into a possibly closed channel without panicking. Why not? What is the reasoning behind such an asymmetric behavior between read and write?</p>
| <go><concurrency><channel><goroutine><panic> | 2016-01-20 10:45:29 | HQ |
34,898,267 | Using CameraCaptureUI in Windows 10 fullscreen | <p>Is their a way to tell the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.cameracaptureui">CameraCaptureUI</a>, that it should start in fullscreen mode, instead of a small window?</p>
<p>my current code from the linked webside:</p>
<pre><code>CameraCaptureUI cameraUI = new CameraCaptureUI();
Windows.Storage.StorageFile capturedMedia =
await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Video);
</code></pre>
<p>My Application is based on WinRT for Windows 8.1.</p>
<p>On a Win 8 Client the Camera App just start in fullscreen, but with a Win 10 Client it open the Camera App in a small window</p>
| <c#><camera><windows-runtime> | 2016-01-20 11:03:27 | HQ |
34,898,589 | Particles over background image | <p>As seen on <a href="https://discordapp.com/" rel="nofollow">https://discordapp.com/</a> there's floating particles overlaying the background of the header. I've searched pretty much everywhere, trying to export transparent videos, gifs from Premiere CC, After Effects even Photoshop, but none of them will work as seen on this page.
I have also not been able to read through the code to find the source of the effect.</p>
| <html><css> | 2016-01-20 11:18:43 | LQ_CLOSE |
34,900,023 | Read files sent with spark-submit by the driver | <p>I am sending a Spark job to run on a remote cluster by running</p>
<pre><code>spark-submit ... --deploy-mode cluster --files some.properties ...
</code></pre>
<p>I want to read the content of the <code>some.properties</code> file by the <strong>driver</strong> code, i.e. before creating the Spark context and launching RDD tasks. The file is copied to the remote driver, but not to the driver's working directory.</p>
<p>The ways around this problem that I know of are:</p>
<ol>
<li>Upload the file to HDFS</li>
<li>Store the file in the app jar</li>
</ol>
<p>Both are inconvenient since this file is frequently changed on the submitting dev machine.</p>
<p>Is there a way to read the file that was uploaded using the <code>--files</code> flag during the driver code main method? </p>
| <apache-spark> | 2016-01-20 12:25:07 | HQ |
34,900,047 | Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unexpected start state' | <p>I've strange and rare to reproduce crash that happening on iOS 9. The question are <strong>How to fix this</strong> or <strong>What leads to this exception</strong> </p>
<p>As you can see traces not contains my code and crash happens on app start. </p>
<pre><code>Last Exception Backtrace:
0 CoreFoundation 0x0000000180a49900 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x00000001800b7f80 objc_exception_throw + 52
2 CoreFoundation 0x0000000180a497d0 +[NSException raise:format:arguments:] + 104
3 Foundation 0x00000001813bca08 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 84
4 UIKit 0x00000001859f9f34 _prepareForCAFlush + 252
5 UIKit 0x00000001859ff4f0 _beforeCACommitHandler + 12
6 CoreFoundation 0x0000000180a00588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
7 CoreFoundation 0x00000001809fe32c __CFRunLoopDoObservers + 368
8 CoreFoundation 0x00000001809fe75c __CFRunLoopRun + 924
9 CoreFoundation 0x000000018092d680 CFRunLoopRunSpecific + 380
10 GraphicsServices 0x0000000181e3c088 GSEventRunModal + 176
11 UIKit 0x00000001857a4d90 UIApplicationMain + 200
12 MyAppName 0x000000010009d200 main (main.m:14)
13 ??? 0x00000001804ce8b8 0x0 + 0
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001805ec140 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001806b4ef8 pthread_kill + 108
2 libsystem_c.dylib 0x000000018055ddac abort + 136
3 MyAppName 0x0000000100805bcc uncaught_exception_handler + 28
4 CoreFoundation 0x0000000180a49c88 __handleUncaughtException + 648
5 libobjc.A.dylib 0x00000001800b823c _objc_terminate() + 108
6 libc++abi.dylib 0x00000001800aaf44 std::__terminate(void (*)()) + 12
7 libc++abi.dylib 0x00000001800aab10 __cxa_rethrow + 140
8 libobjc.A.dylib 0x00000001800b8120 objc_exception_rethrow + 40
9 CoreFoundation 0x000000018092d728 CFRunLoopRunSpecific + 548
10 GraphicsServices 0x0000000181e3c088 GSEventRunModal + 176
11 UIKit 0x00000001857a4d90 UIApplicationMain + 200
12 MyAppName 0x000000010009d200 main (main.m:14)
13 ??? 0x00000001804ce8b8 0x0 + 0
</code></pre>
| <ios><crash><ios9.2> | 2016-01-20 12:26:04 | HQ |
34,900,862 | cheating online test javascript timer | First of all, I have no intention of cheating, I'm just one of these people who tend to see flaws everywhere.
These days before the job interview you may be required to do online test, most of them have javascript timers (countdown), so you don't have enough time to google the answers.
But the way I see it (correct me if I'm wrong), timer is just a decreasing variable that once reaches 0 (say) stops the test. I seems that in many cases it is possible to look the source code, find the name of the variable and force-increase it using the console, so you have all time in the world.
I'm interested is it always possible to manipulate such "timer" variable using console, or there are ways to prevent it?
| <javascript><timer> | 2016-01-20 13:04:41 | LQ_EDIT |
34,901,258 | Are there sample tables on sqlfiddle | <p>Are there any default tables on SqlFiddle that I can query from?</p>
<p>I want to try a basic analytical query on a simple table but I don't want to set up the schema and seed data etc.</p>
<p>normally I would do something like <code>select * from all_objects</code></p>
<p>( <a href="http://sqlfiddle.com/" rel="noreferrer">http://sqlfiddle.com/</a> )</p>
| <sqlfiddle> | 2016-01-20 13:22:32 | HQ |
34,901,556 | sass classes for colorizing in html | <p>i would like to create sass classes, such as .blue and .bg,
but depending on which i use, it should colorize the fonts and/or the background.</p>
<pre><code>// Classes for colorizing elements
.blue {
color: $primary-color;
&.bg {
background-color: $primary-color;
color: initial;
}
}
.light-gray {
color: $light-gray;
&.bg {
background-color: $light-gray;
color: initial;
}
}
.medium-gray {
color: $medium-gray;
&.bg {
background-color: $medium-gray;
color: initial;
}
}
.dark-gray {
color: $dark-gray;
&.bg {
background-color: $dark-gray;
color: initial;
}
}
.black {
color: $black;
&.bg {
background-color: $black;
color: initial;
}
}
.white {
color: $white;
&.bg {
background-color: $white;
color: initial;
}
}
</code></pre>
<p>the use of <code>color:inherit</code> here is repetitive and inefficient.</p>
<p>for example, if I use <code>.black .bg</code> than ONLY the background-color should be black.</p>
<p>If I only use <code>.black</code>, than ONLY the font-color should be used.</p>
<p><code>.bg</code> alone doesn't have to work in this case</p>
<p>Which SCSS/SASS elements can i use to achieve small and efficient code?
Thanks!</p>
| <html><css><sass> | 2016-01-20 13:36:49 | LQ_CLOSE |
34,902,612 | FILE I/O: two file pointes | <p>I'm new to FILE I/O Stream and I want to write a program, which converts chars (read from "texti.txt") like "ä,Ä,ü,Ü,ö,Ö" to "ae,Ae,ue,Ue,oe,Oe" and write them in a new file called "texto.txt".</p>
<p><strong>First Question:</strong>
Is it ok to have two file pointers (on to each file) at the same time like i do?</p>
<p><strong>Second Question:</strong>
What am I doing wrong with character compare in the switch statement?
VS2015 is warning that cases 2 and 3 already exist (reference to case 1)</p>
<p><strong>Thirt Question</strong>
Does <code>fpo</code> (file pointer to output-file) increment itself automatically by writig a char?</p>
<p><strong>Question four:</strong>
VS2015 is warning: </p>
<p>C4996 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.</p>
<p>Is there another function I should use?</p>
<pre><code>int main()
{
char c;
FILE *fpi;
FILE *fpo;
fpi = fopen("texti.txt","r");
fpo = fopen("texto.txt", "w");
if (fpi == NULL)
fprintf(stderr, "Fehler beim Lesen");
while (!feof(fpi))
{
c = fgetc(fpi);
switch (c)
{
case 'ä'||'Ä':
fputc('a', fpo);
fputc('e', fpo);
break;
case 'ö'||'Ö':
fputc('o', fpo);
fputc('e', fpo);
break;
case 'ü' || 'Ü':
fputc('u', fpo);
fputc('e', fpo);
break;
default:
fputc((c), fpo);
}
fpi++;
}
fclose(fpi);
fclose(fpo);
</code></pre>
<p>}</p>
| <c><file><io> | 2016-01-20 14:22:28 | LQ_CLOSE |
34,902,663 | Permission denied inside Docker container | <p>I have a started container <code>gigantic_booth</code> and I want to create the directory <code>/etc/test</code>:</p>
<pre><code># docker exec -it gigantic_booth /bin/bash
$ mkdir /etc/test
$ mkdir: cannot create directory '/etc/test': Permission denied
</code></pre>
<p>And <code>sudo</code> command is not found. I don't want to create this directory in image-build-time but once is started.</p>
<p>How can I do?</p>
<p>Thanks :)</p>
| <docker> | 2016-01-20 14:25:05 | HQ |
34,904,328 | Click: "Got unexpected extra arguments" when passing string | <pre><code>import click
@cli.command()
@click.argument("namespace", nargs=1)
def process(namespace):
.....
@cli.command()
def run():
for namespace in KEYS.iterkeys():
process(namespace)
</code></pre>
<p>Running <code>run('some string')</code> produces:</p>
<p><code>Error: Got unexpected extra arguments (o m e s t r i n g)</code></p>
<p>As if Click passes string argument by one character. Printing an argument shows correct result.</p>
<p>PS: KEYS dictionary defined and working as expected.</p>
| <python><python-click> | 2016-01-20 15:41:13 | HQ |
34,904,499 | want to add multipules tables to a frame dynamicly | hi want to add a number of tables to my frame , depending on the out come of something
so put this
int x=17;
int y=95;
for(int i=0;i<5;i++)
{
table[i].setBounds(x+50,y+50, 525, 44);
contentPane.add(table[i]);
}
but nothing happing
any one has some sorte of idia | <java><swing><jtable> | 2016-01-20 15:49:22 | LQ_EDIT |
34,904,523 | ES6/ES2015 object destructuring and changing target variable | <p>How can I rename the target during object destructing?</p>
<pre><code>const b = 6;
const test = { a: 1, b: 2 };
const {a, b as c} = test; // <-- `as` does not seem to be valid in ES6/ES2015
// a === 1
// b === 6
// c === 2
</code></pre>
| <javascript><ecmascript-6><destructuring> | 2016-01-20 15:50:41 | HQ |
34,904,548 | How to grab a single image from RTSP stream using FFMPEG | <p>I have seen several other related questions but they all seem to be related to grabbing a still shot every X number of seconds. How can I grab 1 image when the command is run.</p>
<p>I was trying</p>
<pre><code>ffmpeg -y -i rtsp://admin:admin@192.168.10.113:554/live -f image2 -updatefirst 1 do.jpg
</code></pre>
| <ffmpeg> | 2016-01-20 15:51:43 | HQ |
34,904,991 | Telerik Kendo MVC TextBox Multiline Mode | <p>Does anyone know what properties to set to make a Kendo MVC Textbox Multiline?</p>
<pre><code> @(Html.Kendo().TextBox()
.Name("txtComments")
.Value(@Model.Comments)
.HtmlAttributes(new { style = "width:100%" })
)
</code></pre>
<p>Thanks.</p>
| <razor><textbox><kendo-asp.net-mvc><multiline><telerik-mvc> | 2016-01-20 16:12:06 | HQ |
34,905,292 | how to compare two images in java?in terms of height and width | <p>i had been working on my project which encompasses the technique for comparing images. I want to compare two images in java in terms of height and width, i can't compare it if any one can help it please do..</p>
| <java><image><comparison><height><width> | 2016-01-20 16:25:30 | LQ_CLOSE |
34,905,363 | Create File with Google Drive Api v3 (javascript) | <p>I want to create a file with content using Google Drive API v3. I have authenticated via OAuth and have the Drive API loaded. Statements like the following work (but produce a file without content):</p>
<pre><code>gapi.client.drive.files.create({
"name": "settings",
}).execute();
</code></pre>
<p>Unfortunately I cannot figure out how to create a file that has a content. I cannot find a JavaScript example using Drive API v3. Are there some special parameters that I need to pass?</p>
<p>For simplicity, assume that I have a String like '{"name":"test"}' that is in JSON format that should be the content of the created file.</p>
| <javascript><google-drive-api> | 2016-01-20 16:28:35 | HQ |
34,905,794 | Android Image upload/download with Base64 into JSON causes Out of memory error | <p>I currently encode and decode images to Base64. I overcame the initial issue with OOM's with the use of streams to encode the images into strings.</p>
<p>My issue now is that I cannot fathom how to add multiple Base64 encoded strings for multiple resolutions images (5620 x 3747 - 4.92MB or 3264 x 1836 - 1.35MB) to a JSON Object via Gson. Currently Gson throws an OOM exception only with 2 Base64 Strings from a 5312 x 2988 - 4.95 MB Image.</p>
<p>I understand that android may only be able to spare 16/20Mb per application, so this conversion must be way over the limit.</p>
<p>How can I write the Base64 String in a stream to a JSON object that will contain the specific values needed to post into my server?</p>
<p>Would it be easier to change my server to accept a Multi-Part request instead of a JSON based POJO with multiple Base64 Strings? I currently use Volley and there isn't an official Multi-Part Request as well as IO streaming.</p>
<p>If it's a matter of compression, how much compression should I apply to the image before encoding into a Base64 String? I ideally want to lose barely any quality but have optimal compression levels.</p>
<p><strong>Bit more Information</strong></p>
<p>I am uploading multiple different resolution images as it is a test for compatibility. For example, all the images that I am sending up have been taken on low resolution and extremely high resolution devices as my App relies on these images for functionality. I am trying to prove that any image (to a certain extent, mainly images captured on mobile devices) can be handled by my application.</p>
<p>I understand that some images may be so large that by loading them into memory will cause exceptions. This is something I will try and handle later.</p>
<p>In some cases the images that will be uploaded can span from 1 to 200.</p>
<p>I'm trying to look for the most optimal solution that will scale well.</p>
| <android><image><base64><gson><android-volley> | 2016-01-20 16:48:57 | HQ |
34,905,850 | Child node "2" exited prematurely | <p>I recently retargeted my Windows 8.1 app to Windows 10. I'm getting this error when building the UI projects, </p>
<pre><code>"MSBUILD : error MSB4166: Child node "2" exited prematurely. Shutting down. Diagnostic information may be found in files in the temporary files directory named MSBuild_*.failure.txt."
</code></pre>
<p>That's not particularly useful, so I went to %temp% looking for said failure log, and it doesn't exist. Am I looking in the wrong "temp" directory?</p>
<p>What causes this error? I can build my supporting library project without this error.</p>
| <msbuild><visual-studio-2015><windows-10-universal> | 2016-01-20 16:51:34 | HQ |
34,905,900 | Swift "retry" logic on request | <p>So i'm a bit lost on how to implement a retry logic when my upload request fail.</p>
<p>Here is my code i would like some guidance on how to do it</p>
<pre><code>func startUploading(failure failure: (NSError) -> Void, success: () -> Void, progress: (Double) -> Void) {
DDLogDebug("JogUploader: Creating jog: \(self.jog)")
API.sharedInstance.createJog(self.jog,
failure: { error in
failure(error)
}, success: {_ in
success()
})
}
</code></pre>
| <swift><alamofire> | 2016-01-20 16:53:50 | HQ |
34,905,905 | General android programming guide lines | <p>I have been programming on android for the past few months and have hit a point where I comprehend the basic ideas and principles for Android development. </p>
<p>Currently I think that my code lacks the appropriate structure and clearance that is required in order for your code to be readable. I know this because sometimes even I find it hard to read my code - and I am not talking about the variable or classes names. I am talking about for example when I open a big ( lengthy ) activity and have 5 overriden methods, 5 more and tons of global variables, a couple of inner-classes and so on it gets hard to find stuff in.</p>
<p>Therefore I have been looking for some guide lines for how to do this so that the code looks good and is readable but I haven't been able to. </p>
<p>There are also small problems to which I find hard to find an answer and usually go with what i feel like rather than knowing for sure what is right in the situation. For example what is better - having the activity implement onClickListener and then having a big switch statement, or just creating new listener for every UI element. </p>
<p>I was hoping some of you might know a place where I can find answers for questions like this. If there is not I will start adding the questions here.</p>
<p>Thank you </p>
| <android><coding-style> | 2016-01-20 16:53:58 | LQ_CLOSE |
34,906,002 | Increase width of entire HTML Rmarkdown output | <p>I am looking to increase the overall width of my HTML Rmarkdown output. </p>
<p>When producing PDF documents from Rmarkdowns there is an option to set the margin in the YAML section of the Rmd (ex. geometry: margin=.5in).</p>
<p>I am looking for something similar for HTML docs. The following link is a good example of my issue: <a href="https://rstudio.github.io/DT/extensions.html" rel="noreferrer">https://rstudio.github.io/DT/extensions.html</a> </p>
<p>As you can see on that html webpage, there is a lot of white space to the left and right of the datatables. Is there a way to reduce this margin space and thus increase the width of the datatables?</p>
<p>Thanks</p>
| <html><rstudio><r-markdown><margins> | 2016-01-20 16:58:15 | HQ |
34,906,042 | sql query to delete data from 2 tables | currently trying to accomplish the following task adn i using this sql to doit but still not working
'' DoCmd.RunSQL " delete tbl_siphon_req_info.* from tbl_siphon_req_info a, tbl_siphon_PO b where concat(a.ross_PO_nbr, a.ross_sku12) = Concat(b.PO_ID, Sbstr(bitem_id,1,12))"
if any one can help me to correct and complete what i need to do... thanks
| <sql><vba><ms-access> | 2016-01-20 17:00:09 | LQ_EDIT |
34,906,301 | How to get other pages followers count number in Instagram? | <p>is there possibility to get other pages follower count number in Instagram?
I can get only my profile followers count number, but I want to get other followers too? (for example in php)</p>
<p>Any ideas?</p>
| <php><instagram><instagram-api> | 2016-01-20 17:12:39 | HQ |
34,906,305 | Protocol buffer3 and json | <p>Protocol buffer v3 claims, that library is json friendly (<a href="https://developers.google.com/protocol-buffers/docs/proto3#json" rel="noreferrer">https://developers.google.com/protocol-buffers/docs/proto3#json</a>), but I cannot find how to achieve get that mapping. Should I add some plugin, or some option into protoc, or call something special instead SerializeTo/ParseFrom?</p>
<p>Is it someone who use that feature?</p>
| <c++><json><protocol-buffers><proto3> | 2016-01-20 17:12:58 | HQ |
34,906,500 | Why is a type registered twice when lifetime manager is specified? | <p>I'm using Unity's <em>Register by convention</em> mechanism in the following scenario:</p>
<pre><code>public interface IInterface { }
public class Implementation : IInterface { }
</code></pre>
<p>Given <code>Implementation</code> class and its interface I'm running <code>RegisterTypes</code> in the following way:</p>
<pre><code>unityContainer.RegisterTypes(
new[] { typeof(Implementation) },
WithMappings.FromAllInterfaces,
WithName.Default,
WithLifetime.ContainerControlled);
</code></pre>
<p>After this call, <code>unitContainer</code> contains three registrations:</p>
<ul>
<li><code>IUnityContainer</code> -> <code>IUnityContainer</code> (ok)</li>
<li><code>IInterface</code> -> <code>Implementation</code> (ok)</li>
<li><code>Implementation</code> -> <code>Implementation</code> (???)</li>
</ul>
<p>When I change the call as follows:</p>
<pre><code>unityContainer.RegisterTypes(
new[] { typeof(Implementation) },
WithMappings.FromAllInterfaces,
WithName.Default);
</code></pre>
<p>The container contains only two registrations:</p>
<ul>
<li><code>IUnityContainer</code> -> <code>IUnityContainer</code> (ok)</li>
<li><code>IInterface</code> -> <code>Implementation</code> (ok)</li>
</ul>
<p>(this is the desired behaviour).</p>
<p>After peeking into <a href="https://github.com/unitycontainer/unity/blob/master/source/Unity/Src/RegistrationByConvention/UnityContainerRegistrationByConventionExtensions.cs">Unity's source code</a>, I've noticed that there is some misunderstanding about how <code>IUnityContainer.RegisterType</code> should work.</p>
<p>The <code>RegisterTypes</code> method works as follows (the comments indicate what are the values in the scenarios presented above):</p>
<pre><code>foreach (var type in types)
{
var fromTypes = getFromTypes(type); // { IInterface }
var name = getName(type); // null
var lifetimeManager = getLifetimeManager(type); // null or ContainerControlled
var injectionMembers = getInjectionMembers(type).ToArray(); // null
RegisterTypeMappings(container, overwriteExistingMappings, type, name, fromTypes, mappings);
if (lifetimeManager != null || injectionMembers.Length > 0)
{
container.RegisterType(type, name, lifetimeManager, injectionMembers); // !
}
}
</code></pre>
<p>Because <code>fromTypes</code> is not empty, the <code>RegisterTypeMappings</code> adds one type mapping: <code>IInterface</code> -> <code>Implementation</code> (correct).</p>
<p>Then, in case when <code>lifetimeManager</code> is not null, the code attempts to change the lifetime manager with the following call:</p>
<pre><code>container.RegisterType(type, name, lifetimeManager, injectionMembers);
</code></pre>
<p>This function's name is completely misleading, because <a href="https://msdn.microsoft.com/en-us/library/ee650597.aspx">the documentation</a> clearly states that:</p>
<blockquote>
<p>RegisterType a LifetimeManager for the given type and name with the container. No type mapping is performed for this type.</p>
</blockquote>
<p>Unfortunately, not only the name is misleading but the documentation is wrong. When debugging this code, I've noticed, that when there is no mapping from <code>type</code> (<code>Implementation</code> in the scenarios presented above), it is added (as <code>type</code> -> <code>type</code>) and that's why we end up with three registrations in the first scenario.</p>
<p>I've downloaded Unity's sources to fix the problem, but I've found the following unit test:</p>
<pre><code>[TestMethod]
public void RegistersMappingAndImplementationTypeWithLifetimeAndMixedInjectionMembers()
{
var container = new UnityContainer();
container.RegisterTypes(new[] { typeof(MockLogger) }, getName: t => "name", getFromTypes: t => t.GetTypeInfo().ImplementedInterfaces, getLifetimeManager: t => new ContainerControlledLifetimeManager());
var registrations = container.Registrations.Where(r => r.MappedToType == typeof(MockLogger)).ToArray();
Assert.AreEqual(2, registrations.Length);
// ...
</code></pre>
<p>- which is almost exactly my case, and leads to my question:</p>
<p>Why is this expected? Is it a conceptual mistake, a unit test created to match existing behaviour but not necessarily correct, or am I missing something important?</p>
<p>I'm using Unity v4.0.30319.</p>
| <c#><.net><unity-container> | 2016-01-20 17:22:22 | HQ |
34,906,624 | Android support EditTextPreference input type | <p>Is there any way to specify the input method type for <code>android.support.v7.preference.EditTextPreference</code>?</p>
| <android><android-support-library><edittextpreference> | 2016-01-20 17:28:34 | HQ |
34,906,888 | Angular 2 access parent routeparams from child component | <p>I've got this (main parent) component -</p>
<pre><code>@RouteConfig([
{ path: '/', name: 'ProjectList', component: ProjectListComponent, useAsDefault: true },
{ path: '/new', name: 'ProjectNew', component: ProjectFormComponent },
{ path: '/:id', name: 'ProjectDetail', component: ProjectDetailComponent },
{ path: '/:id/issues/...', name: 'Issue', component: IssueMountComponent },
])
class ProjectMountComponent {
}
</code></pre>
<p>And then I've got the second mount component (child of main parent, parent of the next component)</p>
<pre><code>@Component({
template: `
<div><router-outlet></router-outlet></div>
`,
directives: [RouterLink, RouterOutlet]
})
@RouteConfig([
{ path: "/", name: "IssueList", component: IssueListComponent, useAsDefault: true },
])
class IssueMountComponent {
constructor(private _routeParams: RouteParams) {
}
}
</code></pre>
<p>Here I can access the routeParams (:id) without any problem. Now, here's the component where I need the value of <code>:id</code> from the uri. </p>
<pre><code>@Component({
template: `
<h3>Issue List</h3>
<ul>
<issue-component *ngFor="#issue of issues" [issue]="issue"></issue-component>
</ul>
`,
directives: [IssueComponent],
providers: [IssueService]
})
class IssueListComponent implements OnInit {
issues: Issue[];
constructor(private _issueService: IssueService,
private _routeParams: RouteParams) {}
getIssues() {
let id = this._routeParams.get('id');
console.log(this._routeParams);
this._issueService.getIssues(id).then(issues => this.issues = issues);
}
ngOnInit() {
this.getIssues();
}
}
</code></pre>
<p>In this component, I cannot access the value of the <code>:id</code> route parameter. It's always null. What am I doing wrong?</p>
<p>Here's the component hierarchy -</p>
<p><strong>ProjectMountComponent -> IssueMountComponent -> IssueListComponent</strong></p>
| <javascript><routing><angular><angular-routing> | 2016-01-20 17:41:15 | HQ |
34,907,151 | Handling refresh tokens using rxjs | <p>Since i've started with angular2 i have setup my services to return Observable of T. In the service i would have the map() call, and components using these services would just use subscribe() to wait for the response. For these simple scenarios i didnt really need to dig in to rxjs so all was ok. </p>
<p>I now want to achieve the following: i am using Oauth2 authentication with refresh tokens. I want to build an api service that all other services will use, and that will transparently handle the refresh token when a 401 error is returned. So, in the case of a 401, i first fetch a new token from the OAuth2 endpoint, and then retry my request with the new token. Below is the code that works fine, with promises:</p>
<pre><code>request(url: string, request: RequestOptionsArgs): Promise<Response> {
var me = this;
request.headers = request.headers || new Headers();
var isSecureCall: boolean = true; //url.toLowerCase().startsWith('https://');
if (isSecureCall === true) {
me.authService.setAuthorizationHeader(request.headers);
}
request.headers.append('Content-Type', 'application/json');
request.headers.append('Accept', 'application/json');
return this.http.request(url, request).toPromise()
.catch(initialError => {
if (initialError && initialError.status === 401 && isSecureCall === true) {
// token might be expired, try to refresh token.
return me.authService.refreshAuthentication().then((authenticationResult:AuthenticationResult) => {
if (authenticationResult.IsAuthenticated == true) {
// retry with new token
me.authService.setAuthorizationHeader(request.headers);
return this.http.request(url, request).toPromise();
}
return <any>Promise.reject(initialError);
});
}
else {
return <any>Promise.reject(initialError);
}
});
}
</code></pre>
<p>In the code above, authService.refreshAuthentication() will fetch the new token and store it in localStorage. authService.setAuthorizationHeader will set the 'Authorization' header to previously updated token. If you look at the catch method, you'll see that it returns a promise (for the refresh token) that in its turns will eventually return another promise (for the actual 2nd try of the request).</p>
<p>I have attempted to do this without resorting to promises:</p>
<pre><code>request(url: string, request: RequestOptionsArgs): Observable<Response> {
var me = this;
request.headers = request.headers || new Headers();
var isSecureCall: boolean = true; //url.toLowerCase().startsWith('https://');
if (isSecureCall === true) {
me.authService.setAuthorizationHeader(request.headers);
}
request.headers.append('Content-Type', 'application/json');
request.headers.append('Accept', 'application/json');
return this.http.request(url, request)
.catch(initialError => {
if (initialError && initialError.status === 401 && isSecureCall === true) {
// token might be expired, try to refresh token
return me.authService.refreshAuthenticationObservable().map((authenticationResult:AuthenticationResult) => {
if (authenticationResult.IsAuthenticated == true) {
// retry with new token
me.authService.setAuthorizationHeader(request.headers);
return this.http.request(url, request);
}
return Observable.throw(initialError);
});
}
else {
return Observable.throw(initialError);
}
});
}
</code></pre>
<p>The code above does not do what i expect: in the case of a 200 response, it properly returns the response. However, if it catches the 401, it will successfully retrieve the new token, but the subscribe wil eventually retrieve an observable instead of the response. Im guessing this is the unexecuted Observable that should do the retry.</p>
<p>I realize that translating the promise way of working onto the rxjs library is probably not the best way to go, but i havent been able to grasp the "everything is a stream" thing. I have tried a few other solutions involving flatmap, retryWhen etc ... but didnt get far, so some help is appreciated.</p>
| <angular><rxjs> | 2016-01-20 17:53:54 | HQ |
34,908,193 | Spotify API: INVALID_APP_ID | <p>I am currently working on an android app which is implementing the Spotify API. I have all of the code connecting my app to spotify using the tutorial and have been working on my app for sometime now. When I play a song through my app after authenticating the user, it works perfectly, that is on my emulator. When I switch it over to my phone it didn't work and gave me an INVALID_APP_ID error in the android response. When I uninstalled spotify off my phone and then tried to login to spotify through my app, I was then able to play music from my phone without any crashes. So my question is how do I fix that? Here is my code for authenticating a user: </p>
<pre><code>@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
// Check if result comes from the correct activity
if (requestCode == requestcode) {
AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);
if (response.getType() == AuthenticationResponse.Type.TOKEN) {
Config playerConfig = new Config(this, response.getAccessToken(), client_id);
token = response.getAccessToken();
Spotify.getPlayer(playerConfig, this, new Player.InitializationObserver() {
@Override
public void onInitialized(Player player) {
mPlayer = player;
mPlayer.addConnectionStateCallback(.this);
mPlayer.addPlayerNotificationCallback(.this);
}
@Override
public void onError(Throwable throwable) {
Log.e("MainActivity", "Could not initialize player: " + throwable.getMessage());
}
});
}
}
}
</code></pre>
| <android><spotify><libspotify> | 2016-01-20 18:55:52 | HQ |
34,908,646 | How to call webservice using ExecutorService | <p><strong>I would like to know the right way to consume a webservice using ExecutorService in java application, I suppose that the webservice call should be parallel and queues but i don't know how to do it.</strong></p>
| <java><multithreading><concurrency><executorservice> | 2016-01-20 19:20:34 | LQ_CLOSE |
34,908,917 | Angular2 Routing redirect with routeParams | <p>Is there a way to access the routerParams in the redirecTo-Statement?</p>
<p>I want to pass the orderId of the 'Order' route to the 'OrderDashboard' route but I can't figure out what to write instead of <code>???</code></p>
<p>If I replace <code>???</code> with <code>3</code> all works fine (in case the user only is intrested in order number 3 ;-) )</p>
<p><code>{path: '/:orderId', name: 'Order', redirectTo: ['OrderDashboard', {orderId:???}]}
{path: '/:orderId/dashboard', name: 'OrderDashboard'}</code></p>
| <angular><angular2-routing> | 2016-01-20 19:33:37 | HQ |
34,909,101 | How can I easily switch between PHP versions on Mac OSX? | <p>I would like to test my application on PHP 5.3 up to PHP 7.0.</p>
<p>Where and how can I install the versions and how can I switch them by running a small script?</p>
| <php><macos> | 2016-01-20 19:44:18 | HQ |
34,909,345 | How to test spring configuration classes? | <p>I have a spring application whith configuration classes where instance the beans.</p>
<p>Aplication class:</p>
<pre><code>@Configuration
@EnableAspectJAutoProxy
@EnableSpringDataWebSupport
@EnableTransactionManagement
@ComponentScan(basePackageClasses = Application.class)
@PropertySource(value = {"classpath:foo.properties"})
@EnableJpaRepositories(basePackageClasses = Application.class)
@EnableJpaAuditing
public class Application {
@Inject
private Environment env;
@Bean
JndiTemplate jndiTemplate() {
return new JndiTemplate();
}
@Bean
public DataSource dataSource() {
DataSource dataSource = getDataSource();
if (dataSource == null) {
dataSource = new BasicDataSource();
((BasicDataSource) dataSource).setUsername(env.getProperty("jdbc.user"));
((BasicDataSource) dataSource).setPassword(env.getProperty("jdbc.password""));
((BasicDataSource) dataSource).setDriverClassName(env.getProperty("jdbc.driverClassName"));
((BasicDataSource) dataSource).setUrl(env.getProperty("jdbc.url"));
}
return dataSource;
}
@Bean
public PlatformTransactionManager transactionManager() {
EntityManagerFactory factory = entityManagerFactory().getObject();
return new JpaTransactionManager(factory);
}
//....
}
</code></pre>
<p>MvcConfiguration class:</p>
<pre><code>@Configuration
@ComponentScan(basePackageClasses = Application.class, includeFilters = @Filter({Controller.class, Component.class}), useDefaultFilters = true)
class MvcConfiguration extends WebMvcConfigurationSupport {
private static final String MESSAGES = "classpath:/i18n";
private static final String VIEW_PREFIX = "/WEB-INF/views/";
@Inject
private Environment env;
@Override
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
RequestMappingHandlerMapping requestMappingHandlerMapping = super.requestMappingHandlerMapping();
requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
requestMappingHandlerMapping.setUseTrailingSlashMatch(true);
return requestMappingHandlerMapping;
}
@Bean(name = "messageSource")
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename(MESSAGES);
messageSource.setCacheSeconds(5);
return messageSource;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/").addResourceLocations("/static/**");
}
@Bean
public MultipartResolver filterMultipartResolver(){
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
resolver.setMaxUploadSize(Long.parseLong(env.getProperty("multipart.max.size")));
return resolver;
}
//....
}
</code></pre>
<p>And SecurityConfiguration class:</p>
<pre><code>@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
//....
@Override
protected void configure(HttpSecurity http) throws Exception {
//Logout por POST con el valor de token csrf
http.authorizeRequests()
.antMatchers("/static/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.failureUrl("/login?error=1")
.loginProcessingUrl("/authenticate")
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/signin")
.permitAll();
}
}
</code></pre>
<p>How I can test them with JUnit? How to test the beans are created in the spring context?</p>
| <java><spring><spring-mvc><junit> | 2016-01-20 19:57:44 | HQ |
34,909,972 | Converting 13 decimals to datetime C++ | I have a project about cars with GPS. I need to return the start and the finish moment for each car. Please help me!
So we have :
time_t x, y;
Because I will use later them for a transformation.
I have a problem! I read from an external file data in this format:
auto1
1439467747492
auto1
1439467748512
......etc.
auto1->name of the car; 1439467747492->the moment in time of the car
I tried to get the first position of the first moment and the last moment for each car. This is the code in C++:
void raportDistanta(/**/, long long momenti[], long long momentf[])
n=m=1;
if (g.is_open())
{
//momenti,momentf---arrays type long long because a moment has 13 digits
//momenti=saves the start moments for each car
//momentf=saves the final moments for each car
momenti[n++] = a[0].getMoment();
for (i = 0; i < nr - 1; i++)
{
if (strcmp(a[i].getnume(), a[i + 1].getnume()) == 0)
{
//here i try to get the distance between two points. The car in the moment i and i+1
// I failed doing that...I don't transform the latitude and longitude properly and I get bad numbers. anyway....
}
else
{ //Here I put
momenti[n++] = a[i + 1].getMoment();
momentf[m++] = a[i].getMoment();
}
}
momentf[m++] = a[nr1].getMoment();
After this i do in main something like that:
**
x = momenti[choice1] / 1000;
y = momentf[choice1] / 1000;
cout << " Moment i:\n " << ctime(&x) << " Moment final: \n" << ctime(&y) << endl;
I receive the same date for every car. Is something like momenti[i]=momentf[i]
What I did wrong? Thanks! | <c++><class><decimal><ctime> | 2016-01-20 20:34:32 | LQ_EDIT |
34,910,435 | Is there a way to prevent fastclick from firing “active” state on scroll? | <p>I’m using <a href="https://github.com/ftlabs/fastclick">FastClick</a> on a page with large links because I want to bypass the 300ms delay for taps in mobile browsers. I have a “highlight” style for the links’ <code>:active</code> states and it is properly firing quickly, thanks to FastClick.</p>
<p>My problem is that – in Mobile Safari at least – it also fires while you’re tapping and swiping to scroll the page. This makes it feel like you can’t scroll the page without it thinking you’re trying to tap the links.</p>
<p>Is there a way to prevent it from firing when someone scrolls?</p>
| <javascript><css><mobile-safari><fastclick.js><fastclick> | 2016-01-20 21:01:45 | HQ |
34,910,638 | looping over AWK commands doesn't work | <p>I have a huge dictionary file that contains each word in each line, and would like to split the files by the first character of the words. </p>
<p>a.txt --> only contains the words that start with a</p>
<p>I used this awk commands to successfully extract words that start with b.</p>
<pre><code> awk 'tolower($0)~/^b/{print}' titles-sorted.txt > b.txt
</code></pre>
<p>Now I wanted to iterate this for all alphabets</p>
<pre><code> for alphabet in {a..z}
do
awk 'tolower($0)~/^alphabet/{print}' titles-sorted.txt > titles-links/^alphabet.txt
done
</code></pre>
<p>But the result files contain no contents. What did I do wrong? I don't even know how to debug this. Thanks! </p>
| <bash><awk> | 2016-01-20 21:13:14 | LQ_CLOSE |
34,911,181 | How to undo setting Elasticsearch Index to readonly? | <p>So I just set one of my indices to readonly, and now want to delete it.</p>
<p>To set it to readonly:</p>
<pre><code>PUT my_index/_settings
{ "index": { "index.blocks.read_only" : true } }
</code></pre>
<p>When I tried to delete it I got this response:</p>
<pre><code>ClusterBlockException[blocked by: [FORBIDDEN/5/index read-only (api)];]
</code></pre>
<p>Then I tried to set the index to readonly false:</p>
<pre><code>PUT my_index/_settings
{ "index": { "index.blocks.read_only" : false } }
</code></pre>
<p>But that gives the same error message as above. So how to set readonly back to false?</p>
| <elasticsearch> | 2016-01-20 21:43:04 | HQ |
34,911,474 | django aggregation: sum then average | <p>Using django's ORM annotate() and/or aggregate(): I want to sum up based on one category field and then average over the category values per date. I tried to do it using two annotate() statements but got a FieldError.</p>
<p>I'm doing this: </p>
<pre><code>queryset1 = self.data.values('date', 'category').annotate(sum_for_field=Sum('category'))
</code></pre>
<p>Which outputs a ValuesQuerySet object with things like (so a sum for each value of category):</p>
<pre><code>[{'category': 'apples', 'date': '2015-10-12', sum_for_field=2000},
{'category': 'carrots', 'date': '2015-10-12', sum_for_field=5000},
{'category': 'apples', 'date': '2015-10-13', sum_for_field=3000},
{'category': 'carrots', 'date': '2015-10-13', sum_for_field=6000}, ...
]
</code></pre>
<p>I then want to average the sum_for_field field for each date to output something like:</p>
<pre><code>[ {'date': '2015-10-12', avg_final: 3500},
{'date': '2015-10-13', avg_final: 4500}, ...
]
</code></pre>
<p>I tried doing this:</p>
<pre><code>queryset2 = queryset1.values('date', 'sum_for_field')
result = queryset2.annotate(avg_final=Avg('sum_for_field'))
</code></pre>
<p>But I got this FieldError: </p>
<pre><code>FieldError: FieldError: Cannot compute Avg('sum_for_field'): 'sum_for_field' is an aggregate
</code></pre>
| <python><django><orm> | 2016-01-20 22:01:11 | HQ |
34,912,099 | Limited number of tires to a simple game? | How would I limit the tries of a simple game to just three? I would think you would use a boolean. But not sure.
import java.util.Scanner;
public class guess {
public static void main(String[] args) {
int randomN = (int) (Math.random() * 10) + 1;
Scanner input = new Scanner(System.in);
int guess;
System.out.println("Enter a number between 1 and 10.");
System.out.println();
do {
System.out.print("Enter your guess: ");
guess = input.nextInt();
if (guess == randomN) {
System.out.println("You won!");
} else if (guess > randomN) {
System.out.println("Too high");
} else if (guess < randomN) {
System.out.println("Too low");
}
} while (guess != randomN);
}
} | <java><boolean><java.util.scanner> | 2016-01-20 22:46:05 | LQ_EDIT |
34,912,156 | AStudio issue #66894 | <p>In the middle of development it threw an error at me complaining about gradle plugin being too old (was 2.0.0-alpha3, changed to 2.0.0-alpha5 and worked. Hurrah!). Then it complained about <code>distributionUrl</code> pointing to an also outdated piece of software. I have Overcome that as well. Now google nailed me with </p>
<pre><code> Error:Execution failed for task ':app:buildInfoDebugLoader'.
> Exception while loading build-info.xml : null
</code></pre>
<p>Invalidate + restart didnt do the trick. What next ?</p>
| <android-studio> | 2016-01-20 22:49:21 | HQ |
34,912,265 | Eloquent get only one column as an array | <p>How to get only one column as one dimentional array in laravel 5.2 using eloquent?</p>
<p>I have tried: </p>
<pre><code>$array = Word_relation::select('word_two')->where('word_one', $word_id)->get()->toArray();
</code></pre>
<p>but this one gives it as 2 dimentional array like:</p>
<pre><code>array(2) {
[0]=>
array(1) {
["word_one"]=>
int(2)
}
[1]=>
array(1) {
["word_one"]=>
int(3)
}
}
</code></pre>
<p>but I want to get it as:</p>
<pre><code>array(2) {
[0]=>2
[1]=>3
}
</code></pre>
| <laravel><eloquent><laravel-5.2> | 2016-01-20 22:58:19 | HQ |
34,912,673 | Java Error invalid start | So I'm trying to get my display method to work...
private static displayResults(String gender,int age,String rateResult);
{
System.out.Println("Thank you");
System.out.println("the "+ gender + " is " + age + " years old.");
System.out.println("the rate class is: " + rateResult);
}
**My Error____ ps/ took out string but i get the same error.... what am i missing??**
RentalRates.java:163: error: illegal start of expression
private static String displayResults(gender,int age,rateResult);
^
RentalRates.java:163: error: illegal start of expression
private static String displayResults(gender,int age,rateResult);
^
RentalRates.java:163: error: ';' expected
private static String displayResults(gender,int age,rateResult);
^
RentalRates.java:163: error: '.class' expected
private static String displayResults(gender,int age,rateResult);
^
RentalRates.java:163: error: ';' expected
private static String displayResults(gender,int age,rateResult);
^
RentalRates.java:163: error: not a statement
private static String displayResults(gender,int age,rateResult);
^
RentalRates.java:163: error: ';' expected
private static String displayResults(gender,int age,rateResult);
^
RentalRates.java:169: error: reached end of file while parsing
} | <java> | 2016-01-20 23:30:12 | LQ_EDIT |
34,913,078 | Importing and changing variables from another file | <p>Okay...</p>
<p>I have searched and searched looking for an answer that directly answers my question, but have had no success. My problem is pretty straight forward and I honestly thought there would have been a more direct answer out there. Please keep in mind I am still relatively new to the language, and am still learning.</p>
<p><em>So I will use <code>fileA</code> and <code>fileB</code> as my two files, and <code>x</code> as my example variable.</em> Variable <code>x</code> is contained in <code>fileB</code>. How do I go about importing variable <code>x</code> into <code>fileA</code>, <strong>then</strong> change <code>x</code> to another value via <code>raw_input</code>, <strong>and then</strong> have the variable <code>x</code> update in <code>fileB</code> with the new value?</p>
<p>I'm not sure if this is even possible, but I would sure like to think so. I am using python 2.7.11, thank you in advanced.</p>
| <python><python-2.7><variables> | 2016-01-21 00:07:21 | HQ |
34,913,087 | Hangman Assignment: Need help revealing the secret word | <p>I have a school assignment and in hangman you reveal the word slowly as the user guesses and I am having trouble with that.</p>
<p><strong>For example, this is what I want (ex. applesauce):</strong></p>
<p>guess: 'a'</p>
<p>display: 'a*****a***'</p>
<p>guess: 'p'</p>
<p>display: 'app***a***'</p>
<p><strong>This is what I currently have:</strong></p>
<p>guess: 'a'</p>
<p>display: 'a*****a***'</p>
<p>guess: 'p'</p>
<p>display: '*pp*******'</p>
<p><strong>Here is my code if it helps:</strong></p>
<pre><code>import java.util.Scanner;
import java.util.Random;
public class HangmanAssignment
{
static Scanner numIn = new Scanner(System.in);
static Scanner strIn = new Scanner(System.in);
// Used to hold the user's previous guesses into a string.
static StringBuffer buffer = new StringBuffer();
public static void main(String[] args)
{
String category;
int wordLength;
int position;
int lettersRemaining;
int totalLives = 10;
boolean isGuessInWord;
StringBuffer prevGuessedLetters;
String word;
String displayWord = "";
char guess;
category = getCategory();
word = getWord(category);
// Gets the length of the word.
wordLength = word.length();
lettersRemaining = wordLength;
System.out.println("The length of your word is: " + wordLength + " characters.");
// Generates as many '*' as long as word's length and stores it in 'displayWord'.
for (int i = 0; i < wordLength; i++)
{
displayWord += "-";
// System.out.println(displayWord); /* Testing */
}
while (lettersRemaining > 0 && totalLives > 0)
{
// Prompts user to guess a letter.
System.out.println("Guess a letter (Note: there are " + wordLength + " letters)");
guess = strIn.findWithinHorizon(".", 0).charAt(0);
// Checks if the letter guessed in within 'word'.
isGuessInWord = (word.indexOf(guess)) != -1;
// Checks if the guess is in within 'word'.
if (isGuessInWord == false)
{
totalLives--;
System.out.println("Sorry, but '" + guess + "' was not in the word.");
if (totalLives < 1)
{
System.out.println("It seems like you have no lives left! :(");
}
else if (totalLives == 1)
{
System.out.println("Careful! You only have 1 life left!");
}
else
{
System.out.println("You still have " + (totalLives) + " lives left!");
}
}
else
{
System.out.println("Nice one! The letter '" + guess + "' was in the word!");
for (position = 0; position < wordLength; position++)
{
String newDisplayWord = "";
for (position = 0; position < wordLength; position++)
{
if (word.charAt(position) == guess)
{
/* displayWord.charAt(position).equals(word.charAt(position)); */
System.out.print(guess);
lettersRemaining--;
}
else
{
System.out.print("*");
}
}
}
}
// Holds the user's previously guessed letters and the number of letters in the word that are still unknown.
System.out.println();
prevGuessedLetters = buffer.append(guess);
System.out.println("Previously guessed letters: " + (prevGuessedLetters));
System.out.println("Letters remaining: " + (lettersRemaining));
System.out.println("");
// Checks win/lose conditions.
if (lettersRemaining == 0)
{
System.out.println("Congratulations, '" + word + "' was the correct answer!");
}
if (totalLives < 1)
{
System.out.println("Sorry, you lose!");
System.out.println("The correct answer was '" + word + "'.");
{
break;
}
}
}
}
public static String getCategory()
{
String category;
System.out.println("=====================================");
System.out.println("Welcome to the Hangman Game!");
System.out.println("=====================================");
while (true)
{
System.out.println("Choose from the following categories:");
System.out.println("1. Car Brands");
System.out.println("2. Countries");
System.out.println("3. Animals");
System.out.println("4. Fruit");
System.out.println("");
category = strIn.nextLine();
if (category.toLowerCase().equals("1") || (category.toLowerCase().equals("one")))
{
category = "car brands";
}
else if (category.toLowerCase().equals("2") || (category.toLowerCase().equals("two")))
{
category = "countries";
}
else if (category.toLowerCase().equals("3") || (category.toLowerCase().equals("three")))
{
category = "animals";
}
else if (category.toLowerCase().equals("4") || (category.toLowerCase().equals("four")))
{
category = "fruit";
}
if (category.toLowerCase().equals("car brands") || category.toLowerCase().equals("countries") || category.toLowerCase().equals("animals") || category.toLowerCase().equals("fruit"))
{
System.out.println("");
System.out.println("Nice Choice! You have chosen the '" + category + "' category!");
System.out.println("");
break;
}
else
{
System.out.println("Sorry, but '" + category + "' is not a valid input. Try Again!");
System.out.println("");
}
}
return category;
}
public static String getWord(String category)
{
String[] carBrandsWord = {"toyota", "ferrari", "honda", "hyundai", "lamborghini", "dodge", "ford", "chevrolet", "fiat", "lexus", "volkswagen", "acura", "audi", "bentley", "bugatti", "buick", "cadillac"};
String[] countriesWord = {"canada", "england", "france", "switzerland", "australia", "sweden", "greece", "italy", "mexico", "brazil", "india", "china", "russia", "japan", "spain", "ireland"};
String[] animalsWord = {"cat", "dog", "parrot", "bear", "tiger", "monkey", "zebra", "hippopotamus", "chicken", "horse", "cow", "starfish", "squid", "wolf", "hyena", "cheetah", "penguin"};
String[] fruitsWord = {"apple", "banana", "orange", "grapes", "grapefruit", "apricot", "cherry", "guava", "kiwi", "mango", "melon", "olive", "pineapple", "strawberry", "watermelon"};
String word = "";
if (category.toLowerCase().equals("car brands"))
{
Random random = new Random();
int index = random.nextInt(carBrandsWord.length);
word = (carBrandsWord[index]);
}
else if (category.toLowerCase().equals("countries"))
{
Random random = new Random();
int index = random.nextInt(countriesWord.length);
word = (countriesWord[index]);
}
else if (category.toLowerCase().equals("animals"))
{
Random random = new Random();
int index = random.nextInt(animalsWord.length);
word = (animalsWord[index]);
}
else
{
Random random = new Random();
int index = random.nextInt(fruitsWord.length);
word = (fruitsWord[index]);
}
return word;
}
}
</code></pre>
| <java> | 2016-01-21 00:08:45 | LQ_CLOSE |
34,913,177 | Command Line Git Problems | <p>I'm not fully understanding git. I have a repository on github.com which I checkout by cloning. Then I add a file called index.html and commit via command line. Then nothing happens on github.com. I cannot see the new file updating nor do I see any of the new branches I create. What am I doing wrong?</p>
| <git><shell><github><command> | 2016-01-21 00:17:01 | LQ_CLOSE |
34,913,328 | All MySQL records from yesterday | <p>What is the most efficient way to get all records with a datetime field that falls somewhere between yesterday at <code>00:00:00</code> and yesterday at <code>23:59:59</code>?</p>
<p>Table:</p>
<pre><code>id created_at
1 2016-01-19 20:03:00
2 2016-01-19 11:12:05
3 2016-01-20 03:04:01
</code></pre>
<p>Suppose yesterday was 2016-01-19, then in this case all I'd want to return is rows 1 and 2.</p>
| <mysql><datetime> | 2016-01-21 00:33:19 | HQ |
34,913,840 | Best practice for connecting to a vpn though docker | <p>Some apps we have depend on being connected to our VPN to connect to different (not-yet dockerized)solutions. </p>
<p>What is the 'docker way' of doing this? In my mind adding OpenVPN to an existing image is against the docker philosophy. </p>
<p>From where I'm standing I feel that creating a docker VPN client container makes the most sense. But what would that look like? I use docker compose, so there would definitely be a </p>
<pre><code>myContainer
- links: myVPNClient
</code></pre>
<p>but would I then have to forward ports? Or what would have to happen to enable <code>myContainer</code> to connect <strong>through</strong> the openVPN container. </p>
| <docker><docker-compose><openvpn> | 2016-01-21 01:31:37 | HQ |
34,913,956 | Looking for a light-weight cross-platform C threading library | <p>I wanted to use OpenMP for this, but it is not appropriate for my purposes: creating my own thread pool.</p>
<p>So, this needs to be C89 code with, of course, platform specific code for windows and unices.</p>
<p>I need this for a C only library, so no C++, boost C++11, etc.</p>
<p>Thanks!</p>
| <c><multithreading> | 2016-01-21 01:43:46 | LQ_CLOSE |
34,914,572 | How to get data submitted from HTML form that insert into redis database use Rust lang? | I have problem get data from HTML form store value into redis database when user submit. Use Nickel web framework, this is code:
fn save_db<'a>(req: &mut Request, res: Response<'a>) -> MiddlewareResult<'a>{
let mut server = Nickel::new();
/* FIXME: connect redis*/
let client = Client::open("redis://127.0.0.1/").unwrap();
let conn = client.get_connection().unwrap();
server.post("/confirmation", middleware!{|req, res|
let mut form_data = String::new();
req.origin.read_to_string(&mut form_data).unwrap();
let _: ()= conn.set("contents",form_data).unwrap();
println!("{}", form_data);
let mut data = HashMap::<&str,String>::new();
data.insert("content", form_data);
data.insert("page_title", "Save blog data".to_string());
return res.render("app/views/blog/save.tpl", &data);
});
}
//error: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements [E0495](req.origin.read_to_string(&mut form_data).unwrap();) | <rust><lifetime> | 2016-01-21 02:52:18 | LQ_EDIT |
34,914,843 | What is the difference between continuous integration, continuous delivery and DevOps? | <p>I hear these terms together and wonder what is the difference? How are they related to continuous builds and continuous deployments?</p>
| <continuous-integration><devops><continuous-delivery> | 2016-01-21 03:22:45 | HQ |
34,915,003 | How can I add an object to an arraylist of objects | <p>The purpose is to add teams to an arraylist. Each team is an object with a String name, String division, int wins, and int losses. </p>
<pre><code>import java.util.ArrayList;
import java.util.Arrays;
public class Default
{
ArrayList<team> teams = new ArrayList<team>();
team Mavericks = new team("Mavericks","Southwest",50,32);
team Rockets = new team("Rockets","Southwest",56,26);
team Grizzlies = new team("Memphis","Southwest",55,27);
teams.add(team Mavericks);
teams.add(team Rockets);
teams.add(team Grizzlies);
}
class team
{
String name, division;
int win,loss;
public team(String n,String d, int w, int l)
{
this.name = n;
this.division = d;
this.win = w;
this.loss = l;
}
}
</code></pre>
| <java><arraylist> | 2016-01-21 03:41:38 | LQ_CLOSE |
34,915,140 | Translate my website content | <p>Guys I know that this question asked before but its not the same.</p>
<p>I have a website that I want to translate its content.</p>
<p><strong>What I came up with:</strong></p>
<p>1-gettext //its not good for me</p>
<p>2-google api //google translate is very bad and also google add its name in my wbesite</p>
<p>3-make another files with different language.</p>
<p>I prefer the last one because I only want my website to be English and Arabic.</p>
<p>Any more solutions? and what disadvantages of making the third solution ?</p>
<p>thanks</p>
| <php><html><translation> | 2016-01-21 03:56:25 | LQ_CLOSE |
34,915,276 | UWP ObservableCollection sorting and grouping | <p>In UWP apps, how can you group and sort an ObservableCollection and keep all the live notification goodness? </p>
<p>In most simple UWP examples I've seen, there is generally a ViewModel that exposes an ObservableCollection which is then bound to a ListView in the View.
When items are added or removed from the ObservableCollection, the ListView automatically reflects the changes by reacting to the INotifyCollectionChanged notifications. This all works fine in the case of an unsorted or ungrouped ObservableCollection, but if the collection needs to be sorted or grouped, there seems to be no readily apparent way to preserve the update notifications. What's more, changing the sort or group order on the fly seems to throw up significant implementation issues.</p>
<p>++ </p>
<p>Take a scenario where you have an existing datacache backend that exposes an ObservableCollection of very simple class Contact.</p>
<pre><code>public class Contact
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string State { get; set; }
}
</code></pre>
<p>This ObservableCollection changes over time, and we want to present a realtime grouped and sorted list in the view that updates
in response to changes in the datacache. We also want to give the user the option to switch the grouping between LastName and State on the fly.</p>
<p>++</p>
<p>In a WPF world, this is relatively trivial.
We can create a simple ViewModel referencing the datacache that presents the cache's Contacts collection as-is.</p>
<pre><code>public class WpfViewModel
{
public WpfViewModel()
{
_cache = GetCache();
}
Cache _cache;
public ObservableCollection<Contact> Contacts
{
get { return _cache.Contacts; }
}
}
</code></pre>
<p>Then we can bind this to a view where we implement a CollectionViewSource and Sort and Group definitions as XAML resources.</p>
<pre><code><Window .....
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase">
<Window.DataContext>
<local:WpfViewModel />
</Window.DataContext>
<Window.Resources>
<CollectionViewSource x:Key="cvs" Source="{Binding Contacts}" />
<PropertyGroupDescription x:Key="stategroup" PropertyName="State" />
<PropertyGroupDescription x:Key="initialgroup" PropertyName="LastName[0]" />
<scm:SortDescription x:Key="statesort" PropertyName="State" Direction="Ascending" />
<scm:SortDescription x:Key="lastsort" PropertyName="LastName" Direction="Ascending" />
<scm:SortDescription x:Key="firstsort" PropertyName="FirstName" Direction="Ascending" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView ItemsSource="{Binding Source={StaticResource cvs}}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding LastName}" />
<TextBlock Text="{Binding FirstName}" Grid.Column="1" />
<TextBlock Text="{Binding State}" Grid.Column="2" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Background="Gainsboro">
<TextBlock FontWeight="Bold"
FontSize="14"
Margin="10,2"
Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<Button Content="Group By Initial" Click="InitialGroupClick" />
<Button Content="Group By State" Click="StateGroupClick" />
</StackPanel>
</Grid>
</Window>
</code></pre>
<p>Then when the user clicks on the GroupBy buttons at the bottom of the window we can we can group and sort on the fly in code-behind.</p>
<pre><code>private void InitialGroupClick(object sender, RoutedEventArgs e)
{
var cvs = FindResource("cvs") as CollectionViewSource;
var initialGroup = (PropertyGroupDescription)FindResource("initialgroup");
var firstSort = (SortDescription)FindResource("firstsort");
var lastSort = (SortDescription)FindResource("lastsort");
using (cvs.DeferRefresh())
{
cvs.GroupDescriptions.Clear();
cvs.SortDescriptions.Clear();
cvs.GroupDescriptions.Add(initialGroup);
cvs.SortDescriptions.Add(lastSort);
cvs.SortDescriptions.Add(firstSort);
}
}
private void StateGroupClick(object sender, RoutedEventArgs e)
{
var cvs = FindResource("cvs") as CollectionViewSource;
var stateGroup = (PropertyGroupDescription)FindResource("stategroup");
var stateSort = (SortDescription)FindResource("statesort");
var lastSort = (SortDescription)FindResource("lastsort");
var firstSort = (SortDescription)FindResource("firstsort");
using (cvs.DeferRefresh())
{
cvs.GroupDescriptions.Clear();
cvs.SortDescriptions.Clear();
cvs.GroupDescriptions.Add(stateGroup);
cvs.SortDescriptions.Add(stateSort);
cvs.SortDescriptions.Add(lastSort);
cvs.SortDescriptions.Add(firstSort);
}
}
</code></pre>
<p>This all works fine, and the items are updated automatically as the data cache collection changes. The Listview grouping and selection remains unaffected by collection changes, and the new contact items are correctly grouped.The grouping can be swapped between State and LastName initial by user at runtime.</p>
<p>++</p>
<p>In the UWP world, the CollectionViewSource no longer has the GroupDescriptions and SortDescriptions collections, and sorting/grouping need to be carried out at the ViewModel level. The closest approach to a workable solution I've found is along the lines of Microsoft's sample package at</p>
<p><a href="https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlListView" rel="noreferrer">https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlListView</a></p>
<p>and this article</p>
<p><a href="http://motzcod.es/post/94643411707/enhancing-xamarinforms-listview-with-grouping" rel="noreferrer">http://motzcod.es/post/94643411707/enhancing-xamarinforms-listview-with-grouping</a></p>
<p>where the ViewModel groups the ObservableCollection using Linq and presents it to the view as an ObservableCollection of grouped items</p>
<pre><code>public ObservableCollection<GroupInfoList> GroupedContacts
{
ObservableCollection<GroupInfoList> groups = new ObservableCollection<GroupInfoList>();
var query = from item in _cache.Contacts
group item by item.LastName[0] into g
orderby g.Key
select new { GroupName = g.Key, Items = g };
foreach (var g in query)
{
GroupInfoList info = new GroupInfoList();
info.Key = g.GroupName;
foreach (var item in g.Items)
{
info.Add(item);
}
groups.Add(info);
}
return groups;
}
</code></pre>
<p>where GroupInfoList is defined as </p>
<pre><code>public class GroupInfoList : List<object>
{
public object Key { get; set; }
}
</code></pre>
<p>This does at least get us a grouped collection displayed in the View, but updates to the datacache collection are no longer reflected in real time. We could capture the datacache's CollectionChanged event and use it in the viewmodel to refresh the GroupedContacts collection, but this creates a new collection for every change in the datacache, causing the ListView to flicker and reset selection etc which is clearly suboptimal.</p>
<p>Also swapping the grouping on the fly would seem to require a completely seperate ObservableCollection of grouped items for each grouping scenario, and for the ListView's ItemSource binding to be swapped at runtime.</p>
<p>The rest of what I've seen of the UWP environment seems extremely useful, so I'm surprised to find something as vital as grouping and sorting lists throwing up obstacles...</p>
<p>Anyone know how to do this properly?</p>
| <c#><sorting><listview><win-universal-app><uwp> | 2016-01-21 04:10:41 | HQ |
34,915,585 | Message: session_start(): Cannot send session cache limiter - headers already sent | <p>Having a problem with sessions which is becoming very annoying. Every time I try to start a session on a particular page I get the following error:</p>
<p>Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/uplbcdcn/public_html/CDC/admin_uplbcdc/header.php:57) in /home/uplbcdcn/public_html/CDC/admin_uplbcdc/index.php on line 33</p>
<p>Warning: Cannot modify header information - headers already sent by (output started at /home/uplbcdcn/public_html/CDC/admin_uplbcdc/header.php:57) in /home/uplbcdcn/public_html/CDC/admin_uplbcdc/index.php on line 42</p>
<p>Here is the Code: header.php</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>UPLB Credit and Development Cooperative</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="../css/bootstrap.css" rel="stylesheet" media="screen">
<link href="../css/bootstrap-responsive.css" rel="stylesheet" media="screen">
<link href="../css/docs.css" rel="stylesheet" media="screen">
<link href="../css/diapo.css" rel="stylesheet" media="screen">
<link href="../css/font-awesome.css" rel="stylesheet" media="screen">
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<link rel="stylesheet" type="text/css" href="../css/DT_bootstrap.css" />
<link rel="stylesheet" type="text/css" media="print" href="../css/print.css" />
<!-- js -->
<script src="../js/jquery-1.7.2.min.js"></script>
<script src="../js/bootstrap.js"></script>
<script src="../js/jquery.hoverdir.js"></script>
<script>
jQuery(document).ready(function() {
$(function(){
$('.pix_diapo').diapo();
});
});
</script>
<noscript>
<style>
.da-thumbs li a div {
top: 0px;
left: -100%;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.da-thumbs li a:hover div{
left: 0px;
}
</style>
</noscript>
<script type="text/javascript" charset="utf-8" language="javascript" src="../js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8" language="javascript" src="../js/DT_bootstrap.js"></script>
<script type='text/javascript' src='../scripts/jquery.easing.1.3.js'></script>
<script type='text/javascript' src='../scripts/jquery.hoverIntent.minified.js'></script>
<script type='text/javascript' src='../scripts/diapo.js'></script>
<!--sa calendar-->
<script type="text/javascript" src="../js/datepicker.js"></script>
<link href="../css/datepicker.css" rel="stylesheet" type="text/css" />
</head>
<?php include('dbcon.php'); ?>
<body>
index.php
<?php include('header.php'); ?>
<?php include('navbar.php'); ?>
<div class="container">
<div class="margin-top">
<div class="row">
<div class="span12">
<div class="login">
<div class="log_txt">
<p><strong>Please Enter the Details Below..</strong></p>
</div>
<form class="form-horizontal" method="POST">
<div class="control-group">
<label class="control-label" for="inputEmail">Username</label>
<div class="controls">
<input type="text" name="username" id="username" placeholder="Username" required>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password</label>
<div class="controls">
<input type="password" name="password" id="password" placeholder="Password" required>
</div>
</div>
<div class="control-group">
<div class="controls">
<button id="login" name="submit" type="submit" class="btn"><i class="icon-signin icon-large"></i>&nbsp;Submit</button>
</div>
</div>
<?php
if (isset($_POST['submit'])){
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
mysqli_select_db($dbcon,$database_dbcon);
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysqli_query($dbcon,$query)or die(mysqli_error());
$num_row = mysqli_num_rows($result);
$row=mysqli_fetch_array($result);
if( $num_row > 0 ) {
header('location:dashboard.php');
$_SESSION['id']=$row['user_id'];
}
else{ ?>
<div class="alert alert-danger">Access Denied</div>
<?php
}}
?>
</form>
</div>
</div>
</div>
</div>
</div>
<?php include('footer.php') ?>
</code></pre>
| <php><session> | 2016-01-21 04:46:21 | LQ_CLOSE |
34,915,869 | Example of Big O of 2^n | <p>So I can picture what an algorithm is that has a complexity of n^c, just the number of nested for loops. </p>
<pre><code>for (var i = 0; i < dataset.len; i++ {
for (var j = 0; j < dataset.len; j++) {
//do stuff with i and j
}
}
</code></pre>
<p>Log is something that splits the data set in half every time, binary search does this (not entirely sure what code for this looks like). </p>
<p>But what is a simple example of an algorithm that is c^n or more specifically 2^n. Is O(2^n) based on loops through data? Or how data is split? Or something else entirely?</p>
| <algorithm><big-o><time-complexity> | 2016-01-21 05:14:29 | HQ |
34,915,886 | Editing locked files from a CocoaPods framework | <p>I have an Xcode workspace that uses CocoaPods to include several third-party frameworks. I would like to edit a line of source code within one of these dependencies. However, when I do so, Xcode warns me that the file is locked and that any changes I make may not be saved. So my question is: will my changes to the source code be discarded when I run a pod install/update? If not, is there any other scenario, possibly unrelated to CocoaPods, that would discard my changes? And finally, is there any good way that I can edit the source code without running into such problems?</p>
<p>Thanks in advance.</p>
| <ios><xcode><dependencies><cocoapods> | 2016-01-21 05:15:41 | HQ |
34,916,703 | How to Identify maven archtype? | I have an existing maven project for java services So is there any way to identify archetype from pom file or is there any way?
The folder structure for this project is:
src/test/java
src/main/java
src/main/resource
And it has "Referenced Libraries" not "Maven Dependencies".
Can anyone please let me know which archetype was selected from the list maven archetypes. | <java><eclipse><maven><maven-2> | 2016-01-21 06:22:32 | LQ_EDIT |
34,917,203 | How to divide the web page in different segment.? | <p>Hi Currently i am working in web project. There it self i am designing a website for mobile device. Here i want to know behalf of what i can use pixel for footer,header.And what is default height and width for mobile device.
Here some sample code is there</p>
<pre><code> <body>
<div id="header">
<h1>Books Gallery</h1>
</div>
<div id="footer">
**Copyright © 2016*
</div>
</body>
</code></pre>
| <java><html><css> | 2016-01-21 06:55:03 | LQ_CLOSE |
34,917,349 | Is there a way to put quotes in a cout? | <p>I was trying to make a simple calculator and I would like to display quotes in the instruction when you first run the program. </p>
| <c++> | 2016-01-21 07:05:21 | LQ_CLOSE |
34,918,025 | How to restart Postgresql | <p>I have Postgresql 9.3 and 9.4 installed on my Linux Mint machine. How can I restart postgresql 9.4? A method to restart both versions together is also fine. </p>
| <postgresql><linux-mint> | 2016-01-21 07:46:00 | HQ |
34,918,057 | What is the faster WebService to use for my android app? | <p>I am new in android i need to start a new project that consume a web Service. I need to know what language to use to develop a very fast web service to consume in my android app?</p>
| <android><android-webservice> | 2016-01-21 07:48:18 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.