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 |
|---|---|---|---|---|---|
37,763,252 | Custom Styling on <ng-content> in angular2 not working ? | <p>I am trying to style <code><ng-content></code> using inline css but seems style does't work on ng-content, i have to do something else for styling ? </p>
<pre><code><ng-content class="red"></ng-content> <p class="red">hello</p>
</code></pre>
<p>here class red works on <code>p</code> but not on </p>
<p><kbd><a href="https://plnkr.co/edit/srE5pcQS3nJIKJFSxto4?p=preview" rel="noreferrer">Working Example</a></kbd></p>
| <angular> | 2016-06-11 11:35:40 | HQ |
37,764,466 | how can I retrieve values from Nsmutable array having object with multiple values | I am beginner in objective-c/IOS development,
I have an NsMutablearray that has say 4 objects, and each object has further elements in it, I Want to retrieve those elements i.e.
Object at index 0 has 15 values( Ns strings) same is for rest of the 3 objects
I don't know the syntax of how can I read the values below syntax I have tried gives me error
for(int i=0;i<[array count]; i++)
{
for (int j=0;j<[array[i] count]; j++)
{
/// reading code here
}
} | <objective-c> | 2016-06-11 13:46:12 | LQ_EDIT |
37,764,888 | i get error while i build my solution | i have an architecture i which i have so many layers and project.Generally i get a common error while i build my solution and i really don't get why i am getting this error.i have attached my architecture image and error image.please help me if anyone knows about this error and h[![enter image description here][1]][1]ow to get rid off this error.
[![enter image description here][2]][2]
[1]: http://i.stack.imgur.com/JIaKw.png
[2]: http://i.stack.imgur.com/9TiAk.png | <.net><asp.net-mvc><visual-studio> | 2016-06-11 14:30:58 | LQ_EDIT |
37,765,197 | Darken or lighten a color in matplotlib | <p>Say I have a color in Matplotlib. Maybe it's a string (<code>'k'</code>) or an rgb tuple (<code>(0.5, 0.1, 0.8)</code>) or even some hex (<code>#05FA2B</code>). Is there a command / convenience function in Matplotlib that would allow me to darken (or lighten) that color. </p>
<p>I.e. is there <code>matplotlib.pyplot.darken(c, 0.1)</code> or something like that? I guess what I'm hoping for is something that, behind the scenes, would take a color, convert it to HSL, then either multiply the L value by some given factor (flooring at 0 and capping at 1) or explicitly set the L value to a given value and return the modified color.</p>
| <python><matplotlib><colors> | 2016-06-11 15:06:02 | HQ |
37,765,456 | PHP password_hash changing every time | <p>I have the code</p>
<pre><code> echo password_hash( 'i=badatphp', PASSWORD_BCRYPT, [ 'cost' => 10 ] );
</code></pre>
<p>Every time I run the script the password changes</p>
<p>I'm using PHP 7, and in PHP 5 I used to be able to set a salt, but now I can't</p>
<p>How am I supposed to overcome not knowing what the salt is?</p>
| <php><passwords><php-password-hash> | 2016-06-11 15:30:44 | LQ_CLOSE |
37,766,199 | Creating array of int from array of objects using lodash | <p>I have this array of objects:</p>
<pre><code>this.clients=[{firstName:"Tywin", lastName:"Lannister", age:46, id:2},
{firstName:"Arya", lastName:"Starck", age:46, id:-1},
{firstName:"John", lastName:"Snow", age:46, id:12},
{firstName:"Robb", lastName:"Starck", age:46, id:24}];
</code></pre>
<p>And this variable:</p>
<pre><code>var idArr;
</code></pre>
<p>I need to iterate threw all objects in array and get all id's and create array from them.Like that:</p>
<pre><code>idArr = [2,-1,12,24]
</code></pre>
<p>How can I implement it using lodash?</p>
| <javascript><lodash> | 2016-06-11 16:44:56 | LQ_CLOSE |
37,766,579 | Check two location(latitude, longlatitude) near in 2000 meters | <p>I have two location latitude, long-latitude. I need to check 2nd location available within 2000 meters with first 1st location.</p>
<p>Also i have location array an i want to check with 1st location. I need result how many available in 2000 meters</p>
<p>Thanks,<br>
Bharat Bhola</p>
| <php><google-maps><google-maps-api-3> | 2016-06-11 17:24:09 | LQ_CLOSE |
37,767,227 | how to determine if the input to a function is integer in matlab | I'm writing a code to take an input ( and integer) interpretes the input as year and return the century . the code works fine except for input like cent = centuries ([ 1 2])
,in this case it is supposed to return empty string but it is returning first century . I've used ~isinteger and ~isscalar and y<1 and the likes but its still returning a value. please what can i do here ? | <matlab> | 2016-06-11 18:31:22 | LQ_EDIT |
37,767,444 | kotlin logging with lambda parameters | <p>In log4j2 we have a handy feature which is described as</p>
<pre><code>// Java-8 style optimization: no need to explicitly check the log level:
// the lambda expression is not evaluated if the TRACE level is not enabled
logger.trace("Some long-running operation returned {}", () -> expensiveOperation());
</code></pre>
<p>my attempt to use this in kotlin</p>
<pre><code>log.debug("random {}", { UUID.randomUUID() })
</code></pre>
<p>which will print</p>
<pre><code>random Function0<java.util.UUID>
</code></pre>
<p><strong>How do we use lambda argument logging with kotlin? Or how do we explicitly tell kotlin what method to call?</strong></p>
| <java-8><log4j2><kotlin> | 2016-06-11 18:55:04 | HQ |
37,767,562 | Unsure why code isn't working | <p>I am unsure why my code is not working:</p>
<pre><code>public int caughtSpeeding(int speed, boolean isBirthday) {
if(isBirthday=true){
speed = speed - 5;
}
if(speed<=60){
return 0;
}
if(speed>=81){
return 2;
}
return 1;
}
</code></pre>
<p>The question is:</p>
<p>You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int value: 0=no ticket, 1=small ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the result is 2. Unless it is your birthday -- on that day, your speed can be 5 higher in all cases.</p>
| <java> | 2016-06-11 19:07:05 | LQ_CLOSE |
37,768,039 | ASP.NET C# storing Session in DataBase | <p>i am new with ASP.NET and C#. I was trying to store details of a booking into the booking table including User ID using the session.
My booking table is as follow</p>
<pre><code>CREATE TABLE [dbo].[BookingTb] (
[Bid] INT IDENTITY (1, 1) NOT NULL,
[Rid] VARCHAR (5) NOT NULL,
[Price] MONEY NOT NULL,
[nights] INT NOT NULL,
[NoOfRooms] INT NOT NULL,
[Uid] VARCHAR(50) NOT NULL,
PRIMARY KEY CLUSTERED ([Bid] ASC));
</code></pre>
<p>and the user table is as follow</p>
<pre><code>CREATE TABLE [dbo].[UserTb] (
[Uid] VARCHAR (50) NOT NULL,
[Uname] VARCHAR (15) NOT NULL,
[Ubd] INT NOT NULL,
[Ugender] VARCHAR (10) NOT NULL,
[Uemail] VARCHAR (50) NOT NULL,
[password] VARCHAR (50) NOT NULL,
PRIMARY KEY CLUSTERED ([Uid] ASC));
</code></pre>
<p>i created the session in the login form as follow</p>
<pre><code>Session["Uid"] = TextBox1.Text.ToString();
</code></pre>
<p>Now i want to store different details in the Booking table including the session after the user log in so i used the following code:</p>
<pre><code>using System.Data;
using System.Data.SqlClient;
public partial class UserBooking : System.Web.UI.Page
{
DataClassesDataContext db = new DataClassesDataContext();
protected void Button1_Click(object sender, EventArgs e)
{
BookingTb b = new BookingTb();
Int32 rooms,nights, cap,price;
rooms = Convert.ToInt32(TextBox1.Text);
nights = Convert.ToInt32(TextBox2.Text);
cap = Convert.ToInt32(DropDownList2.SelectedItem.Value);
String type = DropDownList1.SelectedItem.Value;
String Rid;
String user =Convert.ToString(Session["Uid"]) ;
if (type == "Normal" && cap == 2)
{
Rid = "G01";
price = rooms * nights * 35;
b.Rid = Rid;
b.Price = price;
b.nights = nights;
b.Uid = user;
b.NoOfRooms = rooms;
db.BookingTbs.InsertOnSubmit(b);
db.SubmitChanges();
Label3.Text = "Thank you for Booking with us!</br> Total Payment= " + price;
}
</code></pre>
<p>the problem is i keep getting this error:</p>
<pre><code> Line 39:b.Uid = user;
Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'int'
</code></pre>
<p>well, Uid is a varchar(50) not an int! how can i solve that? i tried many ways but non of them worked.</p>
| <c#><mysql><asp.net><session> | 2016-06-11 20:02:28 | LQ_CLOSE |
37,768,436 | How do I make background code? | <p>I want to make background code that checks if someone hit "H","D", or other letters. Like This,(I mean a background code that is checking this.)</p>
<pre><code>if(e.KeyCode == Keys.U)
{
code;
}
</code></pre>
| <c#> | 2016-06-11 20:56:01 | LQ_CLOSE |
37,769,102 | How add a third Jlist in this example | guys. I'm starting programming, learning a little Swing, i was praticing using the the Visual IDE of Netbeans that is easy, i just click on the components to add to Form. I found a example in internet that have 2 Jlists, i need to add a third, but i dont know cause there's no graphic interface, it was did in code, can you help me to add a third at the end of Form ? Thanks..
That's the actual code and a little photo of the aplication running
[enter image description here][1]
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.swing.AbstractListModel;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import br.com.project.receita.dao.IngredienteDao;
import br.com.project.receita.vo.IngredienteVo;
public class DualListBox extends JPanel {
private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
private static final String ADD_BUTTON_LABEL = "Adicionar >>";
private static final String REMOVE_BUTTON_LABEL = "<< Remover";
private static final String INGREDIENTES_DISPONIVEIS = "Ingredientes Disponíveis";
private static final String INGREDIENTES_SELECIONADOS = "Ingredientes Selecionados";
private static final String RECEITAS_DISPONIVEIS = "Receitas Disponíveis";
private JLabel sourceLabel;
private JList sourceList;
private SortedListModel sourceListModel;
private JList destList;
private SortedListModel destListModel;
private JLabel destLabel;
private JButton addButton;
private JButton removeButton;
public DualListBox() {
initScreen();
}
public String getSourceChoicesTitle() {
return sourceLabel.getText();
}
public void setSourceChoicesTitle(String newValue) {
sourceLabel.setText(newValue);
}
public String getDestinationChoicesTitle() {
return destLabel.getText();
}
public void setDestinationChoicesTitle(String newValue) {
destLabel.setText(newValue);
}
public void clearSourceListModel() {
sourceListModel.clear();
}
public void clearDestinationListModel() {
destListModel.clear();
}
public void addSourceElements(ListModel newValue) {
fillListModel(sourceListModel, newValue);
}
public void setSourceElements(ListModel newValue) {
clearSourceListModel();
addSourceElements(newValue);
}
public void addDestinationElements(ListModel newValue) {
fillListModel(destListModel, newValue);
}
private void fillListModel(SortedListModel model, ListModel newValues) {
int size = newValues.getSize();
for (int i = 0; i < size; i++) {
model.add(newValues.getElementAt(i));
}
}
public void addSourceElements(Object newValue[]) {
fillListModel(sourceListModel, newValue);
}
public void setSourceElements(Object newValue[]) {
clearSourceListModel();
addSourceElements(newValue);
}
public void addDestinationElements(Object newValue[]) {
fillListModel(destListModel, newValue);
}
private void fillListModel(SortedListModel model, Object newValues[]) {
model.addAll(newValues);
}
public Iterator sourceIterator() {
return sourceListModel.iterator();
}
public Iterator destinationIterator() {
return destListModel.iterator();
}
public void setSourceCellRenderer(ListCellRenderer newValue) {
sourceList.setCellRenderer(newValue);
}
public ListCellRenderer getSourceCellRenderer() {
return sourceList.getCellRenderer();
}
public void setDestinationCellRenderer(ListCellRenderer newValue) {
destList.setCellRenderer(newValue);
}
public ListCellRenderer getDestinationCellRenderer() {
return destList.getCellRenderer();
}
public void setVisibleRowCount(int newValue) {
sourceList.setVisibleRowCount(newValue);
destList.setVisibleRowCount(newValue);
}
public int getVisibleRowCount() {
return sourceList.getVisibleRowCount();
}
public void setSelectionBackground(Color newValue) {
sourceList.setSelectionBackground(newValue);
destList.setSelectionBackground(newValue);
}
public Color getSelectionBackground() {
return sourceList.getSelectionBackground();
}
public void setSelectionForeground(Color newValue) {
sourceList.setSelectionForeground(newValue);
destList.setSelectionForeground(newValue);
}
public Color getSelectionForeground() {
return sourceList.getSelectionForeground();
}
private void clearSourceSelected() {
Object selected[] = sourceList.getSelectedValues();
for (int i = selected.length - 1; i >= 0; --i) {
sourceListModel.removeElement(selected[i]);
}
sourceList.getSelectionModel().clearSelection();
}
private void clearDestinationSelected() {
Object selected[] = destList.getSelectedValues();
for (int i = selected.length - 1; i >= 0; --i) {
destListModel.removeElement(selected[i]);
}
destList.getSelectionModel().clearSelection();
}
private void initScreen() {
setBorder(BorderFactory.createEtchedBorder());
setLayout(new GridBagLayout());
sourceLabel = new JLabel(INGREDIENTES_DISPONIVEIS);
JButton button = new JButton("Buscar");
add(button, new GridBagConstraints(1, 3, 1, 2, 0, .25,
GridBagConstraints.CENTER, GridBagConstraints.NONE,
EMPTY_INSETS, 0, 0));
button.addActionListener(new PrintListener());
sourceListModel = new SortedListModel();
sourceList = new JList(sourceListModel);
add(sourceLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
GridBagConstraints.CENTER, GridBagConstraints.NONE,
EMPTY_INSETS, 0, 0));
add(new JScrollPane(sourceList), new GridBagConstraints(0, 1, 1, 5, .5,
1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
EMPTY_INSETS, 0, 0));
addButton = new JButton(ADD_BUTTON_LABEL);
add(addButton, new GridBagConstraints(1, 2, 1, 2, 0, .25,
GridBagConstraints.CENTER, GridBagConstraints.NONE,
EMPTY_INSETS, 0, 0));
addButton.addActionListener(new AddListener());
removeButton = new JButton(REMOVE_BUTTON_LABEL);
add(removeButton, new GridBagConstraints(1, 4, 1, 2, 0, .25,
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
0, 5, 0, 5), 0, 0));
removeButton.addActionListener(new RemoveListener());
destLabel = new JLabel(INGREDIENTES_SELECIONADOS);
destListModel = new SortedListModel();
destList = new JList(destListModel);
add(destLabel, new GridBagConstraints(2, 0, 1, 1, 0, 0,
GridBagConstraints.CENTER, GridBagConstraints.NONE,
EMPTY_INSETS, 0, 0));
add(new JScrollPane(destList), new GridBagConstraints(2, 1, 1, 5, .5,
1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
EMPTY_INSETS, 0, 0));
}
public static void main(String args[]) {
JFrame f = new JFrame("Dual List Box Tester");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
List<IngredienteVo> listaIngredientes = new ArrayList<IngredienteVo>();
DualListBox dual = new DualListBox();
Map<String, IngredienteVo> mapCodigoIngredientes = new HashMap();
int i = 0;
IngredienteDao ingredienteDao = new IngredienteDao();
listaIngredientes = ingredienteDao.getIngredientesList();
String[] myArray = new String[listaIngredientes.size()];
for (IngredienteVo IngredienteVo : listaIngredientes) {
myArray[i] = IngredienteVo.getNome();
i++;
mapCodigoIngredientes.put(IngredienteVo.getNome(), IngredienteVo);
}
dual.addSourceElements(myArray);
f.getContentPane().add(dual, BorderLayout.CENTER);
f.setSize(400, 300);
f.setVisible(true);
}
private class AddListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
Object selected[] = sourceList.getSelectedValues();
addDestinationElements(selected);
clearSourceSelected();
}
}
private class RemoveListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
Object selected[] = destList.getSelectedValues();
addSourceElements(selected);
clearDestinationSelected();
}
}
class PrintListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
int selected[] = destList.getSelectedIndices();
System.out.println("Selected Elements: ");
for (int i = 0; i < destList.getModel().getSize(); i++) {
Object element = destList.getModel().getElementAt(i);
System.out.println("Item - " + element);
}
}
}
}
class SortedListModel extends AbstractListModel {
SortedSet model;
public SortedListModel() {
model = new TreeSet();
}
public int getSize() {
return model.size();
}
public Object getElementAt(int index) {
return model.toArray()[index];
}
public void add(Object element) {
if (model.add(element)) {
fireContentsChanged(this, 0, getSize());
}
}
public void addAll(Object elements[]) {
Collection c = Arrays.asList(elements);
model.addAll(c);
fireContentsChanged(this, 0, getSize());
}
public void clear() {
model.clear();
fireContentsChanged(this, 0, getSize());
}
public boolean contains(Object element) {
return model.contains(element);
}
public Object firstElement() {
return model.first();
}
public Iterator iterator() {
return model.iterator();
}
public Object lastElement() {
return model.last();
}
public boolean removeElement(Object element) {
boolean removed = model.remove(element);
if (removed) {
fireContentsChanged(this, 0, getSize());
}
return removed;
}
}
[1]: http://i.stack.imgur.com/AORrZ.jpg | <java><swing><jbutton><jlist> | 2016-06-11 22:40:25 | LQ_EDIT |
37,769,187 | Access Parent @Component and vars from *Routed* Child Component | <p>I am trying to toggle a side nav menu, located at the top of my main App template using a button in a nested child component. I can't figure out how to get to the sidenav component in the parent to tell it to <code>sidenav.open()</code>. </p>
<p>I know about @Input and @Output on a child component, but as I understand it, to use this I need to have some sort of DOM tag for the child component to attach these to? Such as:</p>
<pre><code><app>
<sidenav-component #sidenav>...</sidenav-component>
<child [someInput]="some_parent_var" (childOpensNav)="sidenav.open()"></child>
</app>
</code></pre>
<p>Tons of articles on how to do this. Problem is that I'm <em>routing</em> to this component so no <code><child></code> tag exists explicitly in the code. Rather my code is like this:</p>
<pre><code><app>
<sidenav-component #sidenav>...</sidenav-component>
<router-outlet></router-outlet>
</app>
</code></pre>
<p>If I have a child component that gets routed to, how do I do a <code>sidenav.open()</code> or somehow access a component in the parent from the child? </p>
<p>Some thoughts: I've done some research and thinking about a couple of approaches and not sure if they are correct or would even work...One approach being using the Injector service and trying to traverse up to the parent, but this feels wrong:</p>
<pre><code>// child component
constructor(injector: Injector) {
this.something = injector.parent.get(Something);
}
</code></pre>
<p>Or possibly creating a Service in the parent, somehow attached to the Sidenav component and then injecting this service into the child??</p>
| <angular><angular2-routing><angular2-services> | 2016-06-11 22:55:51 | HQ |
37,770,539 | Does an exception handler passed to CompletableFuture.exceptionally() have to return a meaningful value? | <p>I'm used to the <a href="https://github.com/google/guava/wiki/ListenableFutureExplained" rel="noreferrer"><code>ListenableFuture</code></a> pattern, with <code>onSuccess()</code> and <code>onFailure()</code> callbacks, e.g.</p>
<pre><code>ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
ListenableFuture<String> future = service.submit(...)
Futures.addCallback(future, new FutureCallback<String>() {
public void onSuccess(String result) {
handleResult(result);
}
public void onFailure(Throwable t) {
log.error("Unexpected error", t);
}
})
</code></pre>
<p>It seems like Java 8's <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html" rel="noreferrer"><code>CompletableFuture</code></a> is meant to handle more or less the same use case. Naively, I could start to translate the above example as:</p>
<pre><code>CompletableFuture<String> future = CompletableFuture<String>.supplyAsync(...)
.thenAccept(this::handleResult)
.exceptionally((t) -> log.error("Unexpected error", t));
</code></pre>
<p>This is certainly less verbose than the <code>ListenableFuture</code> version and looks very promising.</p>
<p>However, it doesn't compile, because <code>exceptionally()</code> doesn't take a <code>Consumer<Throwable></code>, it takes a <code>Function<Throwable, ? extends T></code> -- in this case, a <code>Function<Throwable, ? extends String></code>.</p>
<p>This means that I can't just log the error, I have to come up with a <code>String</code> value to return in the error case, and there is no meaningful <code>String</code> value to return in the error case. I can return <code>null</code>, just to get the code to compile:</p>
<pre><code> .exceptionally((t) -> {
log.error("Unexpected error", t);
return null; // hope this is ignored
});
</code></pre>
<p>But this is starting to get verbose again, and beyond verbosity, I don't like having that <code>null</code> floating around -- it suggests that someone might try to retrieve or capture that value, and that at some point much later I might have an unexpected <code>NullPointerException</code>.</p>
<p>If <code>exceptionally()</code> took a <code>Function<Throwable, Supplier<T>></code> I could at least do something like this --</p>
<pre><code> .exceptionally((t) -> {
log.error("Unexpected error", t);
return () -> {
throw new IllegalStateException("why are you invoking this?");
}
});
</code></pre>
<p>-- but it doesn't.</p>
<p>What's the right thing to do when <code>exceptionally()</code> should never produce a valid value? Is there something else I can do with <code>CompletableFuture</code>, or something else in the new Java 8 libraries, that better supports this use case?</p>
| <java><completable-future> | 2016-06-12 03:45:47 | HQ |
37,770,728 | regex pattrn for date time validation | i m using this regex pattern for date time validation..
$regexp = "/^([0][1-9]|[12][0-9]|3[0-1])\/([0][1-9]|1[0-2])\/(\d{4}) ([0-9]|1[0-2])\:([0-5][0-9]) (am|pm)$/";
can anybody help where is the problem. | <regex> | 2016-06-12 04:28:18 | LQ_EDIT |
37,770,988 | Can we make custom filters in angularjs? | <p>I know there are some filters available in angularjs like <code>**currency**</code>, <code>**number**</code>. </p>
<pre><code>{{ value | currency }}
</code></pre>
<p>Is there any filter available for Phone number formatting?</p>
<p>And can I make my own filter?</p>
<pre><code>{{ Phone-value | phoneFilter }}
</code></pre>
<p>I want to make my own <code>**phoneFilter**</code>.</p>
| <javascript><jquery><angularjs> | 2016-06-12 05:20:31 | LQ_CLOSE |
37,771,329 | Convert Object List Into Map | <p>I have list of objects which have two properties {alpha,beta} as below :</p>
<pre><code>obj1 = {alpha1,beta1}
obj2 = {alpha2,beta2}
obj3 = {alpha3,beta3}
obj3 = {alpha1,beta2}
obj5 = {alpha3,beta1}
</code></pre>
<p>I want to create a map such as <code>Map<alphaKey,List<beta>></code></p>
<p>so It will like below :</p>
<pre><code>alpha1 --> beta1,beta2
alpha2 --> beta2
alpha3 --> beta3,beta1
</code></pre>
<p>Thanks</p>
| <java> | 2016-06-12 06:24:13 | LQ_CLOSE |
37,771,723 | ionic change default font | <p>I know this question is asked and answered before in the links below. I want to change the default font without having to add to every css. </p>
<p>Things I have tried:</p>
<ol>
<li>Changing the .tff, .eot, .woff, .svg file directly to merge my fonts and ionicons </li>
<li>Tried to implement the font by specifying it in html and css file (it works, but i want it to be default)</li>
<li>Overwrite the www/lib/ionic/fonts with open-sans font (the ionicons disappear)</li>
<li>When i use the first link (all formatting is gone, only left with text and buttons) I also tried placing the font-face on top and bottom in scss/ionic.app.scss</li>
</ol>
<p>Please help! The answers i have seen are instructions but no explanation how it works. I don't know how "ionic setup sass" works/what it does. How gulp plays a part in this.</p>
<p><a href="https://forum.ionicframework.com/t/how-to-change-the-font-of-all-texts-in-ionic/30459" rel="noreferrer">https://forum.ionicframework.com/t/how-to-change-the-font-of-all-texts-in-ionic/30459</a></p>
<p><a href="https://forum.ionicframework.com/t/change-font-family-and-use-ionicons-icons/26729" rel="noreferrer">https://forum.ionicframework.com/t/change-font-family-and-use-ionicons-icons/26729</a></p>
| <css><ionic-framework><sass> | 2016-06-12 07:19:27 | HQ |
37,772,524 | Lowercase all strings in a list by list comprehension | <p>I am confused on how my code is not turning all strings into lowercase? </p>
<pre><code>def set_lowercase(strings):
""" lower the case 2. """
return [i.lower() for i in strings]
strings = ['Right', 'SAID', 'Fred']
set_lowercase(strings)
print(strings)
</code></pre>
| <python><python-3.x> | 2016-06-12 09:10:03 | LQ_CLOSE |
37,774,651 | how to turn this "for" loop into a recursion (java)? | This is my code that generates any possible permutation in the given length (n) from string s (the abc):
public String binary (int n, String str, int i){
String s="abcdefghijklmnopqrstuvwxyz";
//i=s.length();
if (n==0){
System.out.println(str);
return str;}
if (i==s.length()){
System.out.println(str);
return "";}
for (i=0;i<26;i++){
binary (n-1,str+s.charAt(i), i);}
return "";
}
My question is how to convert my "for" loop into a recursion? I am not allowed to use any loops in my homework. Thanks! | <java><loops><recursion> | 2016-06-12 13:12:23 | LQ_EDIT |
37,775,561 | Unresolved external symbol in qt project | <p>Okay so spend 30 min or so having a look at common causes for this issue and I can't see what is wrong. </p>
<p>The error I am getting is unresolved external symbol. The symbol in question being a class called AdventureDocs. The header is as follows.</p>
<pre><code>#ifndef ADVENTUREDOCS_H
#define ADVENTUREDOCS_H
#include <QWidget>
class AdventureDocs : public QWidget
{
Q_OBJECT
public:
AdventureDocs(QObject *parent);
};
#endif // ADVENTUREDOCS_H
</code></pre>
<p>and the cpp</p>
<pre><code>#include "adventuredocs.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QTabWidget>
AdventureDocs::AdventureDocs(QObject *parent): QWidget(parent)
{
QHBoxLayout *hLayout = 0;
QVBoxLayout *vLayout = 0;
QPushButton *button = 0;
QLabel *label = 0;
hLayout = new QHBoxLayout();
Q_ASSERT(hLayout);
vLayout = new QVBoxLayout();
Q_ASSERT(vLayout);
// Set the layout to the widget
setLayout(hLayout);
hLayout->addLayout(vLayout);
// Draw widgets on main page.
label = new QLabel(hLayout);
Q_ASSERT(label);
hLayout->addWidget(label);
label->setText("Adventure Docs");
}
</code></pre>
<p>This is a class not a library or anything smart like that I used add new class in qt creator to add it and that added the header and cpp into the project file as follows.</p>
<pre><code>#-------------------------------------------------
#
# Project created by QtCreator 2016-06-12T11:06:47
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = AdventureDocs
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
adventuredocs.cpp
HEADERS += mainwindow.h \
adventuredocs.h
FORMS += mainwindow.ui
</code></pre>
<p>finally in the mainwindow .cpp where i create an AdventureDocs object is where i get the error.</p>
<pre><code>#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include "adventuredocs.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
AdventureDocs *main = 0;
main = new AdventureDocs(this);
if (main != 0)
{
setCentralWidget(main);
}
}
MainWindow::~MainWindow()
{
delete ui;
}
</code></pre>
<p>Can someone point out the bleeding obvious which I am clearly missing thanks.</p>
| <c++><qt><unresolved-external> | 2016-06-12 14:46:58 | LQ_CLOSE |
37,775,780 | CSS3 - Use part of an image for background | <p>I want to use some images as backgrounds but I have no control over the images. If the images are 500px x 500px , is it possible with just CSS3 to scale the image down to 200px x 200px and then only use 100px x 100px from the center?</p>
| <css> | 2016-06-12 15:10:13 | LQ_CLOSE |
37,775,790 | python string (file1.txt) search from file2.txt | file1.txt contains usernames, i.e.
tony
peter
john
...
file2.txt contains user details, just one line for each user details, i.e.
alice 20160102 1101 abc
john 20120212 1110 zjc9
mary 20140405 0100 few3
peter 20140405 0001 io90
tango 19090114 0011 n4-8
tony 20150405 1001 ewdf
zoe 20000211 0111 jn09
...
I want to get a shortlist of user details from file2.txt by file1.txt user provided, i.e.
john 20120212 1110 zjc9
peter 20140405 0001 io90
tony 20150405 1001 ewdf
How to use python to do this?
Sorry, I'm the newbie for both coding and python.
Thanks a lot! | <python><string><search> | 2016-06-12 15:11:14 | LQ_EDIT |
37,776,228 | Pycharm/Python OpenCV and CV2 install error | <p>I've been trying to install both OpenCV and cv2 from both Pycharm and from the terminal as suggested using:</p>
<pre><code>pip install --user opencv
pip install --user cv2
</code></pre>
<p>but I'm getting the following error for them:</p>
<pre><code>Collecting opencv
Could not find a version that satisfies the requirement opencv (from versions: )
No matching distribution found for opencv
</code></pre>
<p>and</p>
<pre><code>Collecting cv2
Could not find a version that satisfies the requirement cv2 (from versions: )
No matching distribution found for cv2
</code></pre>
<p>How can I fix these and install the packages properly? I'm using python 3.4.</p>
| <python><opencv><pycharm> | 2016-06-12 15:54:16 | HQ |
37,776,415 | I wana to get all in mysql | I want fetch all rows in mysql column but it return only 1 is have try this out while($info=mysql_fetch_all($query2, mysql_assoc))
{
but not working please help me out | <php><mysql> | 2016-06-12 16:11:33 | LQ_EDIT |
37,776,440 | Change the browser's Date/time value using chrome extension | <p>I'm looking for a way to change the value returned from javascript's <code>new Date()</code> function.<br>
In general - I'm looking for a way to write an extension that will give the user the ability to set his timezone (or diff from the time of his system's clock) without changing time/timezone on his computer.</p>
<p>I checked the <a href="https://developer.chrome.com/extensions/api_index" rel="noreferrer">chrome extension api</a> but found nothing there. Will appreciate it if someone can point me at the right direction.</p>
| <google-chrome-extension> | 2016-06-12 16:14:23 | HQ |
37,776,690 | Need a SQL query to get data from sql database for a given period with certain condition | I have sql database namely sales.dbo with 7 columns. First column contains different sales person names, on column 2 to 6 other information, on column 7,sales average. What i need is a query to get all sales person details(all seven columns in excel) if their sales average is more than 60 % between a given date. For example:
In my database, i have data from 01/05/2016 to 31/05/2016, if i enter a period in my excel sheet between 25/05/2016 to 31/05/2016 and my required average for ex.60% (should be changed as per my need), then i need all the sales person details who continuously have sales average of more than 60% between 25 to 31st May 2016.
If a sales man average was dropped below 60 % on 28th May , then i don't want to see him on my report.In simple words, i need all sales person who continuously hitting 60 % or more on average sales within my search period.
Thanks in Advance. | <sql-server><excel> | 2016-06-12 16:40:29 | LQ_EDIT |
37,777,026 | How to configure IIS 7 for localhost website? | <p>I am new in Asp.Net</p>
<p>I have enabled features of IIS 7 on my windows system and able to see IIS manager.</p>
<p>I created an application but build/run application through visual studio it goes to browser and run the application with different port number. When i stop build/run application through visual studio and again i refresh browser application could not run.</p>
<p>I want to run application without visual studio. How to do this.</p>
<p>It gives this : <code>http://localhost:9864/</code></p>
| <asp.net><visual-studio><iis-7> | 2016-06-12 17:18:22 | HQ |
37,777,216 | Need regix for input with jquery | I need regix so that only these characters are allowed to type: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 & , . – / ( ) @ * + ! ? “ ‘ : ;
Also it would be nice if I could implement this through jQuery in this code:
$("#firstText").keyup(function () {
var value = $(this).val().toUpperCase();
$(".zetin16").text(value);
}).keyup(); | <jquery><regex> | 2016-06-12 17:39:30 | LQ_EDIT |
37,777,557 | How do I declare an array without knowing its size? C++ | <p>I have to write a program that reads a string of numbers from user input until it reads 0. For example if the values introduced are 1, 2, 3, 0 then the array X will contain 1, 2 and 3 and the array size will be 3. There is no specified limit for the number of values inserted and I can't just declare an array of any size so is there a way to dynamically increase the size of the array to be able to hold more int values as they are being read?</p>
| <c++><arrays> | 2016-06-12 18:13:22 | LQ_CLOSE |
37,778,477 | How to make a part of HTML file not updated under a certain condition | <p>I have a HTML file which is updated every 30 seconds. It is rendered by Jinja2 from a certain python file to pass variables. Is there any way to omit updating of some elements?</p>
<p>The code looks like that:</p>
<pre><code><html>
<head>
<title>My site</title>
<meta http-equiv="refresh" content="30">
<style>
b.value {
position: absolute;
border: 2px solid black;
text-align: center;
padding: 20px;
}
.head {
position: absolute;
}
</style>
</head>
<body>
<b class="value" style="left:920px;">{{ var1 }} %</b></h2>
<h3 style="padding-left:860px;padding-top:200px;"> Text 2: under me is the part I want to update only when the condition is true</h3>
{% if var2 != 0 %}
<b class="head" style="padding-left:900px;">{{ var2 }}</b>
{% endif %}
</body>
</html>
</code></pre>
<p>I want to refresh the variable <em>var2</em> only if it is not equal to 0 and not every 30s, as the rest of page is updated.</p>
<p>Thank you for the tips,
Kaki</p>
| <python><html><css><flask><jinja2> | 2016-06-12 19:52:38 | LQ_CLOSE |
37,778,790 | Who wants to be a millionaire (special help option) | I have wrote a very very simple quiz c++ program (who wants to be a millionaire) which reads the questions from the file,
I would like to include a special help option which will skip the answer when used. The problem is that I do not want the user to use that option more than once, how can I do that.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string a[15]; //Array which will take answers
string print, print2; //Strings for printing questions
ifstream answers("q&a.txt");
cout << "Welcome to who wants to be a millionaire\n";
while (answers) //Read questions from the file
{
getline(answers, print);
auto position = print.find( "01." );
if(position <= print.size())
{
print2 = print.substr(position + 1 );
cout << print2 << endl << "A. Blackburn Losers\nB. Blackburn Rovers\nC. Blackburn Lovers\nD. BlackburnWanderers\n";
}
cin >> a[0];
if (a[0] == "b") //If correct, proceed to next question
{
getline(answers, print);
position = print.find("02.");
}
//If the answer is wrong, terminate the program
if (a[0] != "b")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Fridge\nB. Bank\nC. Market\nD. Shoe\n";
}
cin >> a[1];
if (a[1] == "b")
{
getline(answers, print);
position = print.find("03");
}
if (a[1] != "b")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Bassey\nB. Kwesi\nC. Abiodun\nD. Ejima\n";
}
cin >> a[2];
if (a[2] == "b")
{
getline(answers, print);
position = print.find("04.");
}
if (a[2] != "b")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Inferno\nB. Domino\nC. Stiletto\nD. Tornado\n";
}
cin >> a[3];
if (a[3] == "a")
{
getline(answers, print);
position = print.find("05.");
}
if (a[3] != "a")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Marry a wife\nB. Bury a dead parent\nC. Have thanksgiving in church\nD. Accept gifts or favour in kind\n";
}
cin >> a[4];
if (a[4] == "d")
{
getline(answers, print);
position = print.find("06.");
}
if (a[4] != "d")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Tenacity\nB. Verifiability\nC. Hereditary\nD. Validation\n";
}
cin >> a[5];
if (a[5] == "c")
{
getline(answers, print);
position = print.find("07.");
}
if (a[5] != "c")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Paris\nB. Copenhagen\nC. New York\nD. Madrid\n";
}
cin >> a[6];
if (a[6] == "a")
{
getline(answers, print);
position = print.find("08");
}
if (a[6] != "a")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position +1);
cout << print2 << endl << "A. Mumbai\nB. Beijing\nC. Rio de Janeiro\nD. Seville\n";
}
cin >> a[7];
if (a[7] == "b")
{
getline(answers, print);
position = print.find("09");
}
if (a[7] != "b")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. A speed equal to that of sound\nB. A speed greater than that of sound\nC. A speed equal to that of light\nD. A speed greater than that of light\n";
}
cin >> a[8];
if (a[8] == "b")
{
getline(answers, print);
position = print.find("10.");
}
if (a[8] != "b")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Nephrons\nB. Nerves\nC. Ligaments\nD. Stitches\n";
}
cin >> a[9];
if (a[9] == "c")
{
getline(answers, print);
position = print.find("11.");
}
if (a[9] != "c")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Swimmer\nB. Referee\nC. Football Fan\nD. Judoka\n";
}
cin >> a[10];
if (a[10] == "b")
{
getline(answers, print);
position = print.find("12.");
}
if (a[10] != "b")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. France\nB. United States\nC. Germany\nD. India\n";
}
cin >> a[11];
if (a[11] == "c")
{
getline(answers, print);
position = print.find("13.");
}
if (a[11] != "c")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Clint Eastwood\nB. Oliver Stone\nC. Peter Jackson\nD. Morgan Freeman\n";
}
cin >> a[12];
if (a[12] == "a")
{
getline(answers, print);
position = print.find("14.");
}
if (a[12] != "a")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Lebanon\nB. Columbia\nC. Japan\nD. Eritrea\n";
}
cin >> a[13];
if (a[13] == "b")
{
getline(answers, print);
position = print.find("15.");
}
if (a[13] != "b")
{
cerr << "We are sorry, you are wrong!\n";
break;
}
if (position <= print.size())
{
print2 = print.substr(position + 1);
cout << print2 << endl << "A. Literature\nB. Economics\nC. Peace\nD. Medicine\n";
cin >> a[14];
}
if (a[14] == "c")
{
cout << "Congratulations!\nYou won a million dollars!\n";
break;
}
if (a[14] != "c")
cerr << "We are sorry, you are wrong!\n";
break;
}
return 0;
}
Questions:
01. Which of these is the name of a British Football Club?
02. An establishment where money can be deposited or withdrawn is called what?
03 Name given to a boy born on Sunday in Ghana is what?
04. Which of the following refer to the word fire?
05. According to the constitution a public officer is not allowed to do which of these?
06. The process by which genetic traits are transmitted from parents to offspring is called what?
07. Roland Garros stadium is in which city?
08. Where is Tiananmen Square?
09. The word supersonic denotes which of these?
10. Which of these holds bones together at the joints of the body?
11. Linus Mbah achieved fame in Nigerian sporting circles as what?
12. DAX refers to the stock market of which country?
13. Who won the Academy Award for directing the movie ‘Million Dollar Baby’?
14. In which country is the Galeras Volcano?
15. Professor Maathai Wangari won the Nobel Prize for which of these?
Answers:
1 (B)
2 (B)
3 (B)
4 (A)
5 (D)
6 (C)
7 (A)
8 (B)
9 (B)
10 (C)
11 (B)
12 (C)
13 (A)
14 (B)
I15 (C) | <c++> | 2016-06-12 20:30:26 | LQ_EDIT |
37,779,818 | MvcBuildViews true causes "'/temp' is not a valid IIS application" error | <p>After setting <code>MvcBuildViews</code> to <code>true</code> in my <code>.csproj</code> file in order to have the views compile during build, I get the following error:</p>
<blockquote>
<p>'/temp' is not a valid IIS application</p>
</blockquote>
<p>I presume that the '/temp' that this is referring to is the path where the views will be compiled. Here's the relevant section in the <code>.csproj</code> file:</p>
<pre><code><Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
</code></pre>
<p>I use full IIS to serve up this MVC 5 website on my local machine (haven't tried this on a remote server yet). Do I need to set something up in IIS to make <code>MvcBuildViews</code> work correctly?</p>
| <asp.net-mvc><iis><visual-studio-2015><asp.net-mvc-5> | 2016-06-12 22:47:31 | HQ |
37,780,080 | Android Fingerprints: hasEnrolledFingerprints triggers exception on some Samsungs | <p>I'm seeing a lot of exceptions in our production app when enabling fingerprints coming from Android 6 users, which I cannot reproduce on any of my local Samsung devices. The stacktrace is:</p>
<pre><code>Message: SecurityException: Permission Denial: getCurrentUser() from pid=24365, uid=10229 requires android.permission.INTERACT_ACROSS_USERS
android.os.Parcel.readException in Parcel.java::1620
android.os.Parcel.readException in Parcel.java::1573
android.hardware.fingerprint.IFingerprintService$Stub$Proxy.hasEnrolledFingerprints in IFingerprintService.java::503
android.hardware.fingerprint.FingerprintManager.hasEnrolledFingerprints in FingerprintManager.java::762
android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23.a in SourceFile::39
android.support.v4.hardware.fingerprint.FingerprintManagerCompat$Api23FingerprintManagerCompatImpl.a in SourceFile::239
android.support.v4.hardware.fingerprint.FingerprintManagerCompat.a in SourceFile::66
</code></pre>
<p>This is just using the standard <code>FingerprintManagerCompat</code> class from the support library, and the check works correctly on other devices.</p>
<p>I don't want to add this permission to my app - it seems to have nothing to do with fingerprints.</p>
<p>Has anyone encountered anything like this?</p>
| <android><android-fingerprint-api> | 2016-06-12 23:26:48 | HQ |
37,780,100 | matplotlib: AttributeError: 'AxesSubplot' object has no attribute 'add_axes' | <p>Not sure exactly sure how to fix the following attribute error:</p>
<pre><code>AttributeError: 'AxesSubplot' object has no attribute 'add_axes'
</code></pre>
<p>The offending problem seems to be linked to the way I have set up my plot:</p>
<pre><code>gridspec_layout = gridspec.GridSpec(3,3)
pyplot_2 = fig.add_subplot(gridspec_layout[2])
ax = WCSAxes(fig, [0.1, 0.1, 0.8, 0.8], wcs=wcs)
pyplot_2.add_axes(ax)
</code></pre>
<p>Does anybody know how to solve this? Many thanks.</p>
| <python><matplotlib><axes> | 2016-06-12 23:29:35 | HQ |
37,780,275 | Google App Engine - automatic-scaling with always on instance? | <p>One of the most irritating things about using GAE for a brand new app is having to deal with instances being fired back up if no one has hit your servers in 15 minutes. Since the app is new, or just has few users, there will be periods of great latency for some users who have no clue that instances are being "spun up"</p>
<p>As far as I see it you have these options based on the <a href="https://cloud.google.com/appengine/docs/java/config/appref#scaling_elements">docs</a>:</p>
<p><strong>Use <code>manual-scaling</code> and set the number of instances to <code>1</code>.</strong></p>
<p>When you use <code>manual-scaling</code>, whatever number of instances you set it to is what you will have - no more, no less. This is clearly inefficient as you may be paying for unused instances and instances are not automatically added/removed as traffic increases/decreases</p>
<p><strong>Use <code>basic-scaling</code> and set <code>idle-timeout</code> to something like 24hrs or 48hrs.</strong></p>
<p>This would keep your instance running as long as someone queries your API at least once within that time period.</p>
<p><strong>Use <code>automatic-scaling</code> with <code>min-idle-instances</code> and warm-up requests enabled.</strong></p>
<p>This does not work as intended. According to these <a href="https://cloud.google.com/appengine/docs/java/warmup-requests/">docs</a>:</p>
<blockquote>
<p>if your app is serving no traffic, the first request to the app will
always be a loading request, not a warmup request.</p>
</blockquote>
<p>This does not solve our problem because if zero instances are running, then there is nothing to warm-up in the first place. Thus you still get latency on the first request.</p>
<hr>
<p><strong>The desired effect I would like to have is</strong> to always have an instance running and then scale up from there if traffic is increased (and of course scale down but never go below one instance). It would be like automatic-scaling but with 1 instance always running.</p>
<p>Is this possible in GAE? Or am I missing something?</p>
<p>For now, my temporary solution is to set my app to <code>manual-scaling</code> with 1 instance so at least my app is useable to new users.</p>
| <java><android><google-app-engine> | 2016-06-12 23:58:27 | HQ |
37,780,318 | Code Required to achieve vertical slider effect in Wordpress (examples included) | <p>I'm wondering how I can achieve an effect similar to that of <a href="http://eng.getlost-getnatural.ru/" rel="nofollow">http://eng.getlost-getnatural.ru/</a> or <a href="http://rnbtheme.com/sixteenth/" rel="nofollow">http://rnbtheme.com/sixteenth/</a>. I've contacted various support forums supplied through Wordpress and all they've been able to tell me is that I need to get a web developer and that the effect was possible. I, however, don't have the money for a web developer and went searching online to try to find what I was looking for and haven't been able to find anything yet. I can make code changes to my Wordpress site using javascript or css. Thank you so much to everyone who helps and answers!</p>
| <javascript><css><wordpress> | 2016-06-13 00:06:56 | LQ_CLOSE |
37,780,520 | unknown field in struct literal | <p>I'm trying to create a struct, and it is giving me an error, telling me the field is unknown.</p>
<p>The struct I am trying to initialize is: </p>
<pre><code>package yelk
type PhoneOptions struct {
phone string
cc string
lang string
}
</code></pre>
<p>And I'm trying to initialize a <code>PhoneOptions</code> struct in <code>cli.go</code> like this:</p>
<pre><code>number := os.Args[1]
phoneOptions := yelk.PhoneOptions{phone: number}
</code></pre>
<p>I do <code>go run cli.go 5555555555</code> but it gives me an error </p>
<pre><code>./cli.go:29: unknown yelk.PhoneOptions field 'phone' in struct literal
</code></pre>
<p>All The StackOverflow posts I've seen with this error seem to be from nested structs. I'm wondering what I'm doing wrong. <code>cli.go</code> will give this error if I just try to run <code>go build</code> on it, so I don't think it's the inputs I've been running it with.</p>
<p>Any idea why this happens? </p>
| <go> | 2016-06-13 00:51:01 | HQ |
37,780,648 | cant compile matrix multiplication ( C ) | Hey i got this error and i tried like 10 solutions and either works. I want to load 2 matrix, each one from its own txt file then to multiply them. I cant compile casue of LNK1120 and LNK2019 errors. Here is my code:
int main(int argc, char *argv[])
{
FILE *macierz1, *macierz2, *fw;
char *line = malloc(1000);
int count = 0;
macierz1 = fopen("macierz1.txt", "r");
if (macierz1 == NULL) {``
printf("nie można otworzyć", argv[1]);
exit(1);
}
macierz2 = fopen("macierz2.txt", "r");
if (macierz2 == NULL) {
printf("nie można otworzyć", argv[2]);
exit(1);
}
double *data = (double*)malloc(1000 * sizeof(double));
if (data == NULL)
{
printf("błąd lokowania pamięci");
return EXIT_FAILURE;
}
getline(&line, &count, macierz1);
int read = -1, cur = 0, columCount1 = 0;
while (sscanf(line + cur, "%lf%n", &data[columCount1], &read) == 1)
{
cur += read; columCount1++;
}
int rowCount1 = 1;
while (getline(&line, &count, macierz1) != -1) { rowCount1++; }
printf("%d\n", columCount1);
printf("%d\n", rowCount1);
getline(&line, &count, macierz2);
read = -1, cur = 0;
int columCount2 = 0;
while (sscanf(line + cur, "%lf%n", &data[columCount2], &read) == 1)
{
cur += read; columCount2++;
}
int rowCount2 = 1;
while (getline(&line, &count, macierz2) != -1) { rowCount2++; }
printf("%d\n", columCount2);
printf("%d\n", rowCount2);
int i = 0;
int j = 0;
int **mat1 = (int **)malloc(rowCount1 * sizeof(int*));
for (i = 0; i < rowCount1; i++)
mat1[i] = (int *)malloc(columCount1 * sizeof(int));
fseek(macierz1, 0, SEEK_SET);
for (i = 0; i < rowCount1; i++)
{
for (j = 0; j < columCount1; j++)
fscanf(macierz1, "%d", &mat1[i][j]);
}
i = 0;
j = 0;
printf("\n\n");
//print matrix 1
for (i = 0; i < rowCount1; i++)
{
for (j = 0; j < columCount1; j++)
printf("%d", mat1[i][j]);
printf("\n");
}
i = 0;
j = 0;
int **mat2 = (int **)malloc(rowCount2 * sizeof(int*));
for (i = 0; i < rowCount2; i++)
mat2[i] = (int *)malloc(columCount2 * sizeof(int));
fseek(macierz2, 0, SEEK_SET);
for (i = 0; i < rowCount2; i++)
{
for (j = 0; j < columCount2; j++)
fscanf(macierz2, "%d", &mat2[i][j]);
}
i = 0;
j = 0;
printf("\n\n");
//print matrix 2
for (i = 0; i < rowCount2; i++)
{
for (j = 0; j < columCount2; j++)
printf("%d", mat2[i][j]);
printf("\n");
}
i = 0;
int **mat3 = (int **)malloc(rowCount1 * sizeof(int*));
for (i = 0; i < rowCount1; i++)
mat3[i] = (int *)malloc(columCount2 * sizeof(int));
i = 0;
j = 0;
int k = 0;
int sum = 0;
if (columCount1 != rowCount2)
{
puts("The number of columns in Matrix 1 is not same as the number of rows in Matrix 2");
exit(1);
}
//multiplication of two matrices
for (i = 0; i<rowCount1; i++)
{
for (j = 0; j<columCount2; j++)
{
mat3[i][j] = 0;
for (k = 0; k<columCount1; k++)
{
mat3[i][j] = mat3[i][j] + mat1[i][k] * mat2[k][j];
}
}
}
//print multiplication result
printf("\n\nResult = \n\n");
for (i = 0; i < rowCount1; i++)
{
for (j = 0; j < columCount2; j++)
printf("%d", mat3[i][j]);
printf("\n");
}
for (i = 0; i< rowCount1; i++)
free(mat1[i]);
free(mat1);
for (i = 0; i< rowCount2; i++)
free(mat2[i]);
free(mat2);
for (i = 0; i< rowCount1; i++)
free(mat3[i]);
free(mat3);
free(data);
return 0;
}
| <c> | 2016-06-13 01:13:29 | LQ_EDIT |
37,780,685 | embedded sql in c,how to check if records exist | <p>I have tried these:</p>
<pre><code>1.if (EXEC SQL EXIST SELECT ...)
2.EXEC SQL IF EXIST SELECT ...
</code></pre>
<p>but none of these work,any help?</p>
| <c><embedded-sql> | 2016-06-13 01:19:30 | LQ_CLOSE |
37,780,950 | Why does console tell me that .filter is not a function? | <pre><code>var str = "I am a string.";
console.log(str.split(''));
var fil = function(val){
return val !== "a";
};
console.log(str.filter(fil));
</code></pre>
<p>When I run this, it says the str.filter is not a function.</p>
| <javascript> | 2016-06-13 02:13:04 | HQ |
37,781,229 | Idiomatic elixir to execute if params is not nil? | <p>How to go about filtering out invalid params like nil or empty list before proceed to process the params?</p>
<p>The <code>case</code> use below seems to be common but it's not clear code -- I am pretty sure there is a simpler and idiomatic way to do this.</p>
<pre><code> def load(token) do
case token do
nil -> nil
[] -> nil
token -> process(token)
end
end
</code></pre>
| <elixir> | 2016-06-13 02:58:37 | HQ |
37,781,970 | Disconnected from the target VM, address: '127.0.0.1:62535', transport: 'socket' on intellij idea CE. I can't debug my program. Any suggestions? | <p>Connected to the target VM, address: '127.0.0.1:63073', transport: 'socket'
Disconnected from the target VM, address: '127.0.0.1:63073', transport: 'socket'</p>
| <intellij-idea> | 2016-06-13 04:47:39 | HQ |
37,782,066 | List vs generator comprehension speed with join function | <p>So I got these examples from the official documentation.
<a href="https://docs.python.org/2/library/timeit.html" rel="noreferrer">https://docs.python.org/2/library/timeit.html</a></p>
<p>What exactly makes the first example (generator expression) slower than the second (list comprehension)?</p>
<pre><code>>>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
0.8187260627746582
>>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000)
0.7288308143615723
</code></pre>
| <python><python-2.7><list-comprehension> | 2016-06-13 04:57:27 | HQ |
37,782,191 | How to show the instagram followers counter in my wordpress website | How to show the instagram followers counter in my wordpress website see the screen short. [enter image description here][1]
[1]: http://i.stack.imgur.com/qQo8b.png | <wordpress><instagram><counter> | 2016-06-13 05:09:50 | LQ_EDIT |
37,782,344 | Does Azure WebJob look at the app.config once deployed | <p>I have a Web site running on Azure App Services. It has a WebJob that deploys with it, and thus gets put in it's App_data folder once deployed.</p>
<p>If I FTP to the wwwroot/app_data folder of my site once deployed, the app.config file has none of the configured settings that I set up in the "Application Settings Blade" in the Azure portal. The settings are changed in my web.config for the Website though.</p>
<p>The most curious thing is that when I run the WebJob, the log output indicates that the correct settings are being used!!</p>
<p>So as per my title, does the WebJob use the App.Settings file once deployed or does it use some kind of in-memory copy of the app-settings from the azure portal, or does it use what is in the web.config of the website?</p>
<p>Just to pre-emt a possible question, I know that the app.settings gets renamed to myappname.exe.config</p>
| <azure><azure-webjobs> | 2016-06-13 05:25:26 | HQ |
37,782,403 | set initial react component state in constructor or componentWillMount? | <p>In react components is it preferred to set the initial state in the constructor() or componentWillMount()?</p>
<pre><code>export default class MyComponent extends React.Component{
constructor(props){
super(props);
this.setState({key: value});
}
}
</code></pre>
<p>or</p>
<pre><code>export default class MyComponent extends React.Component{
componentWillMount(props){
this.setState({key: value});
}
}
</code></pre>
| <reactjs> | 2016-06-13 05:31:33 | HQ |
37,782,505 | Is it possible to show the `WORKDIR` when building a docker image? | <p>We have a problem with the <code>WORKDIR</code> when we building a docker image. Is it possible to print the value of <code>WORKDIR</code>?</p>
<p>We tried:</p>
<pre><code>ECHO ${WORKDIR}
</code></pre>
<p>But there is no such instruction <code>ECHO</code></p>
| <docker><dockerfile> | 2016-06-13 05:42:23 | HQ |
37,783,069 | why cannot extract spring boot executable jar | <p>spring boot project, build as a executable jar, but I found cannot extract the executable jar, e.g.</p>
<pre><code>jar xvf spring-boot-foo-0.0.1-SNAPSHOT.jar
</code></pre>
<p>nothing output.
But when extract a normal jar, it is successful</p>
<pre><code>jar xvf mysql-connector-java-5.1.38.jar
created: META-INF/
inflated: META-INF/MANIFEST.MF
created: META-INF/services/
...
</code></pre>
<p>why is this?</p>
| <jar><spring-boot> | 2016-06-13 06:27:15 | HQ |
37,784,574 | How to decompile an apk and save project? | <p>I need to decompile .apk file, and save it. I'm using <a href="http://www.javadecompilers.com/" rel="nofollow">http://www.javadecompilers.com/</a> , but I don't know how to save the folders. </p>
| <android> | 2016-06-13 08:04:52 | LQ_CLOSE |
37,784,605 | Javascript code for Showing and Hiding multiple divs with multiple buttons | Hope all is well?
I first off want to say thanks for the Help in advance.
I am new to JavaScript I don't understand it that well and have something real
urgent to complete.
I used this code: but apparent I have no Idea what I am doing wrong.
<!-- begin snippet: js hide: false console: true -->
<!-- language: lang-html -->
<!DOCTYPE HTML>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<script type="text/javascript">
jQuery(function($) {
var $bgs = $('.menu-toggle');
$('.menu-item').click(function() {
var $target = $($(this).data('target')).stop(true).slideToggle();
$bgs.not($target).filter(':visible').stop(true, true).slideUp();
})
})
</script>
</head>
<body>
<div class="menu-item menu-item-1" data-target=".recovery-bg">
<a href="#">Recovery</a>
</div>
<div class="menu-item menu-item-2" data-target=".forensic-bg">
<a href="#">Forensics</a>
</div>
<div class="menu-item menu-item-3" data-target=".erasure-bg">
<a href="#">Erasure</a>
</div>
<div class="menu-item menu-item-4" data-target=".training-bg">
<a href="#">Training</a>
</div>
<div class="menu-item menu-item-5" data-target=".product-bg">
<a href="#">Products</a>
</div>
<div class="menu-toggle recovery-bg">
recovery-bg
</div>
<div class="menu-toggle forensic-bg">
forensic-bg
</div>
<div class="menu-toggle erasure-bg">
erasure-bg
</div>
<div class="menu-toggle training-bg">
training-bg
</div>
<div class="menu-toggle product-bg">
product-bg
</div>
</body>
</html>
<!-- end snippet -->
I did get this same code from this website, but like I said no luck what so ever.
Please Help
Thanks | <javascript><jquery><html> | 2016-06-13 08:06:52 | LQ_EDIT |
37,785,022 | Java substring string when specific string occours | i need help to substring a string when a a substring occours.
Example
> Initial string: 123456789abcdefgh
> string to substr: abcd
> result : 123456789
I checked substr method but it accept index position value.I need to search the occorrence of the substring and than pass the index?
Thanks | <java><string><substring> | 2016-06-13 08:30:18 | LQ_EDIT |
37,785,154 | How to enable maven artifact caching for gitlab ci runner? | <p>We use gitlab ci with shared runners to do our continuous integration. For each build, the runner downloads tons of maven artifacts.</p>
<p>Is there a way to configure gitlab ci to cache those artifacts so we can speed up the building process by preventing downloading the same artifact over and over again?</p>
| <maven><gitlab-ci><gitlab-ci-runner><gitlab-8> | 2016-06-13 08:37:17 | HQ |
37,785,199 | I want to solution for my given code.kindly help me | `$string="cat, dog, pig, hello";`
required output (dynamically)
`$string1= cat;`
`$string2= dog;`
`$string3= pig;`
`$string4= hello;`
after use of comma in string, word become a new substring.` | <php> | 2016-06-13 08:39:44 | LQ_EDIT |
37,785,995 | how to convert ra-dec coordinates to galactic coordinates in python | i was converting a pixel coordinate fits file to world coordinates in python.the header shows that this fits file is in Ra-Dec coordinate system .I want to convert this to galactic coordinates.i tried
from astropy import coordinates as coord
from astropy import units as u
c=coord.icrscoord(ra=wx,dec=wy,unit=(u.degree,u.degree))
c.galactic
AttributeError: 'module' object has no attribute 'icrscoord'
>>>
what shall I do? | <python><python-2.7><astropy><fits> | 2016-06-13 09:20:00 | LQ_EDIT |
37,786,540 | Showing Legend on the side of graph | <p>I plotted a graph and the legend is showing right on top of the graph there by hiding the graph. </p>
<p>How can I show it on the side. </p>
<p>Here is the code I wrote</p>
<pre><code>##############################################################################
# Plot ROC curves for the multiclass problem
# Compute macro-average ROC curve and ROC area
# First aggregate all false positive rates
all_fpr = np.unique(np.concatenate([fpr[i] for i in range(n_classes)]))
# Then interpolate all ROC curves at this points
mean_tpr = np.zeros_like(all_fpr)
for i in range(n_classes):
mean_tpr += interp(all_fpr, fpr[i], tpr[i])
# Finally average it and compute AUC
mean_tpr /= n_classes
fpr["macro"] = all_fpr
tpr["macro"] = mean_tpr
roc_auc["macro"] = auc(fpr["macro"], tpr["macro"])
# Plot all ROC curves
plt.figure()
plt.plot(fpr["micro"], tpr["micro"],
label='micro-average ROC curve (area = {0:0.2f})'
''.format(roc_auc["micro"]),
linewidth=2)
plt.plot(fpr["macro"], tpr["macro"],
label='macro-average ROC curve (area = {0:0.2f})'
''.format(roc_auc["macro"]),
linewidth=2)
for i in range(n_classes):
plt.plot(fpr[i], tpr[i], label='AUC class {0} (area = {1:0.2f})'
''.format(i, roc_auc[i]))
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Multi-Class ROC Curve of '+name)
plt.legend(loc="lower right")
</code></pre>
<p>And here is the image I got. </p>
<p><a href="https://i.stack.imgur.com/I1yfn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I1yfn.png" alt="enter image description here"></a></p>
| <python><pandas><matplotlib> | 2016-06-13 09:47:17 | LQ_CLOSE |
37,786,975 | C++ - Unresolved External in DLL Injector | <p>I can't really see the reason I am getting this error, I have had a look arround and apparently it's something to do with defining a function that does nothing? I can't really tell what the issue is here unfortunately so any help would be appreciated.</p>
<p>Here is my source code:</p>
<p>main.cpp</p>
<pre><code>#include <Windows.h>
#include <tlhelp32.h>
#include <shlwapi.h>
#include <conio.h>
#include <stdio.h>
#include <iostream>
using namespace std;
#define WIN32_LEAN_AND_MEAN
#define CREATE_THREAD_ACCESS (PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ)
BOOL Inject(DWORD pID, const char * DLL_NAME);
DWORD GetTargetThreadIDFromProcName(const char * ProcName);
using namespace std;
char buf[MAX_PATH];
LPVOID RemoteString, LoadLib;
HANDLE Proc;
DWORD pID;
__int32 main()
{
pID = GetTargetThreadIDFromProcName("Program.exe");
buf[MAX_PATH] = {0};
GetFullPathName("DLL.dll", MAX_PATH, buf, NULL);
if(!Inject(pID, buf)) cout << ("Failed to inject!\n\n\n");
system("pause");
return 0;
}
BOOL Inject(DWORD pID, const char * DLL_NAME)
{
char buf[50] = {0};
if(!pID) return false;
Proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
if(!Proc) return false;
LoadLib = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
RemoteString = (LPVOID)VirtualAllocEx(Proc, NULL, strlen(DLL_NAME), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(Proc, (LPVOID)RemoteString, DLL_NAME, strlen(DLL_NAME), NULL);
CreateRemoteThread(Proc, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLib, (LPVOID)RemoteString, NULL, NULL);
CloseHandle(Proc);
return true;
}
DWORD GetTargetThreadIDFromProcName(const char * ProcName)
{
PROCESSENTRY32 pe;
HANDLE thSnapShot;
BOOL retval, ProcFound = false;
thSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(thSnapShot == INVALID_HANDLE_VALUE) return false;
pe.dwSize = sizeof(PROCESSENTRY32);
retval = Process32First(thSnapShot, &pe);
while(retval)
{
if(StrStrI(pe.szExeFile, ProcName)) return pe.th32ProcessID;
retval = Process32Next(thSnapShot, &pe);
}
return 0;
}
</code></pre>
<p>The error I am getting is the following:</p>
<p>main.obj</p>
<pre><code>unresolved external symbol __imp__StrStrIA@8 referenced in function "unsigned long __cdecl GetTargetThreadIDFromProcName(char const *)" (?GetTargetThreadIDFromProcName@@YAKPBD@Z)
</code></pre>
<p>Injector.exe</p>
<pre><code>1 unresolved externals
</code></pre>
<p>Any solutions or just some help on understanding why this occurs would be great!</p>
| <c++><dll><code-injection><unresolved-external> | 2016-06-13 10:07:59 | LQ_CLOSE |
37,787,095 | Linux chat server with c# | <p>I am quite new in programming so i'm looking for some advice.
Basically I learn C# on win8 until last week, when i started to show some interest in Linux Distros...and of course i installed it too.I really like this OS but it's a bit strange for me after win, by the way i'm sedulous in learning booth linux and programming.</p>
<p>My question is that...I would like to write a simple chat program that could communicate with a win7 client(Gf) and that sounds cool except linux is not windows :D. So I would like to know...What should i do? Change to Python or etc?Is it possible to make it in C#?I just need some "pointer" to select the best option of"route". :D</p>
| <c#><linux><windows><server><chat> | 2016-06-13 10:14:36 | LQ_CLOSE |
37,787,422 | Ruby Beginner - Spacing issue | I am new to ruby and I am practicing conversions with numbers and strings. I have an issue with the spacing for the following code below:
puts 'Hello, what\'s your first name?'
firstName = gets.chomp
puts 'What is your middle name?'
middleName = gets.chomp
puts 'Finally, what is your last name?'
lastName = gets.chomp
puts 'Nice to meet you ' + firstName + middleName + lastName + '. :)'
The last part does not space out once it has been run on Terminal.
Please help, Thanks :) | <ruby> | 2016-06-13 10:31:23 | LQ_EDIT |
37,787,545 | $("#imageform").ajaxForm({ target: '#preview' }).submit().done(function( data ) { alert( "Data Loaded: " + data ); }); | <form id="imageform" method="post" enctype="multipart/form-data" action='<?php echo HTTP_INDEX ?>demo_upload/upload'>
I am using ajax to upload an image file. It is running successfully.But i am facing issue with to get values after successfully uploaded.Want to get some values from backend in javascript variabe. As we get success on ajax call. Please revert me back as soon as possible. | <javascript><php><jquery><ajax><codeigniter> | 2016-06-13 10:36:57 | LQ_EDIT |
37,787,558 | Is The href="" function is the same with Include? | I want to ask you something about `href` on html and `include` on php. What is The Different Between `href` and `include`, they both refering to a file path. When i type '<link rel='stylesheet' href='style/style1.css' />' it means that "you can find style.css file at folder named style at your current position and so on for the include. If you can be more spesific i will appreciated it. thank | <php><html><css> | 2016-06-13 10:37:28 | LQ_EDIT |
37,787,766 | How can this button is developed in android | This button has outer white boundary and inner grey background.
The inner background contains an image(right tick) and a text(Apply).
https://files.slack.com/files-tmb/T0AHMUM8E-F1G9Y8U94-5bfa307623/screenshot_2016-06-13-16-02-01_720.png
I am able to make a shape like this (below).
https://files.slack.com/files-pri/T0AHMUM8E-F1GAD8FHP/screenshot_2016-06-13-16-09-52.png
I am using a shape in drawable(button.xml) given below
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<size android:height="85dp"
android:width="90dp"/>
<solid android:color="@color/grey"/>
<stroke android:color="@color/white" android:width="4dp"></stroke>
</shape>
</item>
<item
android:drawable="@drawable/checkmark_filled"
android:bottom="20dp"
android:left="20dp"
android:right="20dp"
android:top="20dp"/>
</layer-list>
and using imageview to use the shape
<ImageView
android:id="@+id/button_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button"/>
but i am not able to make a text in shape. Am i missing something or is there any way possible??
please help. | <java><android> | 2016-06-13 10:47:18 | LQ_EDIT |
37,787,932 | R.java error .. gen folder file is not generating in WORKLIGHT android environment | R.java error .. gen folder file is not generating in WORKLIGHT android environment.
I tried clean and build.
Android target version and everything goes fine.
Recreated the project.
Restarted eclipse .
But, still its in R.java error.
How to solve it.. please give me an answer.
I am using UBUNTU, IBM Mobile first platform. | <android><eclipse><r.java-file> | 2016-06-13 10:54:41 | LQ_EDIT |
37,788,907 | Have `npm version` not prepend "v" to the git tag | <p>Is there a way to tell <code>npm version</code> not to add the "v" prefix to the git tags? The reason I'm trying to do this is because I'm using dockerhub to build the node/docker project and the tags is used in the version of the docker image, having a "v" there is unusual and pointless.</p>
| <npm> | 2016-06-13 11:41:02 | HQ |
37,789,293 | Javascript show div after a few clicks | I'm new in Javascript and I can't find the answer for my question. Is it possible that my javascript views a div after if you clicked 5 times? If this is the case, how can I make this possible?
Thanks! | <javascript><html><button><click><show> | 2016-06-13 11:58:45 | LQ_EDIT |
37,790,029 | What is difference between arm64 and armhf? | <p>Raspberry Pi Type 3 has 64-bit CPU, but its architecture is not <code>arm64</code> but <code>armhf</code>.
What is the difference between <code>arm64</code> and <code>armhf</code>?</p>
| <linux><arm><debian><arm64> | 2016-06-13 12:36:33 | HQ |
37,790,081 | Analytics API & PHP - Get reports in different format | <p>The following code returns an object of <code>Google_Service_AnalyticsReporting_GetReportsResponse</code></p>
<pre><code>$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests($aRequests);
return $this->oAnalytics->reports->batchGet($body);
</code></pre>
<p>I'm wondering if I can get Reports in a different format, example:
<code>Array(Dimension,value)</code></p>
| <php><google-analytics><google-analytics-api> | 2016-06-13 12:38:52 | HQ |
37,790,218 | Github showing (develop) branch behind master by x commits | <p>I have been searching for the answer to this problem but have not found a solution or explanation. </p>
<p>We just switched to Github for our repo and are still trying to find the best way to use it in a team environment. Our current workflow is like this:</p>
<p>We have two branches <code>develop</code> and <code>master</code></p>
<ol>
<li><p>Developer clones <code>develop</code> branch onto their machine and creates a branch using: <code>git clone https://github.com/username/repo</code></p></li>
<li><p>Developer creates the branch for the feature they are working on using: <code>git checkout -b branchname</code></p></li>
<li><p>Developer finishes branch and pushes to Github using: <code>git pull</code> then <code>git push -u origin branchname</code></p></li>
<li><p>Developer creates pull request and the lead developer will first merge the just pushed branch into <code>develop</code> and then merges <code>develop</code> into <code>master</code></p></li>
</ol>
<p>Now the thing that concerns me and makes me wonder if we are doing something wrong is that when we look at the <code>master</code> branch in Github everything appears fine, but when we view the <code>develop</code> branch inside of Github it says <code>This branch is x commits behind master</code>. Everytime we merge a pull request the number <code>x</code> goes up. Github gives the option on the same line to "Compare" or create a "Pull Request" but when I click either of those options it shows the branches are identical.</p>
<p>I have tried to fixed this previously by merging <code>master</code> into <code>develop</code> which does make the branches both even but as soon as a pull request is merged we get the same problem again. </p>
<p>When we first switched to Github I don't ever recall seeing that <code>develop</code> was behind <code>master</code> but our workflow has not changed. I don't know if maybe I just didn't notice it before or not.</p>
<p>If I compare the commits between the branches I can see that in fact <code>develop</code> is behind <code>master</code> by <code>x</code> number of commits. The commits that are showing up are the ones where I merge <code>develop</code> into <code>master</code>. What I am wondering is if it is something to be concerned about? The branches are identical besides the number of commits. Are we not using Git/Github correctly and is that why we are getting this, or is this a normal thing?</p>
| <git><github><version-control> | 2016-06-13 12:45:47 | HQ |
37,791,846 | open file dialog return multiple file names (Visual Basic 2010 C#) | <p>How to make a OpenFileDialog1 object return multiple paths of the selected files to a multi-line textbox?</p>
| <c#><visual-studio-2010><textbox><openfiledialog> | 2016-06-13 14:06:23 | LQ_CLOSE |
37,792,206 | How do I initialize a final field in Kotlin? | <p>Let's say I declared a final field with <code>private final String s</code> (Java) or <code>val s</code> (Kotlin). During initialization I want to initialize the field with the result of a call to a remote service. In Java I would be able to initialize it in the constructor (e.g. <code>s = RemoteService.result()</code>), but in Kotlin I can't figure out how to do that because as far as I can tell the field has to be initialized in the same line it's declared. What's the solution here?</p>
| <kotlin> | 2016-06-13 14:21:59 | HQ |
37,793,118 | Load Pretrained glove vectors in python | <p>I have downloaded pretrained glove vector file from the internet. It is a .txt file. I am unable to load and access it. It is easy to load and access a word vector binary file using gensim but I don't know how to do it when it is a text file format.</p>
<p>Thanks in advance</p>
| <python-2.7><vector><nlp> | 2016-06-13 15:01:18 | HQ |
37,793,247 | how do i return values of variables from a function in python 2.7 | https://www.dropbox.com/s/ws6fofpexdi382a/rpg.py?dl=0
^above is the code: I don't know how to put the code in the question: i tried for an hour^
in the above code, there is a function called clas(). in that function, there are 8 variables about the player and ai stats. I want those variables to copy to the variables at lines 10-18, but im not sure how. any help is appreciated. | <python><python-2.7><function><variables> | 2016-06-13 15:08:46 | LQ_EDIT |
37,793,870 | sql - convert nvarchar to datetime | I have a set of dates which are in the current format:
yyyy-mm-dd hh:mm:ss.000
e.g.
2016-04-15 13:30:00.000
I have put them into a sql server table as nvarchar(MAX) but I need to convert them to datetime in a view.
I have tried the following pieces of code but neither work:
CONVERT(nvarchar(MAX), start_date, 120) AS start_date1
CAST(RIGHT(CONVERT(nvarchar(MAX), LEFT(start_date, 20), 120), 19) AS datetime) AS start_date1 | <sql><sql-server><date><datetime> | 2016-06-13 15:37:48 | LQ_EDIT |
37,794,978 | Find where a certain string of numbers occurs using Regex and python | Out of a large text file I want to extract all the places where "RA"+6 numbers after it occur. How would I do this?
For instance, I want the new txt file to look like
RA000000
RA111111
RA222222
RA333333
RA444444
Where other instances of RA do not show up either. | <python><regex> | 2016-06-13 16:38:33 | LQ_EDIT |
37,795,008 | about jquery - image gallery | $("#right").click(function(){
var nextIndex=currIndex.next();
var nextImg = nextIndex.children("img").attr("src");
$("#main").attr("src",nextImg);
currIndex = nextIndex;
});
$("#left").click(function(){
var prevIndex=currIndex.prev();
var prevImg = prevIndex.children("img").attr("src");
$("#main").attr("src",prevImg);
currIndex = prevIndex;
});
When I'm in the last image, the right or left arrow doest't work... hmm please help me | <jquery><loops> | 2016-06-13 16:39:58 | LQ_EDIT |
37,795,218 | How can I start writing IT article? | <p>I am new stack overflow user.</p>
<p>I see that I can post a new question by clicking 'question' button.</p>
<p>But if I need to share knowledge,e.g., write some 101 tutorial.</p>
<p>How can I start writing it?</p>
<p>Which menu or link should I go to to post my article?</p>
| <knowledge-management> | 2016-06-13 16:53:13 | LQ_CLOSE |
37,795,337 | Android: multiple intentservices or one intentservice with multiple intents? | <p>I'm a little confused about intentService. The docs say that if you send an intentService multiple tasks (intents) then it will execute them one after the other on one separate thread. My question is - is it possible to have multiple intentService threads at the same time or not? How do you differentiate in the code between creating three different intents on the same intentService (the same thread), or three separate intentServices each with it's own thread and one intent each to execute?</p>
<p>In other words, when you perform the command startService(intent) are you putting the intent in a single queue or does it start a new queue every time?</p>
<pre><code>Intent someIntent1 = new Intent(this, myIntentService.class);
Intent someIntent2 = new Intent(this, myIntentService.class);
Intent someIntent3 = new Intent(this, myIntentService.class);
startService(someIntent1);
startService(someIntent2);
startService(someIntent3);
</code></pre>
| <android><multithreading><android-service><android-intentservice><worker-thread> | 2016-06-13 17:00:37 | HQ |
37,796,139 | How to hydrate a Dictionary with the results of async calls? | <p>Suppose I have code that looks like this:</p>
<pre><code>public async Task<string> DoSomethingReturnString(int n) { ... }
int[] numbers = new int[] { 1, 2 , 3};
</code></pre>
<p>Suppose that I want to create a dictionary that contains the result of calling <code>DoSomethingReturnString</code> for each number similar to this:</p>
<pre><code>Dictionary<int, string> dictionary = numbers.ToDictionary(n => n,
n => DoSomethingReturnString(n));
</code></pre>
<p>That won't work because DoSomethingReturnString returns <code>Task<string></code> rather than <code>string</code>. The intellisense suggested that I try specifying my lambda expression to be async, but this didn't seem to fix the problem either.</p>
| <c#><async-await> | 2016-06-13 17:49:55 | HQ |
37,796,200 | (Webpack) Using the url-loader or file-loader, do I really have to include a require() in my .js for every static image I want to include? | <p>I'm still learning webpack, and I was having trouble getting images to show up in my production build until I stumbled upon some code which had a <code>require('path/to/image.png')</code> at the top of a .js file. So I tried it, and lo and behold it works.</p>
<p>This seems wonky to me. Do I really have to include one of these for every static image I need to serve? Is there a better way to do this? This is going to be messy if not.</p>
| <javascript><webpack> | 2016-06-13 17:53:23 | HQ |
37,796,365 | vb.net :: Why does "Settings.Save" needs admin permissions? | I'm using Visual Studio 2013 and Windows 7. I'm saving windows position when user close a form, and the program breaks in exception because I didn't run it whit admin permissions.
Thanks. | <vb.net><windows><permissions> | 2016-06-13 18:03:31 | LQ_EDIT |
37,796,449 | How to get the current url in the browser in Angular 2 using TypeScript? | <p>I need to get the current URL present in the browser in my Angular 2 application. </p>
<p>In JavaScript normally we do it using the window object.</p>
<p>How can I do this in Angular 2 using TypeScript?</p>
<p>Thanks.</p>
| <javascript><typescript><angular> | 2016-06-13 18:08:35 | HQ |
37,796,563 | HOW TO CREATE BUTTON FOR TRAFFIC LIGHT CODE IN JAVASCRIPT? | I intend to include a button in my traffic light code so that the user can click on it to activate the traffic light however, i am unsure of where to place it in my code. Any help would be greatly appreciated!
This is my code:
<head>
<script type="text/javascript">
var image1 = new Image()
image1.src = "traffic light_1.png"
var image2 = new Image()
image2.src = "traffic light_2.png"
var image3 = new Image()
image3.src = "traffic light_3.png"
var image4 = new Image()
image4.src = "traffic light_2.png"
</script>
</head>
<body>
<p><img src="traffic light_1.png" width="500" height="300" name="slide" /></p>
<script type="text/javascript">
var step=1;
function slideit()
{
document.images.slide.src = eval("image"+step+".src");
if(step<4)
step++;
else
step=1;
setTimeout("slideit()",3000);
}
slideit();
</script>
</body> | <javascript> | 2016-06-13 18:15:06 | LQ_EDIT |
37,797,622 | how to implement timer in asp.net c# | i want to implement a timer in asp.net web in which after a time period the text of button is changed. i created the button dynamically in gridview.
i tried this code.
protected void Timer2_Tick(object sender, EventArgs e)
{
Label2.Text = "Panel refreshed at: " +
DateTime.Now.ToLongTimeString();
for(int i=0;i<rowcount;i++)
{
Button button = new Button();
if (button.Text == "requested")
{
button.Text = "available";
}
}
}
but this code not work | <c#><asp.net> | 2016-06-13 19:24:24 | LQ_EDIT |
37,798,383 | Grab the first snippet of php code with RegEx | <p>I have several files with 2 php snippets nested with </p>
<p><code><? php code code code ?> <? php code code code ?></code></p>
<p>How can I just grab the first snippet including tags with RegEx?</p>
<p>Thanks!</p>
| <php><regex> | 2016-06-13 20:14:30 | LQ_CLOSE |
37,798,397 | Dart: create a list from 0 to N | <p>How can I create easily a range of consecutive integers in dart? For example:</p>
<pre><code>// throws a syntax error :)
var list = [1..10];
</code></pre>
| <list><dart><range> | 2016-06-13 20:15:27 | HQ |
37,798,911 | How to update Google Play Services for Android Studio 2.2 emulators? | <p>There are a number of variations of this question, however most are very old, and don't really answer the question at all. I'm NOT asking how to install Play Services, that is installed in the Studio 2.2 emulators. </p>
<p>The problem is that these emulators are using an old version of Play services.</p>
<p>When I run a test app that uses Firebase to facilitate Google login I get this alert dialog from a Nexus 5 API 23 emulator:</p>
<p><a href="https://i.stack.imgur.com/3W2aG.png"><img src="https://i.stack.imgur.com/3W2aG.png" alt="enter image description here"></a></p>
<p>In the onCreate method of my login activity I have this code:</p>
<pre><code>int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
switch(result) {
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
Log.d(TAG,"SERVICE_VERSION_UPDATE_REQUIRED");
break;
case ConnectionResult.SUCCESS:
Log.d(TAG, "Play service available success");
break;
default:
Log.d(TAG, "unknown services result: " + result);
}
</code></pre>
<p>This always returns SERVICE_VERSION_UPDATE_REQUIRED.</p>
<p>Clicking update in the alert dialog does nothing that I can detected. In the debug log I get this message when Play Services startup fails:</p>
<pre><code>W/GooglePlayServicesUtil: Google Play services out of date. Requires 9080000 but found 8489470
</code></pre>
<p>My application runs fine on a real Android device.</p>
<p>What simple thing am I missing?</p>
<p>TIA</p>
| <android><google-play-developer-api> | 2016-06-13 20:51:46 | HQ |
37,798,967 | Tooltip on click of a button | <p>I'm using <a href="https://clipboardjs.com/" rel="noreferrer">clipboard.js</a> to copy some text from a <code>textarea</code>, and that's working fine, but I want to show a tooltip saying "Copied!" if it was successfully copied like they do in the example given on their website. </p>
<p>Here's an example of it working without showing a tooltip: <a href="https://jsfiddle.net/5j50jnhj/" rel="noreferrer">https://jsfiddle.net/5j50jnhj/</a></p>
| <javascript><clipboard.js> | 2016-06-13 20:56:33 | HQ |
37,800,312 | Error #2032: Stream Error. URL: http://www.fashionboxpk.com/Test2.php"] | openHandler: [Event type="open" bubbles=false cancelable=false eventPhase=2]
progressHandler loaded:384 total: 384
Error opening URL 'http://www.fashionboxpk.com/Test2.php'
httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=406 responseURL=null]
ioErrorHandler: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://www.fashionboxpk.com/Test2.php"]
| <actionscript-3><flash> | 2016-06-13 22:44:31 | LQ_EDIT |
37,800,342 | UIControlState.Normal is Unavailable | <p>Previously for <code>UIButton</code> instances, you were able to pass in <code>UIControlState.Normal</code> for <code>setTitle</code> or <code>setImage</code>. <code>.Normal</code> is no longer available, what should I use instead?</p>
<pre><code>let btn = UIButton(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
btn.setTitle("title", for: .Normal) // does not compile
</code></pre>
<p><sup>(This is a canonical Q&A pair to prevent the flood of duplicate questions related to this <code>UIButton</code> and <code>UIControl</code> changes with iOS 10 and Swift 3)</sup></p>
| <ios><swift><uibutton><swift3><xcode8> | 2016-06-13 22:47:20 | HQ |
37,800,898 | pip install netmiko error | Installing collected packages: setuptools, idna, ipaddress, enum34, cryptography, paramiko, scp, pyyaml, netmiko
Found existing installation: setuptools 1.1.6
Uninstalling setuptools-1.1.6:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line 736, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 742, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
copytree(src, real_dst, symlinks=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/var/folders/8g/tm8510z944sfdk9pkzp1wd2c0000gn/T/pip-XZiudu-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")] | <python><python-2.7> | 2016-06-13 23:53:39 | LQ_EDIT |
37,801,111 | Can't get my Labels to update in tkinter | I'm trying to create a program in where you put a word in a box, press add, and this word goes to a list, which is also displayed on the right side. When I press the forward button the first thing on teh list is deleted. Problem is I can't get the labels to update when I press teh buttons / edit the list...
Thx in advance.
from tkinter import *
root = Tk()
root.title('Speakers List')
root.minsize(800, 600)
speakers = ['none']
spe = speakers[0]
def add():
if spe == 'none':
speakers.insert(0, [s])
e.delete(0, END)
spe.config(text=speakers[0])
else:
speakers[-2] = [s]
e.delete(0, END)
spe.config(text=speakers[0])
return
def forward():
if len(speakers) is 0:
return
else:
del speakers[0]
spe.config(text=speakers[0])
return
entry = StringVar()
e = Entry(root, width=30, font=("Arial", 20), textvariable=entry)
e.grid(row=0, sticky=W)
s = e.get()
button1 = Button(root, padx=10, pady=10, bd=5, text='Add', fg='black', command=add)
button1.grid(row=0, column=1)
button2 = Button(root, padx=10, pady=10, bd=5, text='Next', fg='black', command=forward)
button2.grid(row=1, column=1)
n = Label(root, font=("Arial", 35), bd=2, text=spe)
n.grid(row=1, sticky=W)
listdisplay = Label(root, font=('Arial', 20), text=speakers)
listdisplay.grid(row=0, column=10)
root.mainloop()
| <python><tkinter><label> | 2016-06-14 00:21:55 | LQ_EDIT |
37,801,596 | Get the Left element of a Either function | <p>I have a function in Haskell
<code>getCorError :: a -> b -> Either c [Error]</code>,
being <code>Error = Expected c</code> <br>
On another function, which returns <code>-> [Error]</code>, I want to return <code>[Expected (getCorError a b)]</code> if <code>getCorError</code> returns Left or [Error] otherwise.<br>
I get a type error when doing <code>[Expected (getCorError a b)]</code>. I have tried many things, like writing Left before the parentesis and after, and many others, and I haven't been able of doing this.
Appreciate any help. </p>
| <haskell><functional-programming> | 2016-06-14 01:29:54 | LQ_CLOSE |
37,801,851 | How to get rid of duplicate class errors in Intellij for a Mavenized project using Lombok | <p>I have a Maven managed Lombok project and I use Intellij. After building, I always get lots of errors in Intellij about duplicate classes because of the generated sources in target/generated-sources/delombok. Is there something I can do to git rid of these errors? Right now I just delete the target folder, but this is really irritating to have to do.</p>
<p>I have the standard configuration in Maven and the lombok source code in is in main/src/lombok:</p>
<pre><code> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.8.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
<profiles>
<profile>
<id>lombok-needs-tools-jar</id>
<activation>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.8.0</version>
<dependencies>
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</code></pre>
| <maven><intellij-idea><lombok><intellij-lombok-plugin> | 2016-06-14 02:04:06 | HQ |
37,802,686 | How to search and get result from database using php | <p>I have 2 tables in the same database:
Table1: with follow a field named "mark_allow"</p>
<p>Table2: with the following fields: "header", "title", "comments"</p>
<p>How can I use the result of what I get "mark_allow" in Table 1 and search for the corresponding content of "comments" in Table 2 using php?</p>
<p>Regards,</p>
| <php><html><mysql> | 2016-06-14 03:54:09 | LQ_CLOSE |
37,803,124 | How can I force 2 fields in a Django model to share the same default value without repeating populating method? | <p>I have a Django model <code>MyModel</code> as shown below. </p>
<p>It has two fields of type DateTimeField: <code>my_field1</code>, <code>my_field2</code></p>
<pre><code>from django.db import models
from datetime import datetime
class MyModel(models.Model):
my_field1 = models.DateTimeField(default=datetime.utcnow, editable=False)
my_field2 = models.DateTimeField()
</code></pre>
<p>I want both fields to default to the value of <code>datetime.utcnow()</code>. But I want to save <strong><em>the same</em></strong> value for both. It seems wasteful to call <code>utcnow()</code> twice.</p>
<p>How can I set the default value of <code>my_field2</code> so that it simply copies the default value of <code>my_field1</code>?</p>
<p>I tried adding an <code>__init__()</code> method to <code>MyModel</code> like this:</p>
<pre><code>def __init__(self, **kwargs):
super(MyModel, self).__init__(**kwargs)
if self.my_field2 is None:
self.my_field2 = self.my_field1
</code></pre>
<p>But doing so broke the model as you can see here:</p>
<pre><code>>>> MyModel.objects.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "MYvirtualenv/lib/python2.7/site-packages/django/db/models/query.py", line 138, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "MYvirtualenv/lib/python2.7/site-packages/django/db/models/query.py", line 162, in __iter__
self._fetch_all()
File "MYvirtualenv/lib/python2.7/site-packages/django/db/models/query.py", line 965, in _fetch_all
self._result_cache = list(self.iterator())
File "MYvirtualenv/src/django-cache-machine-master/caching/base.py", line 118, in __iter__
obj = iterator.next()
File "MYvirtualenv/lib/python2.7/site-packages/django/db/models/query.py", line 255, in iterator
obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
File "MYvirtualenv/lib/python2.7/site-packages/django/db/models/base.py", line 489, in from_db
new = cls(*values)
TypeError: __init__() takes exactly 1 argument (2 given)
</code></pre>
<p>What is the proper remedy?
I need the value of <code>my_field2</code> to default to the value of <code>my_field1</code> (without calling the repeating the call to the default function that populated <code>my_field1</code>)</p>
| <python><django> | 2016-06-14 04:40:00 | LQ_CLOSE |
37,804,090 | what does putting this '|' on function parameter do? | im learning how to write SDL program in C++, but i came across this code:
SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
^i have no idea what this means??
i dont know if this is a specific c++ stuff because i didnt use c++ for a very long time and i almost forget everything....
my guess coming from shell scripting background suggests its a pipe(i know its obviously not that :p), or its just a bitwise OR(idk if thats it either).
what does this '|' mean when putting it on a function parameter like the code above? | <c++> | 2016-06-14 06:04:53 | LQ_EDIT |
37,804,279 | How can we use tqdm in a parallel execution with joblib? | <p>I want to run a function in parallel, and wait until all parallel nodes are done, using joblib. Like in the example:</p>
<pre><code>from math import sqrt
from joblib import Parallel, delayed
Parallel(n_jobs=2)(delayed(sqrt)(i ** 2) for i in range(10))
</code></pre>
<p>But, I want that the execution will be seen in a single progressbar like with <strong>tqdm</strong>, showing how many jobs has been completed. </p>
<p>How would you do that?</p>
| <python><parallel-processing><joblib><tqdm> | 2016-06-14 06:17:42 | HQ |
37,805,599 | Using npm with an MVC project | <p>I am getting a bit confused here.</p>
<p>I have an <code>MVC</code> 5 project, I want to use the <code>npm</code> for managing my javascript packages.</p>
<p>I installed <code>npm</code> from <code>nuget</code> and here i am stuck, I cant find the commandline console window or anything like that.</p>
<p>All the info i see online is about node projects.</p>
<p>Can someone direct me to a relevant tutorial. </p>
<p>Using visual studio 2013, MVC 5.</p>
| <asp.net-mvc><visual-studio><npm> | 2016-06-14 07:28:22 | HQ |
37,805,995 | I am facing a SQLite syntax error in Android Studio.Need help fast, this part of my project which I have to submit tomorrow | The below code generates this error and my app crashes:
android.database.sqlite.SQLiteException: near "@kiit": syntax error (code 1): , while compiling: Select * from LoginMaster where UserID = 1505293@kiit.ac.in and Password = harshit999;
when I enter the userid and password which i have already successfully inserted into the table.
package com.harshit.csdp;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Typeface;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
public class LoginActivity extends AppCompatActivity {
private EditText kiitmail, pass;
private Spinner spn;
private TextInputLayout inputKiitMail;
SQLiteDatabase sqldb;
Button register, login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
sqldb = openOrCreateDatabase("xyza", Context.MODE_PRIVATE,null);
final String adminEmail = "admin@kiit.ac.in";
final String adminPass = "admin123";
final String adminStatus = "Administrator" ;
boolean firstRun = getSharedPreferences("preferences", MODE_PRIVATE).getBoolean("firstRun", true);
if(firstRun){
getSharedPreferences("preferences", MODE_PRIVATE).edit().putBoolean("firstRun", false).commit();
Toast.makeText(getApplicationContext(),"First Run Detected.\nDatabase, tables and Administrator account created.",Toast.LENGTH_LONG).show();
sqldb.execSQL("Create table LoginMaster(UserID varchar, Password varchar,Status varchar)");
sqldb.execSQL("insert into LoginMaster values('"+adminEmail+"','"+adminPass+"','"+adminStatus+"')");
sqldb.execSQL("Create table StudentMaster(UserID varchar, RollNo varchar,Batch varchar, Branch varchar, Degree varchar, JoiningYear varchar)");
sqldb.execSQL("Create table FacultyMaster(UserID varchar, Degree varchar, JoiningYear varchar)");
sqldb.execSQL("Create table StudentPersonalMaster(UserID varchar, Name varchar, DOB varchar, Gender varchar, Address varchar, MobNumber varchar)");
sqldb.execSQL("Create table FacultyPersonalMaster(UserID varchar, Name varchar, DOB varchar, Gender varchar, MobNumber varchar)");
sqldb.execSQL("Create table StudentAcademicMaster(UserID varchar, AcademicAchievement varchar,Sports varchar, Cultural varchar, Others varchar, HighSchool varchar)");
sqldb.execSQL("Create table StudentTechnicalMaster(UserID varchar, PLanguage varchar,Database varchar, OS varchar, Software varchar, OtherSkill varchar, IndustryExperience varchar, AcademicProject varchar)");
sqldb.execSQL("Create table NoticeMaster(UserID varchar, Title varchar,Content varchar, Type varchar, Date varchar)");
}
kiitmail = (EditText)findViewById(R.id.editText1);
pass = (EditText)findViewById(R.id.editText2);
spn = (Spinner)findViewById(R.id.spinner1);
login = (Button)findViewById(R.id.button1);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(spn.getSelectedItem().toString().equals(adminStatus)){
Intent intent = new Intent(getApplicationContext(),AdminPage.class);
startActivity(intent);
}
else if(verifyLogin()&&spn.getSelectedItem().toString().equals("Student")){
String km = kiitmail.getText().toString();
Intent studentPage = new Intent(LoginActivity.this, StudentPage.class);
studentPage.putExtra("uid",km);
startActivity(studentPage);
}
else{
Toast.makeText(getApplicationContext(),"Fuck you",Toast.LENGTH_LONG).show();
}
}
});
Typeface font = Typeface.createFromAsset( getAssets(), "fontawesome.ttf" );
TextView textView7 = (TextView)findViewById(R.id.textView7);
TextView textView8 = (TextView)findViewById(R.id.textView8);
textView7.setTypeface(font);
textView8.setTypeface(font);
register = (Button)findViewById(R.id.button2);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),InitialRegistrationActivity.class);
startActivity(i);
}
});
}
public boolean verifyLogin(){
String checkMailID = kiitmail.getText().toString();
String checkPassword = pass.getText().toString();
Cursor cursor = sqldb.rawQuery("Select * from LoginMaster where UserID = "+checkMailID+" and Password = "+checkPassword+";", null);
if(cursor.getCount() <= 0){
cursor.close();
return false;
}
cursor.close();
return true;
}
}
| <android><android-studio><android-sqlite> | 2016-06-14 07:47:52 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.