Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
35,603,494 | Validation travis.yml file locally | <p>Are there any tools (CLI or with GUI) for validation travis.yml file locally at my computer without the need of pushing it? Maybe there are some plugins for text editors or other approaches to solve this problem?</p>
| <validation><yaml><travis-ci> | 2016-02-24 13:25:39 | HQ |
35,603,921 | Javascript regex to parse human readable dates | <p>I have a dates in String in Javascript that could look like: </p>
<pre><code>1h
1h2m
1d3m4s
2d2h2m2s2ms
1ms
3s5ms
</code></pre>
<p>The indicators will not change, they are <code>d, h, m, s, ms</code></p>
<p>What would be a good regex to parse the numbers out:
for <code>3s5ms</code>, it should be:</p>
<pre><code>parsed = [0,0,0,3,5]
</code></pre>
<p>for <code>1d4m</code>, it should be:</p>
<pre><code>parsed = [1,0,4,0,0]
</code></pre>
| <javascript><regex><parsing> | 2016-02-24 13:45:30 | LQ_CLOSE |
35,604,730 | Nodejs/Express: Error: Failed to lookup view "error" in views directory | <p>I switched my nodejs template engine over to ejs (from jade). When I run my app.js with my ejs template, I receive a series of "Failed to lookup view 'error' in views" logs.</p>
<p>Some of which include:</p>
<pre><code>GET /css/bootstrap.min.css 500 12.588 ms - 1390
Error: Failed to lookup view "error" in views directory
...
GET /css/clean-blog.min.css
Error: Failed to lookup view "error" in views directory
...
GET /js/bootstrap.min.js
Error: Failed to lookup view "error" in views directory
...
GET /js/jquery.js
Error: Failed to lookup view "error" in views directory
</code></pre>
<p>Thing is, many of these dependencies are included in the template itself (included via script tags). What is the proper place to get these to work in express? It seems like express ultimately should not be looking for these in the <code>views</code> folder (since they aren't views).</p>
| <javascript><node.js><express><ejs> | 2016-02-24 14:22:56 | HQ |
35,604,984 | Firebase & Swift: How to use another database for storing larger files? | <p>I am currently trying to build a chat application in swift whilst using Firebase for real-time messaging. My only issue is I want users to send images, I want them to have profiles with images but I know Firebase has limited storage (or at least storage per pay tier is low for the number of connections you get)</p>
<p>So I would like to know how to connect up another database and make calls when needed between the two. So when and image is sent in a message, rather than Firebase storing the image, it stores a URL to the image in the other database.</p>
<p>I am under the impression something like AWS S3 is my best bet. any help is appreciated!</p>
| <ios><swift><firebase><chat><storage> | 2016-02-24 14:33:21 | HQ |
35,604,987 | Is there a proper way of resetting a component's initial data in vuejs? | <p>I have a component with a specific set of starting data:</p>
<pre><code>data: function (){
return {
modalBodyDisplay: 'getUserInput', // possible values: 'getUserInput', 'confirmGeocodedValue'
submitButtonText: 'Lookup', // possible values 'Lookup', 'Yes'
addressToConfirm: null,
bestViewedByTheseBounds: null,
location:{
name: null,
address: null,
position: null
}
}
</code></pre>
<p>This is data for a modal window, so when it shows I want it to start with this data. If the user cancels from the window I want to reset all of the data to this. </p>
<p>I know I can create a method to reset the data and just manually set all of the data properties back to their original:</p>
<pre><code>reset: function (){
this.modalBodyDisplay = 'getUserInput';
this.submitButtonText = 'Lookup';
this.addressToConfirm = null;
this.bestViewedByTheseBounds = null;
this.location = {
name: null,
address: null,
position: null
};
}
</code></pre>
<p>But this seems really sloppy. It means that if I ever make a change to the component's data properties I'll need to make sure I remember to update the reset method's structure. That's not absolutely horrible since it's a small modular component, but it makes the optimization portion of my brain scream. </p>
<p>The solution that I thought would work would be to grab the initial data properties in a <code>ready</code> method and then use that saved data to reset the components:</p>
<pre><code>data: function (){
return {
modalBodyDisplay: 'getUserInput',
submitButtonText: 'Lookup',
addressToConfirm: null,
bestViewedByTheseBounds: null,
location:{
name: null,
address: null,
position: null
},
// new property for holding the initial component configuration
initialDataConfiguration: null
}
},
ready: function (){
// grabbing this here so that we can reset the data when we close the window.
this.initialDataConfiguration = this.$data;
},
methods:{
resetWindow: function (){
// set the data for the component back to the original configuration
this.$data = this.initialDataConfiguration;
}
}
</code></pre>
<p>But the <code>initialDataConfiguration</code> object is changing along with the data (which makes sense because in the read method our <code>initialDataConfiguration</code> is getting the scope of the data function. </p>
<p>Is there a way of grabbing the initial configuration data without inheriting the scope? </p>
<p>Am I overthinking this and there's a better/easier way of doing this? </p>
<p>Is hardcoding the initial data the only option?</p>
| <javascript><mvvm><vue.js> | 2016-02-24 14:33:28 | HQ |
35,605,191 | Filter text file with another text file using php | I have got two text files and i need to filter file1 with file2 and put the results in file3.
file1:
1232131-72-427-Q john johnson -----more data----------more data-----<br>
8765438-43-542-T peter dudeson -----more data----- -----more data-----<br>
3456761-21-742-G frank zena -----more data----------more data-----<br>
0924560-23-124-O marin franklin -----more data----------more data-----<br>
2345333-21-423-P pin dudeson-----more data----------more data-----<br>
5434225-21-983-A chow ching -----more data----------more data-----
file2:<br>
8765438-43-542-T<br>
0924560-23-124-O<br>
5434225-21-983-A
outputfile:<br>
8765438-43-542-T peter dudeson-----more data----------more data----- <br>
0924560-23-124-O marin franklin-----more data----------more data----- <br>
5434225-21-983-A chow ching-----more data----------more data-----
so basically it has to check the numbers+oneletter and delete all the lines that do not match and keep the full lines that do match. I hope someone helps me with this because im stuck on it for way too long now. | <php><file> | 2016-02-24 14:42:51 | LQ_EDIT |
35,605,408 | Dagger 2 injection in non Activity Java class | <p>I am trying to use Dagger2 for DI, it works perfectly fine for Activity/Fragment related classes where there is a onCreate lifecycle event. Now I have a plain Java class which I want to be injected. Any ideas as to how to go about it would be appreciated. The code I have looks like this :</p>
<p>BasicMoviesUsecaseComponent.java - </p>
<pre><code>@PerActivity
@Component(dependencies = AppComponent.class, modules = BasicMoviesUsecasesModule.class)
public interface BasicMoviesUsecasesComponent {
void inject(PaymentsManager paymentsManager);
}
</code></pre>
<p>DatabaseModule.java - </p>
<pre><code> @Module
public class DatabaseModule {
@Provides @Singleton
Realm provideRealmInstance(Context context) {
return Realm.getInstance(context);
}
@Provides @Singleton
DatabaseProvider provideDatabaseInstance(Realm realm) {
return new DatabaseProvider(realm);
}
@Provides @Singleton
SharedPreferences provideSharedPrefs(Context context) {
return context.getSharedPreferences(context.getPackageName()+"_prefs", Context.MODE_PRIVATE);
}
@Provides @Singleton
SharedPreferencesManager provideSharedPreferencesManager(SharedPreferences sharedPreferences) {
return new SharedPreferencesManager(sharedPreferences);
}
@Provides @Singleton
PaymentsManager providePaymentsManager(SharedPreferencesManager sharedPreferencesManager) {
return new PaymentsManager(sharedPreferencesManager);
}
}
</code></pre>
<p>AppComponent.java - </p>
<pre><code> @Singleton
@Component(modules = {
ApplicationModule.class,
DomainModule.class,
DatabaseModule.class
})
public interface AppComponent {
Bus bus();
Realm realm();
DatabaseProvider dbProvider();
SharedPreferencesManager sharedPreferencesManager();
}
</code></pre>
<p>Here is the class I need to inject the SharedPreferencesManager into and I am unable to do so :</p>
<p>MyManager.java - </p>
<pre><code> private class MyManager {
private SharedPreferencesManager manager;
@Inject
MyManager(SharedPreferencesManager manager){
this.manager = manager;
}
private void initializeDependencyInjector() {
BMSApplication app = BMSApplication.getInstance();
DaggerBasicMoviesUsecasesComponent.builder()
.appComponent(app.getAppComponent())
.basicMoviesUsecasesModule(new BasicMoviesUsecasesModule())
.build().inject(PaymentsManager.this);
}
}
</code></pre>
<p>How do I call initializeDependencyInjector() ? </p>
| <java><android><dependency-injection><dagger-2> | 2016-02-24 14:51:57 | HQ |
35,605,664 | Best performance: count in a loop or outside? | <p>Perhaps this question has been asked several times but I can't find a proper answer here or in Google so apologies if this is a dupe or something like that but here I go... </p>
<p>What's the best way to achieve performance in a loop:</p>
<ol>
<li><p><code>count($var)</code> each time</p>
<pre><code>for ($i=0;$i<count($var);$i++) {
// do something
}
</code></pre></li>
<li><p>put a var outside and use that var:</p>
<pre><code>$cnt = count($var);
for ($i=0;$i<$var;$i++) {
// do something
}
</code></pre></li>
</ol>
<p>Is there any PHP script or code to show execution times and so on? I mean something for benchmark and see the results on this cases?</p>
| <php><benchmarking><php-5.6><php-7> | 2016-02-24 15:02:36 | LQ_CLOSE |
35,605,836 | Loop while checking if element in a list in Python | <p>Let's say I have a simple piece of code like this:</p>
<pre><code>for i in range(1000):
if i in [150, 300, 500, 750]:
print(i)
</code></pre>
<p>Does the list <code>[150, 300, 500, 750]</code> get created every iteration of the loop? Or can I assume that the interpreter (say, CPython 2.7) is smart enough to optimize this away?</p>
| <python><python-2.7><loops><python-3.x><interpreter> | 2016-02-24 15:13:33 | HQ |
35,605,956 | Mutithreaded chat in windows C++ | i'm trying to do a simple multithreaded client/server chat but i have a problem, the program go in a loop without show any message, all i have is the message "Received: " and nothing more.
Here the codes
Server code:
#pragma comment(lib, "WS2_32.lib") // link con Ws2_32.lib
#include <Winsock2.h>
#include <Windows.h> //Windows.h viene comunque inclusa dentro a Winsock2.h
#include <iostream>
#include <cstdio>
#include <pthread.h>
#define DEFAULT_PORT 54345 //Stabilisco come porta principale la 54345
using namespace std;
void *ricezione(void *)
{
SOCKET client;
long app;
char buff[256];
memset(&buff,0,sizeof(buff));
while(1)
{
memset(&buff,0,sizeof(buff));
app=recv(client,buff,sizeof(buff), 0);
if(app<0) cout<<"Impossibile ricevere messaggio"<<endl;
else cout<<"Client: "<<buff<<endl;
}
}
int main()
{
pthread_t threadA[5];
cout<<"Server TCP/IP"<<endl;
char recvbuf[256]; //Buff di ricezione messaggio
char serverAddrStr[256]={'\0'}; //Contiene indirizzo IP da inserire, all'inizio è vuoto
#ifdef WIN32 //Mi preparo per l'utilizzo della winsocket (Serve per forza)
WSADATA wsaData;
WSAStartup (0x0101,&wsaData);
#endif
long res; //Variabile utile
WSADATA wsadata; //La winsocket
res = WSAStartup(MAKEWORD(2, 1), &wsadata); //Prendo dll winsocket e la inizializzo
if(res==0) cout<<"Winsocket inizializzata con successo!"<<endl; //Controllo sull'inizializzazione della winsocket
else cout<<"Errore nell'inizializzazzione della winsocket'"<<endl;
SOCKET slisten,client; //Dichiaro i Socket Descriptor
cout<<"Inserisci indirizzo al quale connettersi: ";
cin.getline(serverAddrStr,256);
slisten=socket(AF_INET,SOCK_STREAM,0); //Creo il socket
if(slisten!=INVALID_SOCKET) cout<<"Socket creato con successo!"<<endl;
else cout<<"Errore nella creazione del socket"<<endl;
//Varie informazioni del socket
sockaddr_in info; //sockaddr
info.sin_addr.s_addr=INADDR_ANY; //Accetto chiunque
info.sin_family=AF_INET; //Famiglia di protocolli
info.sin_port=htons(54345); //Converto la porta nell'ordine (big-endian) del TCP/IP - Più significativo meno significativo
int infolen=sizeof(info); //Variabile utile a contenere la dimensione della sockaddr
res=bind(slisten,(struct sockaddr*)&info, infolen); //Avvio collegamento server-client
if(res!=SOCKET_ERROR) cout<<"Connessione avvenuta con successo!"<<endl; //Controllo se la connessione è avvenuta correttamente
else cout<<"Errore di connessione..."<<endl;
res=listen(slisten,SOMAXCONN); //Avvio ascolto client e ascolto il numero massimo di connessioni
if(res!=SOCKET_ERROR) cout<<"Sono in ascolto sulla porta 54345"<<endl; //Controllo se è possibile mettersi in ascolto sulla porta 54345
else cout<<"Impossibile mettersi in ascolto sulla porta 54345"<<endl;
sockaddr_in clientinfo; //Struttura che contiene le informazioni del client
int clientinfolen=sizeof(clientinfo); //Lunghezza struttura clientinfo, mi serve per dopo
int nthread=0;
while(nthread<5) //Ciclo fino a quando posso
{
clientinfolen= sizeof(clientinfo);
cout<<"Sono in ascolto di un client"<<endl;
cout<<"nthread: "<<nthread<<endl;
client=accept(slisten,(struct sockaddr*)&clientinfo,&clientinfolen); //Avvio la comunicazione
if(client<0)
{
cout<<"Non posso accettare la connessione"<<endl;
return 0;
}
cout<<"Connessione riuscita"<<endl;
res=pthread_create(&threadA[nthread],NULL,ricezione,NULL);
if(res!=0) cout<<"Errore creazione thread"<<endl;
nthread++;
}
for(int i=0;i<5;i++) pthread_join(threadA[i],NULL);
closesocket(client); //Chiudo socket client
closesocket(slisten); //Chiudo socket server
WSACleanup(); //Termino utilizzo delle Winsock
system("PAUSE");
return 0;
}
And here the client code:
#pragma comment(lib,"ws2_32.lib")
#include <cstdio>
#include <iostream>
#include <WinSock2.h>
#include <Windows.h>
using namespace std;
int main()
{
cout<<"Client TCP/IP"<<endl;
char sendbuf[256]; //Buffer di invio
long res; //Variabile utile
WSADATA wsadata; //Variabile che contiene informazioni Winsocket
SOCKET sConnect; //Variabile di tipo socket
sockaddr_in conpar;
res=WSAStartup(MAKEWORD(2,0),&wsadata); //Mi preparo per l'utilizzo delle winsocket
if(res==0) cout<<"Inizializzazione della winsocket avvenuta con successo!"<<endl; //Controllo creazione winsocket
else cout<<"Inizializzazione della winsocket fallita"<<endl;
sConnect=socket(AF_INET,SOCK_STREAM,0); //Creo la socket
if(sConnect!=INVALID_SOCKET) cout<<"Socket creato con successo!"<<endl; //Controllo creazione socket
else cout<<"Errore nella creazione del socket, errore: "<<WSAGetLastError()<<endl;
hostent *serverInfo; //Struttura che contiene le informazioni dell'host
char serverAddrStr[256]; //Indirizzo IP
cout<<"Inserisci l'indirizzo al quale connettersi: ";
cin.getline(serverAddrStr,256); //prendo indirizzo IP in input
//Inserisco informazioni nella struttura conpar
conpar.sin_addr.S_un.S_addr=inet_addr(serverAddrStr); //Indirizzo al quale connettersi
conpar.sin_family=AF_INET; //Famiglia di protocolli che accetto
conpar.sin_port=htons(54345); //Porta al quale connettersi in formato big-endian
int conparlen=sizeof(conpar); //Dimensione struttura
res=connect(sConnect,(struct sockaddr*)&conpar,conparlen); //Connessione
if(res!=SOCKET_ERROR) cout<<"Connessione avvenuta con successo!"<<endl; //Controllo sulla connessione
else cout<<"Connessione fallita, errore: "<<WSAGetLastError()<<endl;
while(1) //Ciclo fino a quando non chiudo
{
memset(&sendbuf,0,sizeof(sendbuf)); //Inizializzo buffer di invio a 0
cout<<"Invia: ";
cin.getline(sendbuf,256);; //Prendo messaggio
res=send(sConnect,sendbuf,strlen(sendbuf),0); //Invio messaggio
}
closesocket(sConnect); //Chiudo socket
WSACleanup(); //Termino utilizzo winsocket
system("PAUSE");
return 0;
}
I'm using posix thread in windows system with the package installated.
Thanks all for the help :)
| <c++><multithreading><server><client><chat> | 2016-02-24 15:19:30 | LQ_EDIT |
35,606,147 | How to call javascript function from <script> tag? | <pre><code><html>
<script>
//some largeFunction()
//load a script dynamically based on the previous code
document.write("<script src='//...'><\/script>");
</script>
</html>
</code></pre>
<p>Question: is it possible to move the <code>largeFunction()</code> out of the static <code>html</code> page and put it into a <code>js</code> file? If yes, how could I then call that function statically before writing the <code><script></code> tag?</p>
| <javascript><html> | 2016-02-24 15:27:53 | HQ |
35,606,426 | Order of regular expression operator (..|.. ... ..|..) | <p>What is the order of priority of expressions in <code>(..|. .. .|..)</code> operator - left to right, right to left or something else?</p>
| <c#><regex> | 2016-02-24 15:39:17 | HQ |
35,606,790 | How to add a dependency to another project properly using gradle? | <p>Hello I am new to gradle and it is a little bit confusing for me. How should I add a dependency in my gradle configuration to have access to <em>B1.java</em> in <em>projectA1</em>? Project B is gradle project and project A is just a folder with another gradle projects.</p>
<p>Here is my structure:</p>
<ol>
<li>Workspace:
<ul>
<li>ProjectA
<ul>
<li>projectA1
<ul>
<li>... </li>
<li><strong>here I want to have access to <em>B1.java</em></strong></li>
<li>build.gradle</li>
</ul></li>
<li>projectA2
<ul>
<li>...</li>
<li>build.gradle</li>
</ul></li>
</ul></li>
<li>ProjectB
<ul>
<li>projectB1
<ul>
<li><em>B1.java</em></li>
<li>... </li>
<li>build.gradle</li>
</ul></li>
<li>projectB2
<ul>
<li>...</li>
<li>build.gradle</li>
</ul></li>
<li>build.gradle</li>
</ul></li>
</ul></li>
</ol>
<p>I tried to read gradle documentation, but it is not clear for me. Any help appreciated. Thanks!</p>
| <java><gradle><dependencies><build.gradle><project-structure> | 2016-02-24 15:54:30 | HQ |
35,607,760 | Check if a Set of tuples contains a Set of 2 elements | Given these two collections :
val countrys = Set(("Paris","France"),("Berlin","Germany"),("Madrid","Spain"))
val values = Set("Paris","France")
How can I check if `countrys` contains `values` ?
| <scala><set><tuples> | 2016-02-24 16:33:03 | LQ_EDIT |
35,608,200 | React-Native Lowest Android API level | <p>I am doing some research on react-native and android. Does anyone know the lowest api level react-native supports for android? I've searched all over their docs page and couldn't find it. </p>
| <android><react-native> | 2016-02-24 16:51:26 | HQ |
35,609,390 | Join two tables using a medicore relational table | <p>I have three tables</p>
<p>table1</p>
<p><a href="https://i.stack.imgur.com/Q4TJW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q4TJW.png" alt="enter image description here"></a></p>
<p>table2</p>
<p><a href="https://i.stack.imgur.com/XudWX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XudWX.png" alt="enter image description here"></a></p>
<p>table3 (This is the relational table of table1 and table 2)</p>
<p><a href="https://i.stack.imgur.com/7Ebsk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Ebsk.png" alt="enter image description here"></a></p>
<p>How can I join table1 and table2 using table3 ? I need the following output</p>
<p>What will be the sql?</p>
<p><a href="https://i.stack.imgur.com/mt40n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mt40n.png" alt="enter image description here"></a></p>
| <mysql><sql> | 2016-02-24 17:47:46 | LQ_CLOSE |
35,610,053 | Jenkins delete builds older than latest 20 builds for all jobs | <p>I am in the process of cleaning up Jenkins (it was setup incorrectly) and I need to delete builds that are older than the latest 20 builds for every job.</p>
<p>Is there any way to automate this using a script or something?</p>
<p>I found many solutions to delete certain builds for specific jobs, but I can't seem to find anything for all jobs at once.</p>
<p>Any help is much appreciated.</p>
| <bash><jenkins><groovy><jobs> | 2016-02-24 18:23:51 | HQ |
35,610,336 | Write longest and shortest palindrom from text file | i am trying to write a program what will write longest and shortest palindrom from words in text file. My code looks like this now:
static void Main(string[] args)
{
string[] lines = System.IO.File.ReadAllLines(@"C:\palindromy.txt");
foreach (string line in lines)
{
char[] charArray = line.ToCharArray();
for (int i = 0; i < 1; i++)
{
Array.Reverse(charArray);
bool a = charArray.SequenceEqual(line);
while(a == true)
{
Console.WriteLine(line); /that will just write all palindroms
break;
}
}
}
}
I am curently just writing all palindroms, but i need to write just longest and shortest one. | <c#><arrays><string><text-files><palindrome> | 2016-02-24 18:39:04 | LQ_EDIT |
35,610,437 | Using dplyr to conditionally replace values in a column | <p>I have an example data set with a column that reads somewhat like this:</p>
<pre><code>Candy
Sanitizer
Candy
Water
Cake
Candy
Ice Cream
Gum
Candy
Coffee
</code></pre>
<p>What I'd like to do is replace it into just two factors - "Candy" and "Non-Candy". I can do this with Python/Pandas, but can't seem to figure out a dplyr based solution. Thank you!</p>
| <r><dplyr> | 2016-02-24 18:44:26 | HQ |
35,610,487 | How do my router obtain normal ip address | <p>My <code>ifconfig</code> configuration is <code>inet addr:192.168.1.3</code> and when I try to get know the router ip by executing <code>ip route show | grep -i 'default via'| awk '{print $3 }'</code> i get <code>192.168.1.1</code></p>
<p>I remember this ipv4 addresses from provider handbook, so they are roughly the same for all ethernet and routers config in my district. </p>
<hr>
<p>The questions are:</p>
<ol>
<li>How can I get know my real <code>ip</code> address?</li>
<li>Who and where assigns me unique <code>ip</code>?</li>
<li>Why do provider assign this standard ip for everyone? </li>
<li>If I get know my unique id will I be able to establish TCP | UDP connection? How does transmission works <code>unique_ip</code> -> 'router_ip' -> 'ethernet_ip' will not it be passed to my friend why share with me router? </li>
</ol>
| <networking> | 2016-02-24 18:46:54 | LQ_CLOSE |
35,610,831 | php am I expecting something thats impossible? | <p>I am a beginner so please be patient with me. I have a website and a database and im looking to achieve the following...</p>
<p>A user loads example.com, whilst loading the html page an embedded php script grabs some data from an sql db, prints the data into the page and the user gets shown an sql value within the loaded html page. How is this possible?</p>
<p>I have searched all over the net but keep getting examples that echo onto a php page, not an html page. Thanks in advance.</p>
| <php><html><sql> | 2016-02-24 19:04:30 | LQ_CLOSE |
35,610,849 | how to solve this expression taking in mind precedence and associativity in c? | Int m=4 ,s=5;
m = (p=s) * (p==s);
Printf("%d",m);
How to solve this expression in c?
What will be the value of m?
How parenthesis () changes the precedence of operators in this example?
| <c> | 2016-02-24 19:05:18 | LQ_EDIT |
35,611,019 | Chech whether the USER is authenticated/not while trying to browse using direct URL | Thanks in advance.
I want to restrict users based on their authorization to my application while they are trying to access URL directly in browser. We are getting the flags from Database table whether the user has access to perticular services or not. We are having n number of controllers, so I can't use session variables. Can you please suggest that how can I use those flags to restrict users by custom actionfilters. | <asp.net-mvc-3><custom-action-filter> | 2016-02-24 19:14:32 | LQ_EDIT |
35,611,465 | python scikit-learn clustering with missing data | <p>I want to cluster data with missing columns. Doing it manually I would calculate the distance in case of a missing column simply without this column.</p>
<p>With scikit-learn, missing data is not possible. There is also no chance to specify a user distance function.</p>
<p>Is there any chance to cluster with missing data?</p>
<p>Example data:</p>
<pre><code>n_samples = 1500
noise = 0.05
X, _ = make_swiss_roll(n_samples, noise)
rnd = np.random.rand(X.shape[0],X.shape[1])
X[rnd<0.1] = np.nan
</code></pre>
| <python><scikit-learn><cluster-analysis><missing-data> | 2016-02-24 19:39:02 | HQ |
35,611,643 | Function using PHP that converts a base 36 string to a base 10 integer | <p>Can someone show me how I would write a php function that converts a base 36 string to a base 10 integer without using the base convert function </p>
<p>the function should work like this </p>
<pre><code>echo base36_to_base10('614qa'); //prints 10130482
echo base36_to_base10('614z1'); //prints 10130797
</code></pre>
| <php> | 2016-02-24 19:48:23 | LQ_CLOSE |
35,612,383 | How to make a "Rate this app" link in React Native app? | <p>How to properly link a user to reviews page at App Store app in React Native application on iOS?</p>
| <ios><app-store><react-native> | 2016-02-24 20:26:45 | HQ |
35,612,826 | Wamp on Raspberry Pi | <p>For a school project, I need to install a server with Wamp but I need to have access everywhere so maybe is it possible to install it on my Raspberry. So is it possible and if is it how ?
Thanks you so much for your help</p>
| <php><raspberry-pi><wamp><wampserver> | 2016-02-24 20:51:13 | LQ_CLOSE |
35,613,521 | How can I increase values in an array by a percent input by the user? In C# | <p>So I want to store several values in an array, then I want to modify those values that I stored by a percent that I also input. This is what I have so far, I just don't know how to call the values to be modified by a percent that I input.</p>
<pre><code>static void Main(string[] args)
{
double[] array = new double[5];
Console.WriteLine("Enter 5 values.");
for (int i = 0; i < 5; i++)
{
array[i] = Convert.ToDouble(Console.ReadLine());
}
double sum = 0;
foreach (double d in array)
{
sum += d;
}
Console.WriteLine("The values you've entered and their index number.");
Console.WriteLine("{0}{1,8}", "index", "value");
for (int counter = 0; counter < 5; counter++)
Console.WriteLine("{0,5}{1,8}", counter, array[counter]);
Console.WriteLine("Enter percent increase ");
double percent;
percent = 1+1;
Console.WriteLine("The percent is " + percent);
Console.WriteLine("The new values increased by Percent are ");
Console.ReadLine();
}
</code></pre>
| <c#> | 2016-02-24 21:29:08 | LQ_CLOSE |
35,613,863 | Making TabLayout text bold | <p>I'm using the TabLayout from the Android Design Support library and want to style its text (title). Specifically making it bold. How to achieve that in <strong>XML</strong> only?</p>
<pre><code><android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
app:tabTextColor="@color/white"
app:tabSelectedTextColor="@color/white"
app:tabIndicatorColor="@color/accent"
android:layout_height="wrap_content"
app:tabIndicatorHeight="3dp" />
</code></pre>
| <android><android-tablayout> | 2016-02-24 21:50:04 | HQ |
35,613,913 | Loop back to program after an execution is thrown | public void runMenu() {
int x = 1;
Scanner Option = new Scanner (System.in);
int Choice = 0;
do{
try{
System.out.println("Choose Option");
System.out.println("");
System.out.println("1: Create Account");
System.out.println("2: Check Account");
System.out.println("3: Take Action");
System.out.println("4: Exit");
System.out.println("Please choose");
Choice= Option.nextInt();
switch (Choice) //used switch statement instead of If else because more effective
{
case 1:
CreateAccount();
break; //breaks iteration
case 2:
selectAccount();
break;
case 3:
Menu();
int choice = UserInput();
performAction(choice);
break;
case 4:
System.out.println("Thanks for using the application");
System.exit(0);
default:
System.out.println("Invalid Entry");
throw new Exception();
}
}
catch (Exception e){
System.err.println("Enter Correct Input");
return;
}
} while (true);
}
I am trying to make it when users enter incorrect input type like a letter , the exception is caught and then returns back to the menus, right now it catches the exception but it doesnt stop running I have to force stop the program. So I added a return but that just displays the exception error and stops, how can I make it return back to the menus?
| <java><exception-handling><while-loop> | 2016-02-24 21:52:26 | LQ_EDIT |
35,614,061 | Large UL LI html file loading very slow | <p>I have a 'menu' HTML page. The Menu contains Book names and its chapters. It is designed like a tree like structure, built using tags UL & LI. The file is 2.6mb. The file is loading very slow on to the website. Are there any suggestions to improve its load time. Thank you.</p>
| <c#><jquery><css><html> | 2016-02-24 22:00:06 | LQ_CLOSE |
35,614,606 | Google reCAPTCHA data-callback not working | <p>I have built a email newsletter signup form which posts into mailchimp from my website. I have Google reCAPTCHA added to the form and have a data-callback to enable the submit button as it is initially disabled. This was working fine in all browsers last night and did tests with success & signed off on it..and went home. I got in this morning and found the subscribe button will not enable / data-callback does not work? Strange..</p>
<p>Callback</p>
<pre><code><div class="g-recaptcha" data-callback="recaptcha_callback" data-sitekey="xxxxx"></div>
</code></pre>
<p>Input button at bottom of form</p>
<pre><code><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button" disabled>
</code></pre>
<p>Scripts</p>
<pre><code><script src='https://www.google.com/recaptcha/api.js'></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
function recaptcha_callback(){
alert("callback working");
$('.button').prop("disabled", false);
}
)};
</script>
</code></pre>
| <javascript><jquery><callback><recaptcha> | 2016-02-24 22:35:54 | HQ |
35,614,778 | OutOfBoundsException error when creating an ArrayList | <p>I am trying to make a deck of cards. So far I have this:</p>
<pre><code>import java.util.*;
public class Card {
public static void main(String[] args) {
ArrayList<String> rank = new ArrayList<String>(Arrays.asList("Ace", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"));
ArrayList<String> suite = new ArrayList<String>(Arrays.asList("Spades", "Hearts", "Clubs", "Diamonds"));
ArrayList<String> deck = new ArrayList<String>();
String card;
for (int i = 0; i < rank.size(); i++) {
for (int p = 0; i < suite.size(); p++) {
card = rank.get(i) + " of " + suite.get(p);
deck.add(card);
}
}
System.out.println(deck);
}
}
</code></pre>
<p>I am getting an IndexOutOfBoundsException error on this line:</p>
<pre><code>card = rank.get(i) + " of " + suite.get(p);
</code></pre>
| <java><arraylist><indexoutofboundsexception> | 2016-02-24 22:47:22 | LQ_CLOSE |
35,614,957 | How can I read current zoom level of Mapbox? | <p>I have a back to home function</p>
<pre><code>function panToHome(){
latLng = [current.lat, current.lng];
map.setView(latLng, 8);
}
</code></pre>
<p>I want to save the current view as history, so user can switch back as they might click mistakely. So the question is how can I know the current latlng on Mapbox?!</p>
| <mapbox> | 2016-02-24 22:58:20 | HQ |
35,615,396 | Thank you for the help in advance. (How to use Constants?) | //I am very new to java and coding, we have multiple assignments but the instructor has asked us to use constants when we are able to. This one of the assignments.
import java.util.Scanner;
public class PP2_6
{
public static void main(String[] args)
{
Scanner myScan = new Scanner(System.in);
float mileage, kilometer;
System.out.print("Enter the Mileage: ");
mileage = myScan.nextFloat();
kilometer = mileage * 1.60935F;
System.out.println("The mileage in kilometers is : " + kilometer);
}
}
//i know the code is very basic and probably sloppy, is there a way to use a constant in this example?
thank you again | <java><constants> | 2016-02-24 23:34:47 | LQ_EDIT |
35,615,413 | use lodash to find substring from array of strings | <p>I'm learning lodash. Is it possible to use lodash to find a substring in an array of strings?</p>
<pre><code> var myArray = [
'I like oranges and apples',
'I hate banana and grapes',
'I find mango ok',
'another array item about fruit'
]
</code></pre>
<p>is it possible to confirm if the word 'oranges' is in my array?
I've tried _.includes, _.some, _.indexOf but they all failed as they look at the full string, not a substring</p>
| <javascript><arrays><include><lodash> | 2016-02-24 23:36:12 | HQ |
35,615,450 | Need fresh pair of eyes for my php code | <p>I need to make three lines of php code that will randomly choose fahrenheit temp between -10 and 120 degrees and display it converted to celsius. this is the code I came up with but it wont run or validate. please help</p>
<pre><code> <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</code></pre>
<p>Phpexamples
</p>
<p></p>
<pre><code><?php
echo"<p>$f equals $ rand ($c 10)."c."</p>";
echo "<p>"$c=($f-32) * (5/9);$f "</p>";
echo "<p>"$f= rand(-10,120) "<p>";
?>
<p><a href="ex2.php">Run it now</a></p>
</body>
</code></pre>
<p> </p>
| <php> | 2016-02-24 23:39:50 | LQ_CLOSE |
35,615,692 | When does Angular2 ngAfterViewInit get called? | <p>I need some jQuery code to run after my Angular component view has initialized to transform number values into stars.</p>
<p>I put the code in the ngAfterViewInit function, but it is not doing what I need it to. I set a break point in the function and I see that most of the HTML of my component has not even loaded by the time ngAfterViewInit function is called. The parts that have not loaded are generated using *ngFor directive.</p>
<p>How can I get my code to run after this directive has generated all of the html on which I need to operate?</p>
| <javascript><jquery><typescript><angular> | 2016-02-24 23:59:46 | HQ |
35,616,262 | How to use custom logger to log access log in spring boot | <p>Currently in spring boot 1.3, we could only log access log to a file in the filesystem. Is there any way to actually use the custom logger (like log4j2) to log the access log?</p>
<p>I am currently using undertow with spring boot, but after checking the spring boot source code, the undertow logger is initialized with DefaultAccessLogReceiver which is writing to file. I would like to use the AccessLogHandler if possible, and avoid writing a web filter which logs the access.</p>
<p>Is there any easy way around this? (except writing a pull request)</p>
| <java><spring><spring-boot><log4j2><undertow> | 2016-02-25 00:57:27 | HQ |
35,616,650 | How to upgrade glibc from version 2.12 to 2.14 on CentOS? | <p>I do not know how to upgrade glibc from version 2.12 to 2.14 on CentOS 6.3.
I need your help.</p>
| <linux><centos><glibc> | 2016-02-25 01:35:22 | HQ |
35,616,982 | Postgresql Select Constant | <p>In Oracle I can select a constant value that will populate down the column like this:</p>
<pre><code>Select
"constant" constantvalue,
orders.name
from
orders
</code></pre>
<p>and it will yield:</p>
<pre><code>ConstantValue Name
constant sandwich
constant burger
</code></pre>
<p>For whatever reason, when I try to do this in postgres I receive this error.</p>
<pre><code>ERROR: column "Constant" does not exist
</code></pre>
<p>here is my code </p>
<pre><code> select
date_trunc('day', measurement_date + (interval '1 day' * (6 - extract(dow from measurement_date)))) week,
"AROutstanding" colname,
round(avg(Total_Outstanding),0) numbah
from
(
select
measurement_date,
sum(cast(sum_of_dollars as numeric)) Total_Outstanding
from
stock_metrics
where
invoice_status not in ('F','Write off')
group by
measurement_date
) tt
group by
week
</code></pre>
| <sql><postgresql> | 2016-02-25 02:12:43 | HQ |
35,618,132 | Android Studio Show backgrounds tasks in the status bar instead of a floating window | <pre><code>Android Studio 2.0 Beta 5
</code></pre>
<p>Every time I build and deploy I get this floating background task appear.</p>
<p><a href="https://i.stack.imgur.com/Rt3E8.png"><img src="https://i.stack.imgur.com/Rt3E8.png" alt="enter image description here"></a></p>
<p>Normally I click the minimize button to get it to display in the status bar. However, can we change the default behaviour to always show in the status bar.</p>
<p>I couldn't find anything in the settings so not sure if Android Studio designed this way.</p>
<p>I just find this thing annoying.</p>
<p>Many thanks for any suggestions,</p>
| <android><android-studio> | 2016-02-25 04:08:06 | HQ |
35,618,158 | Multiple Slick Sliders Issue | <p>I am using Slick.js plugin with its Slider Syncing feature. The issue I am having is that if I use multiple sliders on a single page, by clicking next or prev buttons plugin performs the action for all sliders on page. I wonder is there anything I could do with JQuery to have the next and prev work for each slider on page not for all? Thanks in advance. </p>
<p>HTML</p>
<pre><code><div class="slider">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
<div class="slider-nav">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
</code></pre>
<p>SLICK RUN SCRIPT</p>
<pre><code>$('.slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
asNavFor: '.slider-nav'
});
$('.slider-nav').slick({
slidesToShow: 4,
slidesToScroll: 1,
asNavFor: '.slider',
dots: true,
arrows: true,
centerMode: false,
focusOnSelect: true
});
</code></pre>
| <jquery><slick.js> | 2016-02-25 04:10:26 | HQ |
35,618,174 | Inheritance student, undergrad and gradstudent code | For a class project I was asked to create three codes. First the student class containing 3 Parameters. Name(String), TestScores( int array), Grade(String). An Empty Constructor- sets the Name and Grade to empty Strings. The TestScores Array will be created with 3 zeros. Another Constructor(String n, int[] tests, String g)- This will set the name, testScores, and grade. Three methods getName()- Returns the Name, getGrade()- Returns the Grade, setGrade()- Sets the Grade, and getTestAverage()- returns the average of the test scores. The method computeGrade()-If the average is greater than or equal to 65, the grade is a "Pass". Otherwise it is a "Fail". The second class is called UnderGrad- This class is a subclass of Student. We had to create an Empty Constructor and another Constructor(String n, int[] tests, String g).We were instructed to override the computeGrade() method so that an UnderGrad() student must get a 70 or higher to pass. The third class is the GradStudent- is a subclass of Student. We have to create 1 instance variable- int MyGradID. An empty Constructor Remember to call super and set the ID to 0. And another constructor(String n, int[] tests, String g, int id)- Remember to call the super constructor and set ID. We had to write the method getId()-returns the ID number. Again we needed to override the computeGrade() method-If if the average is greater than or equal to 65, the grade is a "Pass". Otherwise it is a "Fail". If the test average is higher than 90, the grade should be "Pass with distinction".
I have great difficulty with this task. I attached the GradStudent code. can you find the errors please. I don't fully understand how to override the superclass private instance variables.
public class GradStudent extends Student
{
private int MyGradID;
public void GradStudent()
{
super();
MyGradID= 0;
}
public void GradStudent(String n, int[]tests,String g, int id)
{
super(n,tests,g);
MyGradId = id;
}
public int getId()
{
return MyGradId;
}
public void computeGrade()
{
if(testScores.getTestAverage>=65)
{
super.setGrade("Pass");
}
else if (testScores.getTestAverage>90)
{
grade = "Pass with distinction";
}
} | <java><arrays><inheritance><subclass><superclass> | 2016-02-25 04:12:14 | LQ_EDIT |
35,618,523 | intro programming on java with compareTo | <p>just got some computer science from my friend, I believe it is a intro to programming assignment, and I was trying on it, but it seems there are so many issue, seems I am majoring CS, can someone help me on those questions step by step, would be appreciated. in instructions are following:</p>
<p>Create a public class Movie with private instance variables String title
and int year. The class should declare that it implements the
Comparable interface, and should provide the following:</p>
<p>• A constructor that takes 2 arguments: a String and an int (in that order)<br>
for initializing title and year.</p>
<p>• A method that satisfies the Comparable interface. Movies should be compared first by title and then by year.</p>
<p>{ The Maltese Falcon 1941, The Thomas Crown Affair 1968, The Thomas Crown Affair 1999}</p>
<p>An equals() method that is compatible with the method that satisfies the
Comparable interface.</p>
<p>• A toString() method that prints “Movie” followed by 1 space followed by<br>
the title followed by 1 space followed by open-parenthesis followed by<br>
the year followed by close-parenthesis. Example:
The Maltese Falcon (1941)</p>
<p>• A public static method getTestMovies(), which returns an array of 10<br>
unique Movie instances. The 0th and 1st array elements must be 2 movies<br>
with the same title but from different years (e.g. The Thomas Crown<br>
Affair 1968 and The Thomas Crown Affair 1999, or True Grit 1969 and
True Grit 2010). The 2nd and 3rd elements must 2 movies with different<br>
titles but from the same year (e.g. The Martian 2015 and Bridge of Spies<br>
2015). The 4th and 5th elements must be 2 different objects that<br>
represent the same movie.</p>
<p>• A hashCode() method. Use the following:</p>
<pre><code>public int hashCode()
{
return title.hashCode() + year;
}
</code></pre>
<p>the following is what I have so far, I have the constructor and the starter, but I am sure how to do it.</p>
<pre><code>public class Movie implements Comparable<Movie>{
private String title;
private int year;
public Movie(String title, int year){
this.title = title;
this.year = year;
}
@Override
public int compareTo(Movie that) {
int value = 0;
if(this.title == that.title)
{
if(this.year < that.year){
value = 0;
}
else{
value = -1;
}
}
return value;
}
public static void getTestMovie(){
}
public boolean equals(Object x)
{
</code></pre>
<p>}
}</p>
<p>Any Helps are appreciated!</p>
| <java> | 2016-02-25 04:43:08 | LQ_CLOSE |
35,618,998 | How to implement Bottom Sheets using new design support library 23.2 | <p>Google release the new update to support library 23.2 in that they added bottom sheet feature. Can any one tell how to implement that bottom sheet using that library.</p>
| <android><android-support-library><android-support-design> | 2016-02-25 05:21:19 | HQ |
35,620,098 | React-native: scrollview inside of panResponder | <p>I am using a ScrollView inside of a PanResponder. On Android it works fine but on iOS the ScrollView will not scroll. I did some investigation and here are some facts:</p>
<ol>
<li><p>If I put a break point in <code>PanResponder.onMoveShouldSetPanResponder()</code>, before I step over, the scrollView will scroll as normal but once I release the break point, the scrollView stops working.</p></li>
<li><p>If I modify ScrollResponder.js, and return true in <code>scrollResponderHandleStartShouldSetResponderCapture()</code> - it used to return false at runtime; and return false in <code>scrollResponderHandleTerminationRequest()</code>, the scrollView works OK but of course, since it swallows the event the outer <code>PanResponder</code> will not get the event.</p></li>
</ol>
<p>So the questions are:</p>
<ol>
<li>I want to make the scrollview to work, and <strong>not</strong> to swallow the event. Any one know what's the approach?</li>
<li>How the responding system works on iOS? The react-native responder system doc does not explain that to me.</li>
</ol>
| <ios><react-native> | 2016-02-25 06:38:31 | HQ |
35,620,260 | HOW TO FREE a MALLOC'd attribute of a STACK ALLOCATED STRUCT | typedef struct {
int s;
...
char* temp_status;
...
} param;
pararm MQK;
MQK.temp_status = (char*) malloc(sizeof(char)*14);
...
free(&(MQK.temp_status)); <<< ERROR
// E R R O R R E P O R T //
gcc ...
csim.c: In function ‘main’:
csim.c:348:9: error: attempt to free a non-heap object ‘MQK’ [- Werror=free-nonheap-object]
free(&(MQK.temp_status));
^
cc1: all warnings being treated as errors
How should I free it?
I have to FREE a MALLOC'd attribute of a STACK ALLOCATED STRUCT.
The below is the error. Any aha-ers! help mE! | <c><struct><malloc><free> | 2016-02-25 06:47:36 | LQ_EDIT |
35,620,739 | Split string if contains any of the following comaprison operators like "==", ">", "<", ">=", "<==", "!=" | <p>i want to split a string if it contains one of the following operators ==, >, <, >=, <=, !=</p>
<ol>
<li>if string equals a>b, result is [a,b]</li>
<li>if string equals a < b, result is [a,b]</li>
<li>if string equals a>=b, result is [a,b] </li>
<li>if string equals a<=b, result is [a,b]</li>
<li>if string equals a==b, result is [a,b]</li>
<li>if string equals a!=b, result is [a,b]</li>
</ol>
| <javascript> | 2016-02-25 07:16:53 | LQ_CLOSE |
35,620,853 | How to write a matrix matrix product that can compete with Eigen? | <p>Below is the C++ implementation comparing the time taken by Eigen and For Loop to perform matrix-matrix products. The For loop has been optimised to minimise cache misses. The for loop is faster than Eigen initially but then eventually becomes slower (upto a factor of 2 for 500 by 500 matrices). What else should I do to compete with Eigen? Is blocking the reason for the better Eigen performance? If so, how should I go about adding blocking to the for loop?</p>
<pre><code>#include<iostream>
#include<Eigen/Dense>
#include<ctime>
int main(int argc, char* argv[]) {
srand(time(NULL));
// Input the size of the matrix from the user
int N = atoi(argv[1]);
int M = N*N;
// The matrices stored as row-wise vectors
double a[M];
double b[M];
double c[M];
// Initializing Eigen Matrices
Eigen::MatrixXd a_E = Eigen::MatrixXd::Random(N,N);
Eigen::MatrixXd b_E = Eigen::MatrixXd::Random(N,N);
Eigen::MatrixXd c_E(N,N);
double CPS = CLOCKS_PER_SEC;
clock_t start, end;
// Matrix vector product by Eigen
start = clock();
c_E = a_E*b_E;
end = clock();
std::cout << "\nTime taken by Eigen is: " << (end-start)/CPS << "\n";
// Initializing For loop vectors
int count = 0;
for (int j=0; j<N; ++j) {
for (int k=0; k<N; ++k) {
a[count] = a_E(j,k);
b[count] = b_E(j,k);
++count;
}
}
// Matrix vector product by For loop
start = clock();
count = 0;
int count1, count2;
for (int j=0; j<N; ++j) {
count1 = j*N;
for (int k=0; k<N; ++k) {
c[count] = a[count1]*b[k];
++count;
}
}
for (int j=0; j<N; ++j) {
count2 = N;
for (int l=1; l<N; ++l) {
count = j*N;
count1 = count+l;
for (int k=0; k<N; ++k) {
c[count]+=a[count1]*b[count2];
++count;
++count2;
}
}
}
end = clock();
std::cout << "\nTime taken by for-loop is: " << (end-start)/CPS << "\n";
}
</code></pre>
| <c++><matrix><matrix-multiplication><eigen> | 2016-02-25 07:23:48 | HQ |
35,620,997 | How to make volumes permanent with Docker Compose v2 | <p><em>I realize other people have had similar questions but this uses v2 compose file format and I didn't find anything for that.</em></p>
<p>I want to make a very simple test app to play around with MemSQL but I can't get volumes to not get deleted after <code>docker-compose down</code>. If I've understood Docker Docs right, volumes shouldn't be deleted without explicitly telling it to. Everything seems to work with <code>docker-compose up</code> but after going down and then up again all data gets deleted from the database.</p>
<p>As recommended as a good practice, I'm using separate memsqldata service as a separate data layer.</p>
<p>Here's my docker-compose.yml:</p>
<pre><code>version: '2'
services:
app:
build: .
links:
- memsql
memsql:
image: memsql/quickstart
volumes_from:
- memsqldata
ports:
- "3306:3306"
- "9000:9000"
memsqldata:
image: memsql/quickstart
command: /bin/true
volumes:
- memsqldatavolume:/data
volumes:
memsqldatavolume:
driver: local
</code></pre>
| <docker><docker-compose><memsql> | 2016-02-25 07:32:23 | HQ |
35,621,112 | Im creating a game.How do I change different background images? When I try it just displays for like .5 sec. Please help me | This is my code to a new background and objects.
def bathRoom():
global drag, a, b, c, d, e, f, g, h, i, j
bg_bathroom = True
bathroom = pygame.image.load("pou_bathroom.jpg")
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
gameDisplay.blit(bathroom,[0,0])
gameDisplay.blit(pivi,[200,80])
gameDisplay.blit(soap,(a, b))
gameDisplay.blit(shower,(c,d))
gameDisplay.blit(shop,(e,f))
if click[0] == 1 and a + soapWidth > mouse[0] > a and b + soapHeight > mouse[1] > b:
drag == 1
a = mouse[0] - (soapWidth / 2)
b = mouse[1] - (soapHeight / 2)
if click[0] == 1 and c + showerWidth > mouse[0] > c and d + showerHeight > mouse[1] > d:
drag == 1
c = mouse[0] - (showerWidth / 2)
d = mouse[1] - (showerHeight / 2)
def main_loop():
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
mainScreen()
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
if click[0] == 1 and x + bathWidth > mouse[0] > x and y + bathHeight > mouse[1] > y:
bathRoom()
pygame.display.update()
This is the part that I try to change background
After I click the image I need to display a new background but it just displays for .5sec I need it to stay then I will be the one to change it again
main_loop()
pygame.quit()
quit()
| <python><pygame> | 2016-02-25 07:39:16 | LQ_EDIT |
35,621,167 | 754 single precision 1-bit sign 8-bit exponent 23-bit fraction, What is the binary representation of 0.25*2^(-128)? | 754 single precision 1-bit sign 8-bit exponent 23-bit fraction, What is the binary representation of 0.25*2^(-128)=2^(-130)? by using the formula: **exponent-bias=log(given number)** and also **fraction=-1+(given number)/2^(exponent-bias)** doesn't give the right answer....why? And how to solve this question? | <floating-point><ieee-754> | 2016-02-25 07:42:45 | LQ_EDIT |
35,621,324 | How to create own database in redis? | <pre><code>There are 0 to 15 databases in redis.
</code></pre>
<p>I want to create my own database using redis-cli.
Is there any command for it?</p>
| <redis> | 2016-02-25 07:51:48 | HQ |
35,621,385 | How can I add text multiple text views to the list view items in android? | <p>How can I add text multiple text views to the list view items in android?Please add the code</p>
| <android> | 2016-02-25 07:55:00 | LQ_CLOSE |
35,621,644 | Parameter specified as non-null is null in ArrayAdaper | <p>I've extended ArrayAdapter for spinner:</p>
<pre><code>class OrderAdapter(context: Context, resource: Int, objects: List<Order>) : ArrayAdapter<Order>(context, resource, objects) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View? {
val view = super.getView(position, convertView, parent)
view?.let { view.find<TextView>(android.R.id.text1).text = getItem(position).name }
return view
}
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View? {
val view = super.getDropDownView(position, convertView, parent)
view?.let {view.find<TextView>(android.R.id.text1).text = getItem(position).name }
return view
}
}
</code></pre>
<p>I'm getting exception:</p>
<pre><code>java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter convertView
at com.github.blabla.endlesss.ui.adapter.OrderAdapter.getView(OrderAdapter.kt:0)
</code></pre>
<p>Any ideas how to fix it?</p>
| <android><kotlin> | 2016-02-25 08:09:26 | HQ |
35,621,786 | How to pass arguments in __VA_ARGS to a 2d character array? | <p>I need to get result from __VA_ARGS to a function, and from there I need to pass string of each argument to a 2d character array.</p>
| <c><macros> | 2016-02-25 08:17:14 | LQ_CLOSE |
35,622,209 | UNIX not being able to access file even after 777 permissio | I have file placed at location /orabin/hrtst/TEST
/orabin/hrtst/TEST$ ls -ltr Lookup_code.log
-rwxrwxrwx 1 xxhcmuser dba 0 Feb 25 15:08 Lookup_code.log
I want the -rwxrwxrwx permission to change to `drwxrwxrwx`
what command can i use ? | <file><shell><unix><file-permissions> | 2016-02-25 08:39:11 | LQ_EDIT |
35,622,438 | Update Android Support Library to 23.2.0 cause error: XmlPullParserException Binary XML file line #17<vector> tag requires viewportWidth > 0 | <p>I try to update my Support Library up to 23.2.0 and face this error:</p>
<pre><code>Exception while inflating <vector>
org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:535)
at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:472)
at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:436)
at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:829)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:303)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:178)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
</code></pre>
<p>And</p>
<pre><code>FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chotot.vn.dev/com.chotot.vn.v2.activities.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class android.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class android.support.v7.widget.Toolbar
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
at android.content.res.Resources.loadDrawable(Resources.java:2091)
at android.content.res.Resources.getDrawable(Resources.java:695)
at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:897)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:837)
at android.content.res.Resources.loadDrawable(Resources.java:2087)
at android.content.res.Resources.getDrawable(Resources.java:695)
at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
</code></pre>
<p>My <code>activity_main.xml</code></p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="@+id/f_actionbar"
android:name="com.chotot.vn.fragments.ActionBarFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.Toolbar
android:id="@+id/main_tool_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="@color/action_bar_bg">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/main_action_bar_layout"
layout="@layout/layout_actionbar_custom_search"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="top" />
<LinearLayout
android:id="@+id/main_action_bar_layout_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/main_action_bar_layout"
android:orientation="vertical" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/layout_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/main_tool_bar" />
</RelativeLayout>
</code></pre>
<p><strong>How can I fix it?</strong></p>
| <android><android-support-library> | 2016-02-25 08:53:20 | HQ |
35,622,697 | How to restrict file type (e.g. .pdf) using thymeleaf? | How to restrict file type (e.g. .pdf) using thymeleaf? The accept tag does not serve the purpose fully, as I can type some other file type and the file gets uploaded. The field is of input type "file". Is there any thymeleaf tag that can serve the purpose? | <html><html-input> | 2016-02-25 09:05:45 | LQ_EDIT |
35,622,707 | SimpleJson: String to JSONArray | <p>I get the following JSON:</p>
<pre><code>[
{
"user_id": "someValue"
}
]
</code></pre>
<p>It's saved inside a String.</p>
<p>I would like to convert it to a <code>JSONObject</code> which fails (as the constructor assumes a JSON to start with <code>{</code>). As this doesn't seem to be possible I'd like to convert it to a <code>JSONArray</code>. How can I do that with SimpleJson?</p>
| <java><json><jettison> | 2016-02-25 09:06:07 | HQ |
35,623,280 | Ionic - ion-item text is not vertically centered when ion-icon is bigger | <p>I have a list of ion-items with an icon followed by text. When the icon size is smaller as seen on the image below, the text seems to vertically align itself to the center of the ion-item. But when the icon is bigger, the alignment is a bit off. </p>
<p><a href="https://i.stack.imgur.com/efZu7.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/efZu7.jpg" alt="enter image description here"></a></p>
<p>This is all I've added:</p>
<pre><code><ion-item>
<ion-icon class="icon ion-ios-clock-outline"></ion-icon>
Recent
</ion-item>
</code></pre>
<p>And the CSS:</p>
<pre><code>.icon {
font-size: 35px;
color: #ffC977;
}
</code></pre>
<p>How can I fix this. I tried using <code>vertical-align</code>, <code>align-item</code> and <code>align-self</code>. None of them worked.</p>
| <css><ionic-framework> | 2016-02-25 09:30:45 | HQ |
35,623,307 | how to share the data between the views in angualr | i am doing one angular project in which i am loading the new view by calling the function . up to this thing it is fine . now the my requirement is i want some data to transferred to the new view from the same same function . using the same controller . i am showing here the demo code.
<!-- begin snippet: js hide: false -->
<!-- language: lang-js -->
$scope.passID = function(id){
console.log(id);
$state.go("view", {id: $scope.id });
}
<!-- end snippet -->
| <angularjs> | 2016-02-25 09:31:45 | LQ_EDIT |
35,623,347 | immutable.js get keys from map/hash | <p>I want to retrieve keys() from the following Immutable Map:</p>
<pre><code>var map = Immutable.fromJS({"firstKey": null, "secondKey": null });
console.log(JSON.stringify(map.keys()));
</code></pre>
<p>I would expect the output:</p>
<pre><code>["firstKey", "secondKey"]
</code></pre>
<p>However this outputs:</p>
<pre><code>{"_type":0,"_stack":{"node":{"ownerID":{},"entries":[["firstKey",null],["secondKey",null]]},"index":0}}
</code></pre>
<p>How to do it properly? </p>
<p>JSFiddle link: <a href="https://jsfiddle.net/o04btr3j/57/" rel="noreferrer">https://jsfiddle.net/o04btr3j/57/</a></p>
| <immutable.js> | 2016-02-25 09:33:24 | HQ |
35,623,577 | How to change the size of item-avatar in ionic? | <p>I am developing an app using ionic framework. I need to display an image in the side menu header. I have used <strong>item-avatar</strong> to display the image. Here is the code.</p>
<pre><code><ion-side-menus>
<ion-side-menu side="left">
<ion-header-bar class="bar-calm style="height:200px" >
<div class="list" >
<a class="item item-avatar">
<img src="some image source">
<p>This is an image</p>
</a>
</div>
</ion-header-bar>
</ion-side-menu>
<ion-side-menu-content>
<ion-list >
<!-- Links to the pages that must contain the side menu. -->
<ion-item href="#/side-menu24/page1">Page1</ion-item>
<ion-item href="#/side-menu24/page2"> Page2</ion-item>
</ion-list>
</ion-side-menu-content>
</code></pre>
<p></p>
<p>How do I change(increase) the size of the image displayed in the item-avatar? I was suggested the following CSS:</p>
<pre><code>.list .item-avatar{
width: 20px !important;
height : 60px !important;}
</code></pre>
<p>This increases the content size(size allocated to the div tag) of the item-avatar as a whole but the image size remains the same. Is there any way to increase the size of the image displayed inside the item-avatar?</p>
| <html><css><ionic-framework> | 2016-02-25 09:44:18 | HQ |
35,623,776 | Import numpy on pycharm | <p>I'm trying to import numpy on Pycharm.</p>
<p>Using the Pycharm terminal and Miniconda I've launched the command:</p>
<pre><code>conda install numpy
</code></pre>
<p>And this was the output</p>
<pre><code>Fetching package metadata: ....
Solving package specifications: ....................
# All requested packages already installed.
# packages in environment at C:\Users\...\Miniconda3:
#
numpy 1.10.4 py35_0
</code></pre>
<p>So I run my project but the terminal said</p>
<pre><code>ImportError: No module named 'numpy'
</code></pre>
<p>On my project bar I can see two different folders, the one with my project and another one with the external libraries.</p>
<p>Under External libraries -> Extendend definitions there is a numpy folder so I guess that the installation goes well.</p>
<p>Can you please help me ?</p>
| <python><python-3.x><numpy><pycharm> | 2016-02-25 09:52:24 | HQ |
35,623,868 | Angular2 : two way binding inside parent/child component | <p>Version: "angular2": "2.0.0-beta.6"</p>
<p>I would like to implement a two way binding inside a parent/child component case.</p>
<p>On my child component, I'm using two-way binding to display text while editing.</p>
<p>Child component (<code>InputTestComponent [selector:'input-test']</code>):</p>
<pre><code><form (ngSubmit)="onSubmit()" #testform="ngForm">
{{name}}
<textarea #textarea [(ngModel)]="name" ngControl="name" name="name"></textarea>
<button type="submit">Go</button>
</form>
</code></pre>
<p>Then, I would like to propagate this change to his parent component.
I tried with <code>[(name)]="name"</code> with no success.</p>
<p>Parent component:</p>
<pre><code><div>
{{name}}
<input-test [(name)]="name"></input-test>
</div>
</code></pre>
<p><a href="http://plnkr.co/edit/GO8BCcJleyNRURB29OOC">Code sample</a></p>
<p>What the easiest way to do it (less verbose) ?</p>
| <angular> | 2016-02-25 09:55:48 | HQ |
35,624,413 | Remove 'search' option but leave 'search columns' option | <p>I would like to remove 'global search' option from my application, but leave 'column search' option. Any ideas? I've tried different paramethers like <code>searching=FALSE, filtering='none'</code>... None of this works properly. </p>
<p>My code:</p>
<p><code>server.R:</code></p>
<pre><code>library("shiny")
library("DT")
data(iris)
shinyServer(function(input, output) {
output$tabelka <- DT::renderDataTable({
datatable(iris, filter="top", selection="multiple", escape=FALSE)
})
})
</code></pre>
<p><code>ui.R</code></p>
<pre><code>library("shiny")
library("DT")
shinyUI(fluidPage(
DT::dataTableOutput("tabelka")
))
</code></pre>
<p>And picture which helps to understand my problem:</p>
<p><a href="https://i.stack.imgur.com/B2Map.png" rel="noreferrer"><img src="https://i.stack.imgur.com/B2Map.png" alt="enter image description here"></a></p>
| <r><shiny><dt> | 2016-02-25 10:18:28 | HQ |
35,624,851 | HOW TO WRITE ORACLE PLSQL PROCEDURE TO GET THIS OUTPUT? | table A:Present data
A VALID_FROM VALID_TO
------------ ---------------- ----------------
ARN-1 01-APR-2015 31-DEC-9999
ARN-1 01-MAY-2015 31-DEC-9999
ARN-1 01-JUN-2015 31-DEC-9999
table B:Required output after insertion
A VALID_FROM VALID_TO
------------ ---------------- ----------------
ARN-1 01-APR-2015 30-APR-2015
ARN-1 01-MAY-2015 31-MAY-2015
ARN-1 01-JUN-2015 31-DEC-9999
HOW TO WRITE ORACLE PLSQL PROCEDURE TO GET THIS OUTPUT??
| <sql><oracle><plsql> | 2016-02-25 10:36:43 | LQ_EDIT |
35,625,099 | How to change color of vector drawable path on button click | <p>With the new android support update, vector drawables get backward compatibility. I have a vector image with various paths. I want the color of the paths to change on click of a button or programmatically based on an input value. Is it possible to access the name parameter of the vector path? And then change the color.</p>
| <android><vector><vector-graphics><android-vectordrawable> | 2016-02-25 10:48:04 | HQ |
35,625,178 | What is the alternate for -webkit-print-color-adjust in firefox and IE | <p>I had some issues with the printing the background colors.</p>
<p>print-color-adjust made the background color issue solved in chrome.</p>
<pre><code>body{
-webkit-print-color-adjust: exact;
}
</code></pre>
<p>What are the <strong>alternate CSS</strong> in firefox and IE for this.</p>
| <css><google-chrome><internet-explorer><firefox> | 2016-02-25 10:51:02 | HQ |
35,625,620 | ListView item with checkbox - how to remove checkbox ripple effect? | <p>I have a ListView with item contains a checkbox and some other elements. The problem is when I click on the list item on Android 5+ device I have it looks like this:</p>
<p><a href="https://i.stack.imgur.com/jnctG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jnctG.png" alt="enter image description here"></a></p>
<p>I don't want to have ripple effect around the checkbox.
How can I acheive that?</p>
<p>Item XML code:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
android:gravity="center_vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/item_check"
android:checked="false"
android:focusable="false"
android:layout_marginRight="32dp"
android:clickable="false"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/item_title"
android:textAppearance="@android:style/TextAppearance.Medium"
android:maxLines="1"
android:lines="1"/>
</LinearLayout>
</code></pre>
| <android><android-layout><listview><material-design><android-checkbox> | 2016-02-25 11:11:56 | HQ |
35,626,234 | google play store insufficient storage lenovo A5000 | <p>every time i try to download app or update apps from google store ,said"insufficient storage" but i have 11GB of space in my memory card and my phone is lenovo A5000 .<a href="http://i.stack.imgur.com/VMuIc.png" rel="nofollow">enter image description here</a></p>
| <android> | 2016-02-25 11:39:48 | LQ_CLOSE |
35,627,648 | CORS endpoints on asp.net Webforms [WebMethod] endpoints | <p>I am trying to add some <code>[WebMethod]</code> annotated endpoint functions to a Webforms style web app (.aspx and .asmx). </p>
<p>I'd like to annotate those endpoints with <code>[EnableCors]</code> and thereby get all the good ajax-preflight functionality.</p>
<p>VS2013 accepts the annotation, but still the endpoints don't play nice with CORS. (They work fine when used same-origin but not cross-origin).</p>
<p>I can't even get them to function cross-origin with the down and dirty</p>
<pre><code>HttpContext.Current.Response.AppendHeader("Access-Control-Allow-Origin", "*");
</code></pre>
<p>approach -- my browsers reject the responses, and the cross-origin response headers don't appear.</p>
<p>How can I get CORS functionality in these <code>[WebMethod]</code> endpoints?</p>
| <c#><.net><webforms><cors> | 2016-02-25 12:41:39 | HQ |
35,627,923 | UNION versus SELECT DISTINCT and UNION ALL Performance | <p>Is there any difference between these two performance-wise?</p>
<pre><code>-- eliminate duplicates using UNION
SELECT col1,col2,col3 FROM Table1
UNION SELECT col1,col2,col3 FROM Table2
UNION SELECT col1,col2,col3 FROM Table3
UNION SELECT col1,col2,col3 FROM Table4
UNION SELECT col1,col2,col3 FROM Table5
UNION SELECT col1,col2,col3 FROM Table6
UNION SELECT col1,col2,col3 FROM Table7
UNION SELECT col1,col2,col3 FROM Table8
-- eliminate duplicates using DISTINCT
SELECT DISTINCT * FROM
(
SELECT col1,col2,col3 FROM Table1
UNION ALL SELECT col1,col2,col3 FROM Table2
UNION ALL SELECT col1,col2,col3 FROM Table3
UNION ALL SELECT col1,col2,col3 FROM Table4
UNION ALL SELECT col1,col2,col3 FROM Table5
UNION ALL SELECT col1,col2,col3 FROM Table6
UNION ALL SELECT col1,col2,col3 FROM Table7
UNION ALL SELECT col1,col2,col3 FROM Table8
) x
</code></pre>
| <sql-server><tsql> | 2016-02-25 12:54:05 | HQ |
35,627,938 | Difference between byte stream and bit stream | <p>So far I thought they are the same as bytes are made of bits and that both side needs to know byte size and endiannes of the other side and transform stream accordingly. However Wikipedia says that <code>byte stream</code> != <code>bit stream</code> (<a href="https://en.wikipedia.org/wiki/Byte_stream">https://en.wikipedia.org/wiki/Byte_stream</a> ) and that <code>bit streams</code> are specifically used in video coding (<a href="https://en.wikipedia.org/wiki/Bitstream_format">https://en.wikipedia.org/wiki/Bitstream_format</a>). In this RFC <a href="https://tools.ietf.org/html/rfc107">https://tools.ietf.org/html/rfc107</a> they discuss these 2 things and describe <code>Two separate kinds of inefficiency arose from bit streams.</code>. My questions are:</p>
<ul>
<li>what's the <em>real</em> difference between byte stream and bit stream?</li>
<li>how bit stream works if it's different from byte stream? How does a receiving side know how many bits to process at a given time?</li>
<li>why is bit stream better than byte stream in some cases?</li>
</ul>
| <streaming><byte><bits><bytestream> | 2016-02-25 12:55:17 | HQ |
35,628,175 | Can I not use $ctrl. in angular component template | <p>I am using angular 1.5 and I wanted to extract part of my DOM into a <a href="https://docs.angularjs.org/guide/component" rel="noreferrer">component</a>.<br>
Here is what I have done so far:</p>
<pre><code>angular.module('my-app').component("menuItem",{
templateUrl : "lib/menu-item.tmpl.html",
bindings : {
index : "<",
first : "<",
last : "<",
item : "=",
onDelete : "&",
onMoveUp : "&",
onMoveDown : "&"
},
controller : function($scope) {
}
});
</code></pre>
<p>And the template looks like so:</p>
<pre><code><div>
<aside class="sort-buttons">
<ul>
<li>
<button ng-click="$ctrl.onMoveUp({index : $ctrl.index})"
ng-disabled="$ctrl.first">
<i class="icon icon-up"></i>
</button>
</li>
<li>
<button ng-click="$ctrl.onMoveDown({index : $ctrl.index})"
ng-disabled="$ctrl.last">
<i class="icon icon-down"></i>
</button>
</li>
</ul>
</aside>
<div class="row">
<button class="btn btn-danger btn-icon btn-remove"
ng-click="$ctrl.onDelete({index : $ctrl.index})">
<i class="icon icon-remove"></i>
</button>
</div>
</div>
</code></pre>
<p>I use this component (far from finished!) like so:</p>
<pre><code><section class="container menu">
<menu-item index="$index" first="$first" last="$last" item="item"
on-delete="removeItem(index)"
on-move-up="moveItemUp(index)"
on-move-down="moveItemDown(index)"
ng-repeat="item in menu">
</menu-item>
<!-- some other display details of `$ctrl.item` -->
</section>
</code></pre>
<p>I have three main questions I guess:</p>
<ol>
<li>Why do I have to use <code>$ctrl</code> everywhere in my template? There is <code>$scope</code> so why all the bindings go to <code>$ctrl</code> rather than <code>$scope</code>? And is there a way to change this?</li>
<li>Can I somehow have values like <code>$index</code>, <code>$first</code> and <code>$last</code> passed in? It seems to me like it is a "buttery butter" to pass them in...</li>
<li>Is this even the right approach? Or should I use directive? I know components have isolated scope, and directives can have not-isolated scope. but could I mix/match in a directive (share the scope with controller, but also add my own functions to be used within directive/template only?)</li>
</ol>
<p>Thanks for your help.</p>
| <angularjs><angularjs-directive><angularjs-scope> | 2016-02-25 13:05:32 | HQ |
35,628,557 | SQL Error(1166):Incorrect collumn name 'id' | Am new to yii and heidiSQL while am creating new table iget this error,so help me to slove this error
CREATE TABLE `users` (
`id ` INT(45) NULL,
`username ` VARCHAR(50) NULL,
`pwd_hash` VARCHAR(50) NULL,
`fname` VARCHAR(50) NULL,
`lname` VARCHAR(50) NULL,
`email` VARCHAR(50) NULL,
`country` VARCHAR(50) NULL,
`address` VARCHAR(50) NULL,
`gender` VARCHAR(50) NULL,
INDEX `PRIMARY KEY` (`id `),
INDEX `UIQUE KEY` (`username `)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;
It shows the SQL error so i can't able to create new table with in one database
Thanks Sandhiya! | <php><mysql><sql><yii><heidisql> | 2016-02-25 13:23:29 | LQ_EDIT |
35,628,733 | QML Canvas: different behaviour in rendering | <p>I am trying to draw an annulus sector in QML using the Canvas object.
First, I have written the javascript code, and I have verified that it is correct by executing it in a browser.</p>
<p>Here it is:</p>
<pre><code>var can = document.getElementById('myCanvas');
var ctx=can.getContext("2d");
var center = {
x: can.width / 2,
y: can.height / 2
};
var minRad = 100;
var maxRad = 250;
var startAngle = toRad(290);
var endAngle = toRad(310);
drawAxis();
drawSector();
function drawSector() {
var p1 = {
x: maxRad * Math.cos(startAngle),
y: maxRad * Math.sin(startAngle)
}
p1 = toCanvasSpace(p1);
var p2 = {
x: minRad * Math.cos(startAngle),
y: minRad * Math.sin(startAngle)
}
p2 = toCanvasSpace(p2);
var p3 = {
x: minRad * Math.cos(endAngle),
y: minRad * Math.sin(endAngle)
}
p3 = toCanvasSpace(p3);
var p4 = {
x: maxRad * Math.cos(endAngle),
y: maxRad * Math.sin(endAngle)
}
p4 = toCanvasSpace(p4);
ctx.beginPath();
ctx.moveTo(p1.x, p1.y);
ctx.arc(center.x, center.y, maxRad, startAngle, endAngle);
ctx.lineTo(p3.x, p3.y);
ctx.arc(center.x, center.y, minRad, endAngle, startAngle, true);
ctx.closePath();
ctx.strokeStyle = "blue";
ctx.lineWidth = 2;
ctx.stroke();
}
function drawAxis() {
ctx.beginPath();
ctx.moveTo(can.width / 2, 0);
ctx.lineTo(can.width / 2, can.height);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(0, can.height / 2);
ctx.lineTo(can.width, can.height / 2);
ctx.stroke();
}
function toRad(degrees) {
return degrees * Math.PI / 180;
}
function toCanvasSpace(p) {
var ret = {};
ret.x = p.x + can.width / 2;
ret.y = p.y + can.height / 2;
return ret;
}
</code></pre>
<p><a href="https://jsfiddle.net/0kwauehj/7/" rel="nofollow noreferrer">Here</a> you can run the code above.
The output is this:</p>
<p><a href="https://i.stack.imgur.com/bmjS0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bmjS0.png" alt="enter image description here"></a></p>
<p>Next, I moved the same code into a Canvas object in Qml.</p>
<p>See here the main.qml containing the Canvas:</p>
<pre><code>import QtQuick 2.5
import QtQuick.Window 2.2
Window {
visible: true
width: 500
height: 500
x:500
Canvas
{
id: can
anchors.fill: parent
antialiasing: true
onPaint: {
var ctx=can.getContext("2d");
var center = {
x: can.width / 2,
y: can.height / 2
};
var minRad = 100;
var maxRad = 250;
var startAngle = toRad(290);
var endAngle = toRad(310);
drawAxis();
drawSector();
function drawSector() {
var p1 = {
x: maxRad * Math.cos(startAngle),
y: maxRad * Math.sin(startAngle)
}
p1=toCanvasSpace(p1);
var p2 = {
x: minRad * Math.cos(startAngle),
y: minRad * Math.sin(startAngle)
}
p2=toCanvasSpace(p2);
var p3 = {
x: minRad * Math.cos(endAngle),
y: minRad * Math.sin(endAngle)
}
p3=toCanvasSpace(p3);
var p4 = {
x: maxRad * Math.cos(endAngle),
y: maxRad * Math.sin(endAngle)
}
p4=toCanvasSpace(p4);
ctx.beginPath();
ctx.moveTo(p1.x, p1.y);
ctx.arc(center.x, center.y, maxRad, startAngle, endAngle);
ctx.lineTo(p3.x, p3.y);
ctx.arc(center.x, center.y, minRad, endAngle, startAngle, true);
ctx.closePath();
ctx.strokeStyle="blue";
ctx.lineWidth=2;
ctx.stroke();
}
function drawAxis() {
ctx.beginPath();
ctx.moveTo(can.width / 2, 0);
ctx.lineTo(can.width / 2, can.height);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(0, can.height / 2);
ctx.lineTo(can.width, can.height / 2);
ctx.stroke();
}
function toRad(degrees) {
return degrees * Math.PI / 180;
}
function toCanvasSpace(p) {
var ret = {};
ret.x = p.x + can.width / 2;
ret.y = p.y + can.height / 2;
return ret;
}
}
}
}
</code></pre>
<p>In this case I get this output:</p>
<p><a href="https://i.stack.imgur.com/93Ns0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/93Ns0.jpg" alt="enter image description here"></a></p>
<p>As you can see there is an imperfection at the bottom.</p>
<p>I really don't understand why there is that imperfection; moreover I don't understand why the same code gives different output.</p>
<p>Any help is appreciated!
Thanks</p>
| <javascript><html><qt><canvas><qml> | 2016-02-25 13:31:39 | HQ |
35,628,735 | Refactoring class to get rid of switch case | <p>Say I have a class like this for calculating the cost of travelling different distances with different modes of transportation:</p>
<pre><code>public class TransportationCostCalculator
{
public double DistanceToDestination { get; set; }
public decimal CostOfTravel(string transportMethod)
{
switch (transportMethod)
{
case "Bicycle":
return (decimal)(DistanceToDestination * 1);
case "Bus":
return (decimal)(DistanceToDestination * 2);
case "Car":
return (decimal)(DistanceToDestination * 3);
default:
throw new ArgumentOutOfRangeException();
}
}
</code></pre>
<p>This is fine and all, but switch cases can be a nightmare to maintenance wise, and what if I want to use airplane or train later on? Then I have to change the above class. What alternative to a switch case could I use here and any hints to how?</p>
<p>I'm imagining using it in a console application like this which would be run from the command-line with arguments for what kind of transportation vehicle you want to use, and the distance you want to travel:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
if(args.Length < 2)
{
Console.WriteLine("Not enough arguments to run this program");
Console.ReadLine();
}
else
{
var transportMethod = args[0];
var distance = args[1];
var calculator = new TransportCostCalculator { DistanceToDestination = double.Parse(distance) };
var result = calculator.CostOfTravel(transportMethod);
Console.WriteLine(result);
Console.ReadLine();
}
}
}
</code></pre>
<p>Any hints greatly appreciated!</p>
| <c#> | 2016-02-25 13:31:46 | HQ |
35,628,774 | How to update single value inside specific array item in redux | <p>I have an issue where re-rendering of state causes ui issues and was suggested to only update specific value inside my reducer to reduce amount of re-rendering on a page.</p>
<p>this is example of my state</p>
<pre><code>{
name: "some name",
subtitle: "some subtitle",
contents: [
{title: "some title", text: "some text"},
{title: "some other title", text: "some other text"}
]
}
</code></pre>
<p>and I am currently updating it like this</p>
<pre><code>case 'SOME_ACTION':
return { ...state, contents: action.payload }
</code></pre>
<p>where <code>action.payload</code> is a whole array containing new values. But now I actually just need to update text of second item in contents array, and something like this doesn't work</p>
<pre><code>case 'SOME_ACTION':
return { ...state, contents[1].text: action.payload }
</code></pre>
<p>where <code>action.payload</code> is now a text I need for update.</p>
| <javascript><reactjs><redux> | 2016-02-25 13:33:28 | HQ |
35,630,098 | Convert a column of datetimes to epoch in Python | <p>I'm currently having an issue with Python. I have a Pandas DataFrame and one of the columns is a string with a date.
The format is :</p>
<blockquote>
<p>"%Y-%m-%d %H:%m:00.000". For example : "2011-04-24 01:30:00.000"</p>
</blockquote>
<p>I need to convert the entire column to integers. I tried to run this code, but it is extremely slow and I have a few million rows.</p>
<pre><code> for i in range(calls.shape[0]):
calls['dateint'][i] = int(time.mktime(time.strptime(calls.DATE[i], "%Y-%m-%d %H:%M:00.000")))
</code></pre>
<p>Do you guys know how to convert the whole column to epoch time ?</p>
<p>Thanks in advance !</p>
| <python><datetime><pandas><epoch> | 2016-02-25 14:28:34 | HQ |
35,630,842 | Ember - How to get route model inside route action | <p>Is it possible to access route model inside route action?</p>
<p>I am passing multiple objects inside a route model to template,</p>
<pre><code> model: function() {
return {
employeeList : this.store.findAll("employee"),
employee : Ember.Object.create()
}
}
</code></pre>
<p>From the route action I am want to modify the route model.employee. I tried the following, but I am not getting the object.</p>
<pre><code>actions:{
editAction : function(id) {
var emp = this.get("model");
console.log(emp.employee);
}
}
</code></pre>
<p>Can anyone give a solution to get and modify model object(employee)?</p>
| <ember.js><ember-data> | 2016-02-25 14:58:57 | HQ |
35,630,947 | @Input and other decorators and inheritance | <p>I don't really understand how object binding works, so if anyone could explain if I can use @Input() inside a base class, or better: decorators and inheritance.
For example if each form should receive a customer I have a base class:</p>
<pre><code>export class AbstractCustomerForm{
@Input() customer;
...
}
</code></pre>
<p>and then I extend this class in an actual component:</p>
<pre><code>export AwesomeCustomerForm extends AbstractCustomerForm implements OnInit{
ngOnInit(){
if(this.customer)
doSomething();
}
}
</code></pre>
<p>but this won't work, customer will never get set :(</p>
| <angular><angular2-inputs> | 2016-02-25 15:03:00 | HQ |
35,631,168 | Measure height of TextInputLayout error container | <p>Hi I have to make layout as below, edit text has to be in <code>TextInputLayout</code> to have error and floating hint functionality, and spinner on the right must have underline. My question is how to do it, because when I'm adding <code>EditText</code> into <code>TextInputLayout</code> there is a padding bellow and both underlines aren't in the same line. Is it possible to measure somehow this error container height?
<a href="https://i.stack.imgur.com/0Gs6q.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0Gs6q.png" alt="enter image description here"></a></p>
| <android><layout><android-textinputlayout> | 2016-02-25 15:12:28 | HQ |
35,632,085 | Scala REPL in Gradle | <p>At the moment Gradle's scala integration does not offer REPL functionality. How to ergonomically run a Scala REPL from Gradle with the appropriate classpath?</p>
| <scala><gradle><classpath><read-eval-print-loop> | 2016-02-25 15:51:20 | HQ |
35,632,166 | float to byte[4] to float without using BitConverter? | <p>How can I convert a float to an array of bytes then re-convert the byte array to float without using BitConverter??</p>
<p>Thanks in advance.</p>
| <c#> | 2016-02-25 15:55:05 | LQ_CLOSE |
35,632,746 | Is there a vector class or struct (with 3 components) in C#? | <p>Is there a good available vector class or struct (for vectors defined in physics with 3 components) in C#? It is like <code>c++</code>'s <code>std::array<double, 3></code> and better with inner product, cross product and other arithmetic operations.</p>
| <c#> | 2016-02-25 16:20:36 | LQ_CLOSE |
35,634,407 | sql querry- BEGGINERS- NEED HELP FOR sCHOOL | [enter image description here][1]
Id Parinte Angajator
1 Parinte1 Firma1
2 Parinte2 Firma2
3 Parinte3 Firma3
Id Copil Data_Nastere Id_Parinte Data_creare
1 Copil1 10.01.2013 1
2 Copil2 11.11.2012 1
3 Copil3 10.10.2013 2
4 Copil4 12.11.2013 2
I have these 2 tables (1st let's say table1 and 2nd table2)
I need to do the follwings operations on these 2 tables for a project tomorrow!
If anyone could help, would be much appreciated!
I need em in querry so I can copy paste it for project!
1.Show all from "Parinti" that have "Angajator" as "Firma1"
2.Show all from "Copil" that have "Parinte1"
3.Update the field "Data_creare" from table2 with current date for "Copil" that have "Parent1"
4.Delete all from "Copil" that have "Data_Naster" = 10.01.2013
5.last I need to sort the values from table2 column "Copil" ascending ascending depending of field "Data_nastere"
**Better use Image link to see the 2 tabs**
[1]: http://i.stack.imgur.com/yHp3G.jpg | <mysql><sql-server-2008> | 2016-02-25 17:39:03 | LQ_EDIT |
35,634,447 | Sum value in dictionary key python | I have a python dictionary like the one below:
{'Jason': {'A': 200, 'B': 'NaN', 'C': 34, 'D': 'NaN', 'E': True},
'John': {'A': 250, 'B': '34', 'C':98, 'D': 59, 'E': False},
'Steve': {'A': 230, 'B': '45', 'C':'NaN', 'D': 67, 'E': False},
'Louis': {'A': 220, 'B': '37', 'C':'NaN', 'D': 'Nan', 'E': True},
....
}
I want to count the number of `'NaN'` in each value, and return that count with the number of `'NaN'` that have the value `'E': True`.
So I would like to create a dictionary like this:
{'A': {'NaN': 0, 'E': 0},
'B': {'NaN': 1, 'E': 1},
'C': {'NaN': 2, 'E': 1},
'D': {'NaN': 2, 'E': 2}}
Thanks for the help! | <python><dictionary><count> | 2016-02-25 17:41:31 | LQ_EDIT |
35,636,960 | C++ Programming assignment program terminated with signal 6 | <p>This is the assignment:
Write a program that outputs a histogram of student grades for an assignment. First, the program will input the number of grades and create a dynamic array to store the grades. Then, the program should input each student's grade as an integer and store the grade in the dynamic array.</p>
<p>The program should then scan through the array and compute the histogram. In computing the histogram, the minimum value of a grade is 0 but your program should determine the maximum value entered by the user. Use a dynamic array to store the histogram. Output the histogram to the console.</p>
<p>For example, if the input is:</p>
<p>Enter number of grades:
6
Enter grades (each on a new line):
20
30
4
20
30
30
Then the output histogram should be:</p>
<p>4 *
20 **
30 ***</p>
<p>My program works fine for me but when I submit it online it tells me "Program terminated with signal 6." Im not sure what this is and im not sure what in my program is causing it. Here is my code:</p>
<pre><code>#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int numGrades;
int i,j;
int max = 0;
int *list, *hist;
cout << "Enter number of grades:" << endl;
cin >> numGrades;
list = new int[numGrades];
cout << "Enter grades (each on a new line):\n";
for(i=0;i<numGrades;i++)
{
cin >> *(list+i);
}
for(i=0;i<numGrades;i++)
{
if(max<*(list+i))
max = *(list+i);
}
hist = new int[max];
for(i=0;i<=max;i++)
{
int no=0;
for(int j=0;j<numGrades;j++)
{
if(i==*(list+j))
no++;
}
*(hist+i)=no;
}
cout << "Histogram:" << endl;
for(i=0;i<=max;i++)
{
if(*(hist+i)!=0)
{
cout << right << setw(3) << i << " ";
for(j=0;j<*(hist+i);j++)
cout << "*";
}
if(*(hist+i) != 0)
cout << endl;
}
delete []hist;
delete []list;
return 0;
}
</code></pre>
<p>Any help is appreciated, thank you.</p>
| <c++> | 2016-02-25 19:51:40 | LQ_CLOSE |
35,637,880 | Content Positioned in Y and X Middel | so I don't want my content positioned in middle along the X axis, I want the content in the middle of the Y axis to.
In my CSS I've used the following to prevent the page becoming any bigger
html { overflow-y: hidden; overflow-x: hidden }
and below is what I want to achieve. Just as an example, imagine a box in the middle. I believe this can be done with JavaScript, I'm just not sure how.
[![Example Image][1]][1]
So the image above shows the box in the middle on both X and Y axis. **Please don't post how to position it in the middle along X Axis like this website as that's not what I woud like.** Any help will be awesome, thanks!
[1]: http://i.stack.imgur.com/Y268i.png | <javascript><jquery><html><css> | 2016-02-25 20:41:33 | LQ_EDIT |
35,638,941 | Does an app that amplify your voice instantly exist? | <p>I wonder if there is any app existed that I can either speak to the android phone directly or speaking into a clip-on mic, and the app uses the phone as a speaker to amplify the voice instantly?</p>
<p>I am not trying to record the voice, but just instantly make it louder.</p>
| <android><voice-recording> | 2016-02-25 21:42:01 | LQ_CLOSE |
35,639,116 | how to make my custom directive depends on ng-model? | <p>I am new to angular js. I want to know how to make my custom directive depends on ng-model? Which line to add in <code>app.directive('myDirective',...</code> so that myDirective module will depend on ngModel?</p>
| <javascript><angularjs> | 2016-02-25 21:52:52 | LQ_CLOSE |
35,639,666 | Doing multiples of a number in java issues with implementation | <p>Im not sure how to go about making this code.. well at least the total part of this. this is my code right now, I understand the math behind it. I'm just not sure how to implement it. Would I use a loop? here is my code as of right now. I know its not correct but its the start of it.</p>
<pre><code>public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("what number would you like me to multiply: ");
int number = in.nextInt();
System.out.println("how many multiples of "+number+" would you like to see: ");
int multiple = in.nextInt();
int total =
System.out.println("total :"+total);
}
</code></pre>
<p>here is the output that I would like to get:</p>
<pre><code> What number would you like me to multiply? 4
How many multiples of 4 would you like to see? 7
The first 7 multiples of 4 are: 4, 8, 12, 16, 20, 24, 28
</code></pre>
| <java> | 2016-02-25 22:27:13 | LQ_CLOSE |
35,639,766 | Check a variable is a multiple of 10 and if not how do i round it up or down to the closest multiple of 10? | I need my program to check an in putted variable (e_gtin) and then calculate the GTIN from it (times the 1,3,5 and 7th number by three then add the 7 numbers up and divide by the nearest 10 times table) So far, it times the numbers and adds them up but I don't know where to go from there in terms of making it a multiple of ten
Any help would be appreciated.
e_gtin = input("Enter a 7 digit number - ")
gtin1 = int(e_gtin[0]) *3
print("First Digit of the GTIN8 code - ",gtin1)
gtin2 = int(e_gtin[1])
print("Second Digit of the GTIN8 code - ",gtin2)
gtin3 = int(e_gtin[2]) *3
print("Third Digit of the GTIN8 code - ",gtin3)
gtin4 = int(e_gtin[3])
print("Fourth Digit of the GTIN8 code - ",gtin4)
gtin5 = int(e_gtin[4]) *3
print("Fith Digit of the GTIN8 code - ",gtin5)
gtin6 = int(e_gtin[5])
print("Sixth Digit of the GTIN8 code - ",gtin6)
gtin7 = int(e_gtin[6]) *3
print("Seventh Digit of the GTIN8 code - ",gtin7)
GTIN7 = gtin1+ gtin2 + gtin3 + gtin4 + gtin5 + gtin6 + gtin7
from there how do I check its a multiple of ten and if it isn't how do I check which way to round, and then how do I round it?
Thanks in advance
Also this is to help with my practice GCSE Programming Coursework, which is why I'm bad with python.
| <python> | 2016-02-25 22:33:56 | LQ_EDIT |
35,641,984 | Converting a Letter to a Number in C | <p>Alright so pretty simple, I want to convert a letter to a number so that a = 0, b = 1, etc. Now I know I can do</p>
<pre><code>number = letter + '0';
</code></pre>
<p>so when I input the letter 'a' it gives me the number 145. My question is, if I am to run this on a different computer or OS, would it still give me the same number 145 for when I input the letter 'a'?</p>
| <c> | 2016-02-26 01:53:58 | LQ_CLOSE |
35,643,058 | get the float number's exponents | <p>I just started learning floating point and get to know the SME stuff. I'm still very confused about the mantissa... Can somebody explain to me how can I get the exp part of the float. I am sorry if that's a super stupid and basic question but I am having a hard time understanding it...</p>
<p>Also how do I implement the following function... clearly my implementation is wrong. But how do I do it?</p>
<pre><code>// Extract the 8-bit exponent field of single precision
// floating point number f and return it as an unsigned byte
unsigned char get_exponent_field(float f)
{
// TODO: Your code here.
int bias = 127;
int expp = (int)f;
unsigned char E = expp-bias;
return E;
}
</code></pre>
| <c><floating-point><precision> | 2016-02-26 03:47:22 | LQ_CLOSE |
35,644,778 | Reason why this C program stopped working | <p>I wonder why this program stopped working when I increase the value of array a[]
If it has, plaese tell me how to increase this value without crashing
Thanks</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int i, j, save;
char a[2082001];
memset(a,'1',2082000);
for (i=2;i<=2082000;i++)
{
if (a[i]=='1')
{
save=i;
for (j=i*2;j<=2082000;j+=i)
a[j]='0';
}
}
printf("save = %d",save);
return 0;
}
</code></pre>
| <c> | 2016-02-26 06:12:58 | LQ_CLOSE |
35,646,049 | exception on empty record Mvc4 | when there is no record,it throws exception.Control stop string IDss and It do not check If condition,how to handle that situation.please help me to improve string IDss line.
Error: There is no row at position 0.
IOSHUB.Models.MVCHelper objHelper = new IOSHUB.Models.MVCHelper();
bool isAdmin = Convert.ToBoolean(objHelper.GetSingleData(String.Format("select isAdmin from members where Id={0}", ID)));
string IDss = objHelper.GetSingleData(String.Format("select resumeID from Resumes where employeeID={0}", ID));
if (IDss == null)
{
TempData["Error"] = "Please create your resume First";
return RedirectToAction("Create", "Resume");
} | <asp.net-mvc><linq><asp.net-mvc-4><entity-framework-4> | 2016-02-26 07:36:31 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.