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,066,248
Combine Two table datas
<p><a href="https://i.stack.imgur.com/yydiK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yydiK.jpg" alt="enter image description here"></a></p> <p>I have two table A and B, i need a report by combining these two tables and the output should be as below image. How can i achieve it. Please help me out.</p>
<join><oracle11g><union-all>
2016-01-28 16:03:00
LQ_CLOSE
35,066,705
Which one is more efficient in terms of boolean in java?
<p>Which one is more efficient in terms of boolean in java ?</p> <pre><code>Boolean boolean; if(boolean == false) {} </code></pre> <p>OR</p> <pre><code>if(!boolean) {} </code></pre>
<java><performance><if-statement><boolean><conditional-statements>
2016-01-28 16:25:28
LQ_CLOSE
35,066,797
Hi Am using audio player
when the app enter the background mode the audio player should be play after 4 min. How? can u help me please am using NSTimer but is not working after 3 minutes . Pleas help me it is urgent ...
<ios><audio><tvos>
2016-01-28 16:29:10
LQ_EDIT
35,067,085
C# .net code error message in calculator code
**I am coding for calculator in c#.net. I am having an error message on txtDisplay in txtDisplay.Text. the error says "The name 'txtDisplay' does not exists in the current context".My code so far is:** using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Calc { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnOne_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnOne.Text; }
<c#><winforms>
2016-01-28 16:41:52
LQ_EDIT
35,067,290
equalsIgnoreCase not working when value are different
<p>I have a method that compare the name of two products in an arraylist, this is the method:</p> <pre><code>public void compareNames(ArrayList&lt;Register&gt; register) { Register registerNew = null; Product productNew = null; int sumEqualProducts =0; for (int i = 0; i &lt;register.size() ; i++) { if ( register.get(i).getProduct().getNameOfProduct().equalsIgnoreCase(register.get(i+1).getProduct().getNameOfProduct())) { sumEqualProducts = register.get(i).getQuantity() + register.get(i + 1).getQuantity(); register.remove(i+1); productNew = new Product(register.get(i).getProduct().getNameOfProduct(), register.get(i).getProduto().getUnitValue()); registerNew = new Register(productNew, sumEqualProducts); register.set(i, registerNew); } } } </code></pre> <p>On the arraylist, I have 3 products, [Banana,baNANA,berry]. For the firts 2 index(Banana, baNANA), it's working as expected, the if is comparing the name of products and editing the value of index, with a new that have the sum of the 2 products with same name... But, when the comparison is between Banana and berry, the if is returning true, but should be false, because the values are not equal. Also, I'm getting this error:</p> <pre><code>java.lang.IndexOutOfBoundsException: Index: 2, Size: 2 </code></pre> <p><strong>How can I fix this comparison?</strong></p>
<java><string><arraylist><indexoutofboundsexception>
2016-01-28 16:50:50
LQ_CLOSE
35,067,728
Find an image tag?
<p>I have a content editable div, this could have any tags in it, eg.</p> <pre><code>&lt;p&gt;hello&lt;/p&gt; &lt;p&gt;whatever &lt;p&gt;nested p is a bad idea but can happen&lt;/p&gt;&lt;/p&gt; &lt;div&gt;stuff&lt;/div&gt; &lt;p&gt;test&lt;img&gt;&lt;/p&gt; </code></pre> <p>For a given element, I need to find the img tag that is above it in the source order. The image tag could be a direct sibling, or a child of a sibling or even a parent of the given element.</p>
<javascript><jquery>
2016-01-28 17:10:52
LQ_CLOSE
35,068,280
Do cakephp 3.x auth only works with users table?
I have an admins table in my db with username and password.. I want to logged a user in using that. When ever I try to login, it gives me an sql error.... unknown column Users.Username is not found
<php><authentication><cakephp><cakephp-3.0>
2016-01-28 17:39:46
LQ_EDIT
35,069,173
Performance hit from using std::find
<p>I have the following code to check whether a value belongs to a list of values. eg: <code>contains({1,2,3},3)</code>. Almost always, I could write a bunch of <code>if-else</code>s. How much performance hit does the <code>contains</code> approach create? Is there a way to avoid this?</p> <pre><code>template&lt;typename T1,typename T2&gt; std::enable_if_t&lt;std::is_same&lt;std::initializer_list&lt;T2&gt;,T1&gt;::value, bool&gt; contains(const T1 &amp;container,const T2 &amp;item) { return(std::find(container.begin(),container.end(),item)!=container.end()); } </code></pre>
<c++><templates><c++11><c++14>
2016-01-28 18:25:58
LQ_CLOSE
35,069,967
Flask-Migrate and Migrations in General
I'm relatively new to flask, python, and coding overall so please bear with me if you have the time. I'm trying to understand migrations and have some questions regarding the topic. I'm working on a web-based asset management app, and I've had some modest success thus far. I've implemented a page that iterates through all my assets (rows) and displays them in a form with their associated row values (horsepower, voltage etc.) I've implemented a page that takes form data and adds it to the database. I've implemented a page that lets you filter all your assets by some of their values (horsepower, voltage etc.) and displays the result, as well as a search by primary_key (Asset Tag) bar in the header. To be honest so far I'm quietly impressing myself :). Flask is great because when I was getting started and watching a few tutorial playlists I found it easier to learn than Django. There was much less overhead / pre-written code and I actually knew what each line of code was doing, and I felt I was really grasping the operation of my application in its entirety. Anyways this is all besides the point. What I'm looking to implement now is something I feel the need to get some opinions on as I have not found much of anything regarding it online. I'd like for my customers to be able to add / remove tables, and table columns and rows. From the reading I have done I know that making schema changes is going to require migrations, so adding in that functionality would require something along the lines of writing a view that takes form data and inserts it into a function that then invokes a method of Flask-Migrate, or maybe something directly into Flask-Migrate itself? The thing is, even if I manage to build something like this, don't migrations build the required separate scripts and everything that goes along with that each time something is added or removed? Is that a practical solution for something like this, where 10 or 20 new tables might be added from the default / shipped database? Also, if I'm building in a functionality that allows users to add columns to a table, it will have to modify that tables class. I'm unsure if that's even possible, or a safe idea? I may also be looking at solving this the wrong way entirely. In that case I'd really appreciate it if someone could help me out, and at least get me pointed in the right direction. TLDR; Can you take form data and change database schema? Is it a good idea? Is there a downside to many migrations from a 'default' database?
<python><flask><sqlalchemy><alembic><flask-migrate>
2016-01-28 19:11:15
LQ_EDIT
35,071,461
Parsing a log file and inserting into mySQL DB
<p>I am currently tasked with writing up a script which will parse through our log file of mySQL errors and exceptions, and then insert them into a database.</p> <p>The general format of the log file is:</p> <pre><code>POSPER ERRORS: 01 Jan 2014 11:33:23,931 ERROR LazyInitializationException:42 - failed to lazily initialize a collection of role: org.data.moredata.CashRegister.tickets, no session or session was closed </code></pre> <p>There are many more lines, but this is just an example of how the error log is currently formatted.The posper errors header only appears once, and subsequent lines are simply more errors.</p> <p>What I need to do with this script is insert errors into the table I have created with the fields: client_name, timestamp, error_message and error_from (either Posper or a something else. In the example above it is posper). </p> <p>So how exactly am I supposed to break down the data on each line, assign it to individual mySQL fields, and then insert it into the database? Keep in mind the log file will have many lines, so it will have to execute multiple times. I have already set up the table with the appropriate fields.</p> <p>Any help would be greatly appreciated. </p>
<mysql><bash>
2016-01-28 20:33:31
LQ_CLOSE
35,071,796
create instance of class inside namespace
is a better way to implement this code ? int getBlockVector(vector<unsigned char>& vect, const int pos, const int length) { int destinyInt = 0; switch (length) { case 1 : destinyInt = (0x00 << 24) | (0x00 << 16) | (0x00 << 8) | vecct.at(pos); break; case 2 : destinyInt = (0x00 << 24) | (0x00 << 16) | (vect.at(pos + 1) << 8) | vect.at(pos); break; case 3 : destinyInt = (0x00 << 24) | (vect.at(pos + 2) << 16) | (vect.at(pos + 1) << 8) | vect.at(pos); break; case 4 : destinyInt = (vect.at(pos + 3) << 24) | (vect.at(pos + 2) << 16) | (vect.at(pos + 1) << 8) | vect.at(pos); break; default : destinyInt = -1; return destinyInt;} considering the ugly default value. How implement this function with iterators and template for vector, deque, queue, etc. Note: the bounds are checked before.
<c++>
2016-01-28 20:52:52
LQ_EDIT
35,072,066
(C++) Not able to create objects different objects even when I give different constructor parameters
<p>I am making a basic card system in C++. It is object-oriented, of course. All I did was a class for the card stack, another for the card itself and the main class. But as I was trying to make this project, I noticed that all the cards that I made were the same! It seems to me that the problem lays on the creating of the object itself. Check it out, guys:</p> <p>Main.cpp</p> <pre><code>#include "Header.h" using namespace std; char cardTypes[4] = { CARD_TYPE_HEARTS,CARD_TYPE_SPADES,CARD_TYPE_CLUBS,CARD_TYPE_DIAMONDS }; int main(void) { setlocale(LC_ALL, "Portuguese"); srand((unsigned)time(NULL)); CardStack stack; for (int i = 0; i &lt; 4; i++) { char type = cardTypes[i]; for (int j = 0; j &lt;= 13; j++) { stack.add(&amp;Card(j, type)); } } stack.shuffle(); cout &lt;&lt; stack.getCard(0)-&gt;translateMe() &lt;&lt; endl; cout &lt;&lt; stack.getCard(1)-&gt;translateMe() &lt;&lt; endl; cout &lt;&lt; stack.getCard(2)-&gt;translateMe() &lt;&lt; endl; return 0; } </code></pre> <p>Header.h</p> <pre><code>#ifndef HEADER_H #define HEADER_H #include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;time.h&gt; #include &lt;random&gt; #include &lt;string&gt; using namespace std; #define CARD_POS_STACK 0 #define CARD_TYPE_HEARTS 'H' #define CARD_TYPE_SPADES 'S' #define CARD_TYPE_CLUBS 'C' #define CARD_TYPE_DIAMONDS 'D' #define CARD_TYPE_NONE ' ' #define CARD_JOKER 0 #define CARD_ACE 1 #define CARD_2 2 #define CARD_3 3 #define CARD_4 4 #define CARD_5 5 #define CARD_6 6 #define CARD_7 7 #define CARD_8 8 #define CARD_9 9 #define CARD_10 10 #define CARD_JACK 11 #define CARD_QUEEN 12 #define CARD_KING 13 class Card { private: char type; /* type can be H (hearts), S (spades), C (clubs) or D (diamonds) */ short num; /* coringa = 0, J = 11, Q = 12 and K = 13*/ int pos; /* 0 = stack */ public: /* &gt; Creates a card */ Card(short num, char type); /* &gt; Recieves the card's type */ char getType(); /* &gt; Recieves the card's number */ short getNum(); /* &gt; Translates the number */ string translateMe(); /* &gt; Recieves the card's position on the table */ int getPos(); /* &gt; Checks if a card is equal to another */ bool isEqual(Card* another); }; class CardStack { private: vector&lt;Card*&gt; cards; int numOfCards; public: int getSize(); /* &gt; Checks if there is any item in the stack */ bool isEmpty(); /* &gt; Add a card to the top of the stack */ void add(Card* theCard); /* &gt; Remove a card from the stack */ void remove(Card* theCard); /* &gt; Shuffles randomly the card */ void shuffle(); /* &gt; Get a certain card */ Card* getCard(int i); /* &gt; Gets the card at the top of the stack */ Card* getTopCard(); /* &gt; Generates an empty stack */ CardStack(); }; #endif </code></pre> <p>Card.cpp</p> <pre><code>#include "Header.h" Card::Card(short cardNum, char cardType){ num = cardNum; if (cardNum = CARD_JOKER) type = CARD_TYPE_NONE; else type = cardType; pos = CARD_POS_STACK; } string Card::translateMe() { string message = ""; switch (num) { case 0: message.append("Coringa"); break; case 11: message.append("Valete de"); break; case 12: message.append("Rainha de "); break; case 13: message.append("Rei de "); break; default: message.append(to_string(num)+" de "); } switch (type) { case CARD_TYPE_CLUBS: message.append("Paus"); break; case CARD_TYPE_DIAMONDS: message.append("Ouros"); break; case CARD_TYPE_HEARTS: message.append("Copas"); break; case CARD_TYPE_SPADES: message.append("Espadas"); break; } return message; } char Card::getType() { return type; } short Card::getNum() { return num; } int Card::getPos() { return pos; } bool Card::isEqual(Card* another) { return this == another; } </code></pre> <p>CardStack.cpp</p> <pre><code>#include "Header.h" #include &lt;algorithm&gt; bool CardStack::isEmpty() { return numOfCards == 0 ? true : false; } void CardStack::add(Card* theCard) { cards.push_back(theCard); } void CardStack::remove(Card* theCard) { for (int i = 0; i &lt; cards.size(); i++) if (theCard-&gt;isEqual(cards[i])) cards.erase(cards.begin() + i); } CardStack::CardStack() { numOfCards = 0; } void CardStack::shuffle() { random_shuffle(cards.begin(), cards.end()); } Card* CardStack::getCard(int i) { return cards.at(i); } Card* CardStack::getTopCard() { return cards.front(); } int CardStack::getSize() { numOfCards = cards.size(); return numOfCards; } </code></pre> <p>And the output is the following:</p> <pre><code>"Rei de Ouros" "Rei de Ouros" "Rei de Ouros" </code></pre>
<c++><object>
2016-01-28 21:08:31
LQ_CLOSE
35,072,334
C expected identifier or β€˜(’ before β€˜{’
<p>The point of the exercise (for university) is to create a function that calculates the perimeter of a triangle once given the coordinates of its 3 corners. I am a beginner at C and after some work I have managed to create a code that more or less does its intended job, however i have stumbled upon the following error: </p> <p>trperim.c:25:1: error: expected identifier or β€˜(’ before β€˜{’ token { ^ trperim.c:31:58: error: expected identifier or β€˜(’ before β€˜{’ token double trperim(double r1[2], double r2[2], double r3[2]);{</p> <p>I have been unable to solve this, and so I turn to this community. Any help would be greatly appreciated.</p> <pre><code>#include&lt;stdio.h&gt; #include&lt;math.h&gt; double trperim(double r1[2], double r2[2], double r3[2]); double norm(double r[2]); main() { double r1[2], r2[2], r3[2]; printf("Ingrese las coordenadas del primer vertice en x:"); scanf("%lf",&amp;r1[0]); printf("Ingrese las coordenadas del primer vertice en y:"); scanf("%lf",&amp;r1[1]); printf("Ingrese las coordenadas del segundo vertice en x:"); scanf("%lf",&amp;r2[0]); printf("Ingrese las coordenadas del segundo vertice en y:"); scanf("%lf",&amp;r2[1]); printf("Ingrese las coordenadas del tercer vertice en x:"); scanf("%lf",&amp;r3[0]); printf("Ingrese las coordenadas del tercer vertice en y:"); scanf("%lf",&amp;r3[1]); printf("El perimetro del triangulo es %f\n", trperim(r1,r2,r3)); } double norm(double r[2]); { double modulo, r[2]; modulo=sqrt(pow(r[0],2)+pow(r[1],2)); return modulo; } double trperim(double r1[2], double r2[2], double r3[2]);{ double nr1, nr2, nr3, p; nr1=norm(r1-r2); nr2=norm(r2-r3); nr3=norm(r3-r1); p=nr1+nr2+nr3; return p; } </code></pre>
<c>
2016-01-28 21:24:52
LQ_CLOSE
35,073,492
Html email form do not send mail
<p>Hello and the end of my website i have this form :</p> <pre><code>&lt;section class="contact" id="contact"&gt; &lt;h1&gt;Contact&lt;/h1&gt; &lt;hr/&gt; &lt;div class="content"&gt; &lt;div class="form"&gt; &lt;form action="#" method="post" enctype="text/plain"&gt; &lt;input name="your-name" id="your-name" value="Numele Tau" /&gt; &lt;input name="your-email" id="your-email" value="Adresa de E-mail sau Telefon" /&gt; &lt;textarea id="message" name="message" &gt;Mesajul Tau&lt;/textarea&gt; &lt;a href="#"&gt; &lt;div class="button"&gt; &lt;span&gt;SEND&lt;/span&gt; &lt;/div&gt; &lt;/a&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>What i an wondering is how can i make send email to a certain mail with all that info ?</p> <p>Thanks, and sorry for my english,</p>
<php><html><email>
2016-01-28 22:36:57
LQ_CLOSE
35,073,650
Go to hyperlink on scroll?
<p>I have a question:</p> <p>Is it possible to go to a hyperlink once you scroll past a certain point? I don't mean jumping to an anchor, I mean once you scroll past an anchor or point a new page loads.</p> <p>Any help will be appreciated!</p> <p>Thanks,</p> <p>Samson Zhang</p>
<javascript><html><css><scroll><hyperlink>
2016-01-28 22:48:42
LQ_CLOSE
35,075,238
Too many arguments error? yes i am a novice coder
I am building a laser that is to be controlled by a joystick. the joystick uses 2 servo motors to move the laser in the direction i want. i am using an arduino board that uses C++ coding. i keep getting a " too many arguments" error on my outputs and i don't know why. i would appreciate if anyone can help me fix my code. <!-- begin snippet: js hide: false --> <!-- language: lang-css --> #include <Servo.h> const int servo1 = 11; // first servo const int servo2 = 10; // second servo const int joy1 = 5; // switch 1 const int joy2 = 4; // switch 2 const int joy3 = 3; // switch 3 const int joy4 = 2; // switch 4 int servoVal; // variable to read the value from the digital pin Servo myservo1; // create servo object to control a servo Servo myservo2; // create servo object to control a servo void setup() { // Servo myservo1.attach(servo1); // attaches the servo myservo2.attach(servo2); // attaches the servo // Inizialize Serial Serial.begin(9600); } void loop(){ // Display Joystick values using the serial monitor outputJoystick(); // Read the horizontal joystick value (value between 0 and 180) servoVal = digitalRead(joy1, joy2, joy3, joy4); servoVal = map(servoVal, 0, 45, 135, 180); // scale it to use it with the servo (result between 0 and 180) myservo2.write(servoVal); // sets the servo position according to the scaled value // Read the horizontal joystick value (value between 0 and 180) servoVal = digitalRead(joy1, joy2, joy3, joy4); servoVal = map(servoVal, 0, 45, 135, 180); // scale it to use it with the servo (result between 0 and 180) myservo1.write(servoVal); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there } /** * Display joystick values */ void outputJoystick(){ Serial.print(digitalRead(joy1, joy2, joy3, joy4)); Serial.print ("---"); Serial.print(digitalRead(joy1, joy2, joy3, joy4)); Serial.println ("----------------"); } <!-- end snippet -->
<arduino>
2016-01-29 01:13:44
LQ_EDIT
35,076,960
how to do a smoth scoll down a page with javascript
so im trying to make the for loop increase the height by 1 each loop which will make the screen drop by the height of one. Using a time interval for a very short amount of time I would believe this would make a smooth scroll down the page.
<javascript>
2016-01-29 04:35:21
LQ_EDIT
35,076,996
datetime data type seperate am and pm as checkin and checkout MSSQL
[I need to separate the checkintime column as AM as checkin and PM as checkout ][1] [1]: http://i.stack.imgur.com/1dvUT.jpg
<php><sql-server><datetime><time-and-attendance>
2016-01-29 04:40:18
LQ_EDIT
35,078,845
Mysql database expert needed
I have a question about mysql $result = mysql_query(" SELECT * FROM Table order by rand() limit 10 When i write the script 10 row is fetch in 2-3 second Is it possible to Fetch each 1 row with 2 second
<mysql><database>
2016-01-29 07:16:38
LQ_EDIT
35,078,899
How this program is being evaluated?
#include<stdio.h> int main(void) { int i=10; if(i==(20||10)) printf("True"); else printf("False"); return 0; } // gives output: False //Please explain me how this program works??
<c><logical-operators>
2016-01-29 07:20:18
LQ_EDIT
35,079,509
Bootstrap button tooltip hide on click
<p>On my site I have some buttons. When a user clicks the button, a modal opens. When a user hovers the button, a tooltip is shown.</p> <p>Is use this code:</p> <pre><code>&lt;button type="button" rel="tooltip" title="Tooltip content" class="btn btn-sm btn-default" data-toggle="modal" data-target="#DeleteUserModal"&gt; &lt;span class="glyphicon glyphicon-remove"&gt;&lt;/span&gt; &lt;/button&gt; &lt;div&gt;modal&lt;/div&gt; &lt;script&gt; $(document).ready(function(){ $('[rel="tooltip"]').tooltip(); }); &lt;/script&gt; </code></pre> <p>This works, but the only problem is that the tooltip stays visible after the button is clicked, and the modal is shown. As soon as the modal is closed, the tooltip is hidden again.</p> <p>How to prevent this? I only want the tooltip to be shown on hover, and not all the time when the related modal is visible.</p>
<twitter-bootstrap>
2016-01-29 08:00:04
HQ
35,079,697
Capibara/Selenium vs Robot Framework for Rails
I have to decided to choose between Rspec/Capibara over Robot Framework for integration tests. Previously Robot framework was used for integration testing in the project I am working on. As I now joined the team so I tried to change it to Rspec based integration testing using Capibara but I have to convince the top management that Rspec and Capibara is better option for Rails based application. So basically I need a comparison table between these two frameworks Which will tell that Rspec is better option than Python Robot Framework (if it is better option)
<ruby-on-rails><ruby><selenium><rspec><automated-tests>
2016-01-29 08:12:35
LQ_EDIT
35,080,280
Spy on setTimeout and clearTimeout in Karma and Jasmine
<p>I cannot seem to be able to spy on <code>setTimeout</code> and <code>clearTimeout</code> in my Jasmine tests, which are being run through Karma. </p> <p>I have tried variations on all of this</p> <pre><code>spyOn(window, 'setTimeout').and.callFake(()=&gt;{}); spyOn(global, 'setTimeout').and.callFake(()=&gt;{}); spyOn(window, 'clearTimeout').and.callThrough(); clock = jasmine.clock(); clock.install(); spyOn(clock, 'setTimeout').and.callThrough(); runMyCode(); expect(window.setTimeout).toHaveBeenCalled(); // no expect(global.setTimeout).toHaveBeenCalled(); // nope expect(window.clearTimeout).toHaveBeenCalled(); // no again expect(clock.setTimeout).toHaveBeenCalled(); // and no </code></pre> <p>In every case, I can confirm that <code>setTimeout</code> and <code>clearTimeout</code> have been invoked in <code>runMyCode</code>, but instead I always get <code>Expected spy setTimeout to have been called.</code></p> <p>For <code>window</code>, clearly this is because the test and the runner (the Karma window) are in different frames (so why should I expect anything different). But because of this, I can't see any way to confirm that these global functions have been invoked.</p> <p>I know that I can use <code>jasmine.clock()</code> to confirm that timeout/interval callbacks have been invoked, but it looks like I can't watch <code>setTimeout</code> itself. And confirming that <code>clearTimeout</code> has been called simply isn't possible.</p> <p>At this point, the only thing I can think of is to add a separate layer of abstraction to wrap <code>setTimeout</code> and <code>clearTimeout</code> or to inject the functions as dependencies, which I've done before, but I think is weird.</p>
<javascript><unit-testing><jasmine><karma-jasmine>
2016-01-29 08:47:39
HQ
35,080,845
Angular ng-table with Goto page
<p>I'm using ng-table to setup a custom pagination control. I want to have an input that only allows valid page numbers. I have the existing pagination so far.</p> <pre><code>script(type="text/ng-template" id="ng-table-pagination-input") div(class="ng-cloak ng-table-pager" ng-if="params.data.length") br ul(ng-if="pages.length" class="pagination ng-table-pagination") li(ng-class="{'disabled': !page.active &amp;&amp; !page.current, 'active': page.current}" ng-repeat="page in pages" ng-switch="page.type") a(ng-switch-when="prev" ng-click="params.page(page.number)" href="") span &amp;laquo; a(ng-switch-when="next" ng-click="params.page(page.number)" href="") span &amp;raquo; </code></pre> <p>How can I get an input control in there to work properly?</p>
<javascript><angularjs><ngtable>
2016-01-29 09:21:20
HQ
35,080,852
return out of function
<p>Hi im working on a code but it is not working because i get the error: 'return' out of function</p> <p>here is my code</p> <pre><code>def get_information(): names_list=[] coursework_marks_list=[] prelim_marks_list=[] file=open("details.txt","r") for line in file: item=line.split() if len(item)&gt;1: names_list.append(item[0]) coursework_marks_list.append(item[1]) prelim_marks_list.append(item[2]) return names_list,coursework_marks_list,prelim_marks_list </code></pre>
<python><return>
2016-01-29 09:21:48
LQ_CLOSE
35,081,194
Why is IEnumerable(of T) not accepted as extension method receiver
<p>Complete <strong>question</strong> before code:</p> <p>Why is <code>IEnumerable&lt;T&gt;</code> <code>where T : ITest</code> not accepted as receiver of an extension method that expects <code>this IEnumerable&lt;ITest&gt;</code>?</p> <p>And now the <strong>code</strong>:</p> <p>I have three types:</p> <pre><code>public interface ITest { } public class Element : ITest { } public class ElementInfo : ITest { } </code></pre> <p>And two extension methods:</p> <pre><code>public static class Extensions { public static IEnumerable&lt;ElementInfo&gt; Method&lt;T&gt;( this IEnumerable&lt;T&gt; collection) where T : ITest { β†’ return collection.ToInfoObjects(); } public static IEnumerable&lt;ElementInfo&gt; ToInfoObjects( this IEnumerable&lt;ITest&gt; collection) { return collection.Select(item =&gt; new ElementInfo()); } } </code></pre> <p>The compiler error I get (on the marked line):</p> <blockquote> <p><code>CS1929</code> : <code>'IEnumerable&lt;T&gt;'</code> does not contain a definition for <code>'ToInfoObjects'</code> and the best extension method overload <code>'Extensions.ToInfoObjects(IEnumerable&lt;ITest&gt;)'</code> requires a receiver of type <code>'IEnumerable&lt;ITest&gt;'</code></p> </blockquote> <p>Why is this so? The receiver of the <code>ToInfoObjects</code> extension method is an <code>IEnumerable&lt;T&gt;</code> and by the generic type constraint, <code>T</code> must implement <code>ITest</code>. </p> <p><strong>Why is then the receiver not accepted</strong>? My guess is the covariance of the <code>IEnumerable&lt;T&gt;</code> but I am not sure.</p> <p>If I change <code>ToInfoObjects</code> to receive <code>IEnumerable&lt;T&gt; where T : ITest</code>, then everything is ok.</p>
<c#><.net><generics><extension-methods><type-inference>
2016-01-29 09:39:17
HQ
35,081,810
Error with Array.map() in IE11
<p>I have this code:</p> <pre><code>var labelsPrint= new Array(); var vector = labelsPrint.map((el) =&gt; el.id); </code></pre> <p>IE11 give me a error, because lost the datas. Do you know an other way for make this .map?</p>
<javascript><arrays><hashmap>
2016-01-29 10:09:50
HQ
35,082,206
how to filter the existing month into next month
i have a code : SELECT pegawai.Nama, pegawai.Tempat_Lahir, pegawai.Tanggal_lahir, pegawai.NIP, pegawai.Tingkat_Ijasah, pegawai.Jurusan, pegawai.Golongan_CPNS,pegawai.TMT_CPNS, pegawai.Alamat, pensiun.TMT_Pensiun, pensiun.SKPensiun from pegawai JOIN pensiun on pegawai.NIP=pensiun.NIP) WHERE (MONTH(CONVERT(Date, Month)) = MONTH(GETDATE()) + 1)) AS pensiun.TMT_Pensiun months in the filter is TMT_Pensiun
<mysql><sql>
2016-01-29 10:29:00
LQ_EDIT
35,082,429
Shell Script to find string of file A in File B and print Yes or No in front of particular string
<p>I have two file A &amp; B. File A contains some strings. I wanted to find strings in file B &amp; if a string is there in file B. Print Yes in front of string in file A otherwise print NO.</p> <p>Propose any solution.</p>
<linux><bash><shell><unix><scripting>
2016-01-29 10:40:50
LQ_CLOSE
35,082,895
Please help me write the outcome of is statement to a python file
I have a rather stupid question to ask, but I have, can someone explain to me what I am doing wrong ? I have two files: file1 looks like this NOP7 305 CDC24 78 SSA1 41 NOP7 334 LCB5 94 FUS3 183 file2 looks like this SSA1 550 S HSP70 1YUW FUS3 181 Y Pkinase 1QMZ FUS3 179 T Pkinase 1QMZ CDC28 18 Y Pkinase 1QMZ And I'm using the following code-lit to get proteins-names that match in lists from other files file = open('file1') for line in file1: line=line.strip().split() with open('file2') as file2: for l in out: l=l.strip().split() if line[0]==l[0]: take=line[0] with open('file3', 'w') as file3: file3.write("{}".format(take)) what I get a file with one protein name only CDC28 And what I want is all the proteins that matches, eg SSA1 CDC28 FUS3 Please guide ...... ?? PS: when I print the result I get the required values (protein names) printed but can not able to write to a file.
<python><file><split><fwrite>
2016-01-29 11:03:53
LQ_EDIT
35,083,608
syntax of join in sql
<p>i want to know the syntax of joins in sql so please help regarding this</p> <p>thanks</p>
<mysql><sql><database>
2016-01-29 11:38:53
LQ_CLOSE
35,083,637
OPENVPN route local net to remote server
<p>I have configured a openvpn connection from my debian pc to my remote debian server, and it works. In fact, I can ping 10.0.0.1 (address in vpn of the server).</p> <p>Now I want to share this connection. I want my other clients on lan can access the server without openvpn client. How can I do it?</p> <p>My lan standard address are 192.168.2.x. How can I set the 192.168.2.123 address to connect directly to remote server?</p>
<routes><openvpn>
2016-01-29 11:39:57
LQ_CLOSE
35,083,779
How to convert strings to DateTime C#
<p>I have 3 separate strings with the following format: </p> <p><code>01-29-2016</code>: a date, picked from a bootstrap datepicker</p> <p><code>1:00am</code> start time, picked from a dropdown, format could also be e.g. 10:00pm</p> <p><code>2:30am</code> end time, picked from a dropdown, format could also be e.g. 11:30pm</p> <p>Using the above strings I need to construct 2 DateTime properties that represent the time range, something like below:</p> <p><code>2016-01-29 02:30:00</code></p> <p><code>2016-01-29 01:00:00</code></p> <p>I need the DateTime properties so I could update datetime database fields</p>
<c#><.net><datetime>
2016-01-29 11:46:22
LQ_CLOSE
35,083,787
The usage of computed properties in swift
<p>computed properties evaluated every time they are accessed(I mean the getter is called everytime),so why I just use a stored properties?</p>
<swift>
2016-01-29 11:46:46
LQ_CLOSE
35,084,398
Rstudio on MAC OS X EI Capitan Package "Rsymphony" for " image not found"How can I solve it Thanks for any answer
Rstudio on MAC OS X EI Capitan cannot library the Package "Rsymphony" ,for the reason "Reason: image not found" , How can I solve the thorny problem? Thanks for any answer...
<r>
2016-01-29 12:17:25
LQ_EDIT
35,084,773
Why is first HttpClient.PostAsync call extremely slow in my C# winforms app?
<p>I have an httpclient like this : </p> <pre><code>var client = new HttpClient(); </code></pre> <p>I post to it like this:</p> <pre><code>var result = client.PostAsync( endpointUri, requestContent); </code></pre> <p>And get the response like this:</p> <pre><code>HttpResponseMessage response = result.Result; </code></pre> <p>I understand this call will block the thread, thats how its supposed to work (just building a tool for myself, no async threads needed)</p> <p>The first time I run this call, it takes about 2 minutes to get a result. Meanwhile, if I do the exact same call elsewhere its done in 200ms. Even if I hit google, it takes 2 minutes. But, after the first call, as long as I keep the app open any additional calls are good. Its just the first cal when I open the application. What could be causing this?</p>
<c#><winforms><dotnet-httpclient>
2016-01-29 12:38:23
HQ
35,084,860
How to retain text between regex matches in Javascript?
I would like to extract some tags from string and perform some operations according to them, but the remaining string should retain with stripped tags and go for further processing. Is it possible to do this in one run? For example, if I have a code, which is taking tags: while (match = regex.exec(str)) { result.push( match[1] ); } can I take what between matches simultaneously?
<javascript><regex>
2016-01-29 12:42:56
LQ_EDIT
35,085,032
AutoCompleteView in Dialog Box
<p>I am trying to implement a AutoCompleteView inside one of my dialog boxes. I have been following some tutorials but cant seem to see when I am going wrong. When ever I click the button to launch the dialog box the app crashes with the below error. Is the AutoCompleteView correct?</p> <p><strong>Error</strong></p> <pre><code>01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: FATAL EXCEPTION: main 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: Process: com.example.rory.prototypev2, PID: 5481 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.Cursor android.database.sqlite.SQLiteDatabase.query(java.lang.String, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String)' on a null object reference 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at com.example.rory.prototypev2.DBMain.getIngredientsForInput(DBMain.java:418) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at com.example.rory.prototypev2.enterRecipe$1.onClick(enterRecipe.java:72) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.view.View.performClick(View.java:5204) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:21153) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) </code></pre> <p><strong>Dialog with AutoCompleteView</strong></p> <pre><code> ingredient = (Button) findViewById(R.id.showIngredientDialog); ingredient.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { db1.open(); String filler = "Filler"; recipe_number = db1.insertRecipe(filler); // custom ingredient_dialog final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.ingredient_dialog); dialog.setTitle("Add Ingredient"); // set the custom ingredient_dialog components //final EditText ingredient = (EditText) dialog.findViewById(R.id.name); String[] list = db1.getIngredientsForInput(); text = (AutoCompleteTextView)findViewById(R.id.name); ArrayAdapter adapter3 = new ArrayAdapter(getApplicationContext(),android.R.layout.simple_list_item_1,list); text.setAdapter(adapter3); text.setThreshold(1); </code></pre> <p><strong>Dialog XML</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;AutoCompleteTextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:layout_marginTop="72dp" android:hint="AutoComplete TextView"&gt; &lt;requestFocus /&gt; &lt;/AutoCompleteTextView&gt; &lt;Spinner android:id="@+id/measurement" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/name" android:layout_alignParentStart="true" android:entries="@array/measurements"/&gt; &lt;Spinner android:id="@+id/unit" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/measurement" android:layout_alignParentStart="true" android:entries="@array/units"/&gt; &lt;Button android:id="@+id/dialogButtonNext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Next" android:layout_below="@+id/unit" android:layout_toStartOf="@+id/dialogButtonOK" /&gt; &lt;Button android:id="@+id/dialogButtonOK" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" Ok " android:layout_marginRight="5dp" android:layout_below="@+id/unit" android:layout_toEndOf="@+id/name" android:gravity="center"/&gt; </code></pre> <p></p> <p><strong>getIngredientsForInput()</strong></p> <pre><code> public String[] getIngredientsForInput() { Cursor cursor = this.sqliteDBInstance.query(CONTENTS_TABLE, new String[] {KEY_CONTENTS_NAME}, null, null, null, null, null); if(cursor.getCount() &gt;0) { String[] str = new String[cursor.getCount()]; int i = 0; while (cursor.moveToNext()) { str[i] = cursor.getString(cursor.getColumnIndex(KEY_CONTENTS_NAME)); i++; } return str; } else { return new String[] {}; } } </code></pre>
<android><sqlite><autocompletetextview>
2016-01-29 12:51:19
LQ_CLOSE
35,085,205
difference in the style of giving comments between C and C++
Is there any difference between a commenting style between C(`/*..*/`) and C++(`//`)? **MISRA C says** > Rule 2.2 (required): Source code shall only use /* … */ style > comments. **MISRA C++ says** Rule 2.7.1 (required): The character sequence /* shall not be used with c style comments. Can any one explain me what could be the difference?
<c++><c><misra>
2016-01-29 13:00:34
LQ_EDIT
35,085,579
Linq for nested loop
<p>I have a loop as follows:</p> <pre><code>foreach(x in myColl) { foreach(var y in x.MyList) { result.Add(x.MyKey + y) } } </code></pre> <p>That means within my inner loop I need access to a property of the current outer element. </p> <p>IΒ΄m looking for a LINQ-statement but IΒ΄m unsure on it. I tried it by using </p> <pre><code>result = myColl .SelectMany(x =&gt; x.MyList) .SelectMany(x =&gt; /* how to get the key of the outer loop here */ + x) </code></pre>
<c#><linq>
2016-01-29 13:19:11
HQ
35,085,981
How to change Navigation Drawer icon color in Android Studio?
<p>I am not getting answer. because when i am giving transparent color for toolbar on one activity then i am not able to see navigation drawer icon. Please help me out.</p>
<android>
2016-01-29 13:40:44
LQ_CLOSE
35,086,423
Android - change Date format to - dd.mm.yyyy HH:mm
<p>I have a Date object like this:</p> <pre><code>Fri Jan 29 13:22:57 GMT+01:00 2016 </code></pre> <p>And I need it to look like this:</p> <p><strong><em>29.01.2016 13:22</em></strong></p> <p>How can I do that ?</p>
<android><simpledateformat><date-formatting>
2016-01-29 14:02:30
LQ_CLOSE
35,086,676
c# - SQL update statement
<p>I need help with my SQL connection. I have this code:</p> <pre><code> SqlConnection myConnection2 = new SqlConnection("server=c1212\\SQLEXPRESS;" + "Trusted_Connection=yes;" + "database=SPZ; " + "connection timeout=30"); try { myConnection2.Open(); SqlCommand myCommand2 = new SqlCommand(); myCommand2.CommandText = "UPDATE SPZ set Datum='" + textBox1.Text+"' , ČasP='"+textBox5.Text+"', ČasO='"+textBox6.Text+"', SPZ='"+textBox2.Text+"', PΕ™Γ­jmenΓ­='"+textBox3.Text+"', Firma='"+textBox4.Text+"', PoznΓ‘mka='"+textBox7.Text+"', Kontrola='"+textBox8.Text+ "' where Datum='" + textBox9.Text + "' and ČasP='" + textBox13.Text + "' and ČasO='" + textBox14.Text + "' and SPZ='" + textBox10.Text + "' and PΕ™Γ­jmenΓ­='" + textBox11.Text + "' and Firma='" + textBox12.Text + "' and PoznΓ‘mka='" + textBox15.Text + "' and Kontrola='" + textBox16.Text + "'"; myCommand2.ExecuteNonQuery(); // myConnection.Close(); } catch (SqlException ex) { MessageBox.Show("PΕ™ipojenΓ­ do databΓ‘ze selhalo! " + ex.Message); } </code></pre> <p>I can't find what is wrong, can someone help me? </p>
<c#><sql>
2016-01-29 14:16:06
LQ_CLOSE
35,086,827
ReactNative TextInput not visible iOS
<p>I have the following stripped down render result:</p> <pre><code>return ( &lt;View style={{backgroundColor:'red'}}&gt; &lt;TextInput value={'Hello'}/&gt; &lt;/View&gt; ); </code></pre> <p>The generated TextInput is not visible in iOS, unless I specify the height, and when using flexDirection:'row' in its container, I need to specify its width as well.</p> <p>This only happens with iOS, Android seems to work as expected. </p> <p>Is there a way of displaying a TextInput in iOS without fixed size? </p> <p>Current dependencies:</p> <pre><code> "dependencies": { "react-native": "=0.18.1", "react-native-orientation": "=1.12.2", "react-native-vector-icons": "=1.1.0" }, </code></pre> <p>iOS: </p> <p><a href="https://i.stack.imgur.com/bKPlY.png"><img src="https://i.stack.imgur.com/bKPlY.png" alt="enter image description here"></a></p> <p>Android: </p> <p><a href="https://i.stack.imgur.com/gg7VC.png"><img src="https://i.stack.imgur.com/gg7VC.png" alt="enter image description here"></a></p> <p>Changing the render like this: </p> <pre><code>return ( &lt;View style={{backgroundColor:'red'}}&gt; &lt;Text&gt;text&lt;/Text&gt; &lt;TextInput value={'Hello'}/&gt; &lt;/View&gt; ); </code></pre> <p>has the following result:</p> <p>iOS:</p> <p><a href="https://i.stack.imgur.com/SEGN0.png"><img src="https://i.stack.imgur.com/SEGN0.png" alt="enter image description here"></a></p> <p>Android:</p> <p><a href="https://i.stack.imgur.com/MHzvI.png"><img src="https://i.stack.imgur.com/MHzvI.png" alt="enter image description here"></a></p>
<ios><react-native>
2016-01-29 14:23:31
HQ
35,087,555
java bitwise left shift
<p>I understand all of the bitwise operations (in Java specifically) except bitwise left shift. I've combed the "stacks" and read many "explanations" on different pages, but I am still left unsatisfied. Either this is an extremely complicated concept or it is not well understood and obscure. But, I know it must be relevant to some extent because I have seen Java algorithms (today) that indeed use the left shift operator "&lt;&lt;". So if someone could break this down in plain English that would be great! </p>
<java><bit-manipulation><bitwise-operators><bit-shift>
2016-01-29 15:01:47
LQ_CLOSE
35,087,844
Search for code or text in GitLab
<p>Is it possible to search for code or text in GitLab inside of files? I can search for files, issues, milestones, etc., but could not find a way to search for code in source files or text in the documentation i.e .doc files.</p>
<search><gitlab>
2016-01-29 15:15:23
HQ
35,087,846
How to check if a commit has been merged to my current branch - somewhere in time?
<p>I have a random feature/XXXXXXX branch that has some commits and naturally the "develop" branch where those features are eventually merged.</p> <p>How do I check if a certain old commit (e.g. commit ab123456 from branch feature/user-registration) has been somehow brought/merged to my currently active branch (e.g. develop)? Either by directly merging the feature branch to develop or by going up/merged through some other intermediary branch.</p> <p>Through git commands or through SourceTree UI, both ways are equally suitable for me.</p>
<git><merge><atlassian-sourcetree><sourcetree>
2016-01-29 15:15:33
HQ
35,087,948
High Presicion Random Double Numbers
This is a follow up question on an answer on this page: [How to generate random double numbers with high precision in C++?][1] #include <iostream> #include <random> #include <iomanip> int main() { std::random_device rd; std::mt19937 e2(rd()); std::uniform_real_distribution<> dist(1, 10); for( int i = 0 ; i < 10; ++i ) { std::cout << std::fixed << std::setprecision(10) << dist(e2) << std::endl ; } return 0 ; } The answer works fine but I had a hard time to reliaze how to put the output of this code in a double variable instead of printing it on the STDOUT. Can anyone help with this? Thanks. [1]: http://stackoverflow.com/a/18131869/3199911
<c++>
2016-01-29 15:20:40
LQ_EDIT
35,090,591
Is there a way to force Bazel to run tests serially
<p>By default, Bazel runs tests in a parallel fashion to speed things up. However, I have a resource (GPU) that can't handle parallel jobs due to the GPU memory limit. Is there a way to force Bazel to run tests in a serial, i.e., non-parallel way? </p> <p>Thanks.</p>
<gpu><tensorflow><bazel>
2016-01-29 17:34:32
HQ
35,091,169
Can't parse my string into a JSON object in javascript
I am working on a parser for a text file. I am trying to parse some strings into JSON objects so I can easily display some different values on a webapp page (using flask). I am passing the strings into my html page using jinja2, and trying to parse them JSON objects in javascript. <script type="text/javascript"> function parseLine(x){ var obj = JSON.parse(x); document.write(obj.timestamp1); } I am getting this error: SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data in the console browser. I have found many stackoverflow questions with that error, but the suggestions do not fix my problem. If I use a dummy string, surrounded by single quotes: '{"test": "1234"}' it works fine. If I need to include anymore information I can.
<javascript><json><parsing><flask><jinja2>
2016-01-29 18:07:29
LQ_EDIT
35,091,412
Jenkins build monitor wall without manual login
<p>I'm trying to create a completely automatized Jenkins status screen for our office wall with a Raspberry Pi. I was able to configure the Pi to show a browser with a specific URL on the TVs as well as configuring the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Build+Monitor+Plugin">Build Monitor Plugin in Jenkins</a> with our build jobs.</p> <p>Our Jenkins uses matrix-based security, so I created separate <code>raspberry</code> user with the required privileges. (After logging in manually the wall plugin is shown properly.)</p> <p>I can see a valid HTTP answer with the following command:</p> <pre><code>curl "http://raspberry:0b45...06@localhost:8080/view/wall1/" </code></pre> <p><code>0b45...06</code> is the API Token of the <code>raspberry</code> Jenkins user. (From <code>http://localhost:8080/user/raspberry/configure</code>)</p> <p>Unfortunately this URL scheme does not work in graphical browsers. I've also tried the token parameter without success:</p> <pre><code>$ curl "http://localhost:8080/view/wall1/?token=0b45...06" &lt;html&gt;&lt;head&gt;...&lt;/head&gt;&lt;body ...&gt; Authentication required &lt;!-- You are authenticated as: anonymous Groups that you are in: Permission you need to have (but didn't): hudson.model.Hudson.Read ... which is implied by: hudson.security.Permission.GenericRead ... which is implied by: hudson.model.Hudson.Administer --&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>How can I get an URL which works without login in browsers (like Chromium or Midori) and shows my Jenkins view?</p> <p>I don't want any manual step, including logging in (though VNC, for example) since it does not scale too well to multiple offices/Pis.</p>
<jenkins>
2016-01-29 18:21:21
HQ
35,091,757
Parse Javascript fetch in PHP
<p>I'm calling a post request through Javascript and here's how it looks,</p> <pre><code>function syncDeviceId(deviceID, mod){ var request = new Request('url', { method: 'POST', body: JSON.stringify({ uuid: unique_id, }), mode: 'cors' }) fetch(request).then(function(data) { return }) </code></pre> <p>And I'm trying to retreive the values like this,</p> <pre><code>&lt;?php $post['uuid'] = $_POST['uuid']; ?&gt; </code></pre> <p>This is returned as empty, how can I retrieve the values from the fetch post request in PHP. Thanks</p>
<javascript><php>
2016-01-29 18:43:02
HQ
35,091,783
Can't delete Parenthesis in IntelliJ/Cursive
<p>I'm using IntelliJ/Cursive to write Clojure. I found out that the only way to erase parenthesis is to totally erase the content inside them, and only then, the parenthesis can be deleted. For example, let's say that I have the following code: </p> <pre><code>(list) </code></pre> <p>and I want to delete only the opening parenthesis. Once I hit backspace on the opening parenthesis, the IDE ignores this act. Only when I erase the word "list", the parenthesis can be deleted. </p> <p>Does anyone have any idea how to solve this? </p>
<intellij-idea><clojure><cursive>
2016-01-29 18:44:22
HQ
35,091,997
Difference between deep copy and shallow copy
<p>I am not able to get understand what is difference between deep copy and shallow copy. Please make me understand with the simple example. Thanks</p>
<ios><objective-c>
2016-01-29 18:56:05
LQ_CLOSE
35,092,183
Webpack plugin: how can I modify and re-parse a module after compilation?
<p>I'm working on a webpack plugin and can't figure out how to modify a module during the build. What I'm trying to do:</p> <ul> <li>Collect data via a custom loader (fine)</li> <li>After all modules have been loaded, collect data gathered by my loader (fine)</li> <li>Insert code I generate into an existing module in the build (doing this as described below, not sure if it's the best way)</li> <li>'update' that module so that the code I added gets parsed and has its 'require's turned into webpack require calls (can't figure out how to do this correctly)</li> </ul> <p>Currently I'm hooking into 'this-compilation' on the compiler, then 'additional-chunk-assets' on the compilation. Grabbing the first chunk (the only one, currently, as I'm still in development), iterating through the modules in that chunk to find the one I want to modify. Then:</p> <ul> <li>Appending my generated source to the module's _cachedSource.source._source._value (I also tried appending to the module's ._source._value)</li> <li>setting the ._cachedSource.hash to an empty string (as this seems to be necessary for the next step to work)</li> <li>I pass the module to .rebuildModule() </li> </ul> <p>It looks like rebuildModule should re-parse the source, re-establish dependencies, etc. etc., but it's not parsing my require statements and changing them to webpack requires. The built file includes my modified source but the require('...') statements are unmodified.</p> <p>How can I make the module I modified 'update' so that webpack will treat my added source the same as the originally parsed source? Is there something I need to do in addition to rebuildModule()? Am I doing this work too late in the build process? Or am I going about it the wrong way?</p>
<webpack>
2016-01-29 19:07:58
HQ
35,093,491
AWS s3api json formatting error: Error parsing parameter 'cli-input-json': Invalid JSON: Expecting value: line 1 column 1 (char 0)
<p>Not sure what I'm getting wrong with my json format. Just trying to test out aws cli and run <code>aws s3api list-objects --cli-input-json &lt;json_file&gt;.json --profile &lt;profile_name&gt;</code> where <code>&lt;my_json&gt;</code> is below but getting:</p> <pre><code>Error parsing parameter 'cli-input-json': Invalid JSON: Expecting value: line 1 column 1 (char 0) JSON received: &lt;my_json.json&gt; {"Bucket": "&lt;bucket_name&gt;","Delimiter": "","EncodingType": "","Marker": "","MaxKeys": 0,"Prefix": "&lt;prefix_name&gt;"} </code></pre>
<amazon-web-services><amazon-s3>
2016-01-29 20:30:12
HQ
35,093,576
how can I avoid storing a command in ipython history?
<p>In bash I can prevent a command from being saved to bash history by putting a space in front of it. I cannot use this method in ipython. How would I do the equivalent in ipython?</p>
<python><ipython><history>
2016-01-29 20:35:43
HQ
35,094,457
Can anyone please help on this?I dont know why i am getting SQL Error: ORA-00001: unique constraint (RO_MARGE_TABLE_PK) violated
insert into RO_MARGE_TABLE ( PROMOTION_OFFER_ID, PROMOTION_CODE, SYS_CREATION_DATE, SYS_UPDATE_DATE, OPERATOR_ID, APPLICATION_ID, DL_SERVICE_CODE, DL_UPDATE_STAMP, SPEED, PREMIUM_TIERS, PACKAGE_TYPE, EFFECTIVE_DATE, EXPIRATION_DATE, PROMOTION_AMOUNT) select PROMOTION_OFFER_ID, DECODE(PROMOTION_CODE,NULL,NULL,NVL(RTRIM(PROMOTION_CODE),' ')), SYS_CREATION_DATE, SYS_UPDATE_DATE, OPERATOR_ID, DECODE(APPLICATION_ID,NULL,NULL,NVL(RTRIM(APPLICATION_ID),' ')), DECODE(DL_SERVICE_CODE,NULL,NULL,NVL(RTRIM(DL_SERVICE_CODE),' ')), DL_UPDATE_STAMP, DECODE(SPEED,NULL,NULL,NVL(RTRIM(SPEED),' ')), DECODE(PREMIUM_TIERS,NULL,NULL,NVL(RTRIM(PREMIUM_TIERS),' ')), DECODE(PACKAGE_TYPE,NULL,NULL,NVL(RTRIM(PACKAGE_TYPE),' ')), EFFECTIVE_DATE, EXPIRATION_DATE, PROMOTION_AMOUNT FROM SCHEMT098.MARGE_TABLE@DBLINK865;
<sql><oracle><sql-insert>
2016-01-29 21:35:24
LQ_EDIT
35,094,771
How To Split String Before After Comma?
<p>i have string like this:</p> <pre><code>&lt;?php $string = "52.74837280745686,-51.61665272782557"; ?&gt; </code></pre> <p>i want access to first string before comma and second string after comma like this:</p> <pre><code>&lt;?php string1 = "52.74837280745686"; $string2 = "-51.61665272782557" ; ?&gt; </code></pre> <p>thank you !</p>
<php><string><split>
2016-01-29 21:57:23
LQ_CLOSE
35,095,021
Core data complicated array
<p>I have this kind of array:</p> <pre><code>var vakken: [(String,[Int],[Int])] </code></pre> <p>but I don't know how i could put this in core data and pull it back?</p> <p>Has anyone advice how to make this or even some code?</p> <p>Thanks in advance</p>
<swift><core-data>
2016-01-29 22:15:17
LQ_CLOSE
35,095,478
i need to use the value of i outside of the loop
for(int i = 0 ; i < Tri.length; i++) for(int v = 1; v < Tri.length;v++) { boolean plz= Tri[i].compareColors(Tri[v]); if(v==i) continue; if(plz == true ) System.out.println("Trinagle " + i + " is equal to Triangle "+ v+ " "+ plz); } i need to use the value of i outside of the loop.Currently the print statement is being looped 21 X more than what i need. Is there any way i can access 'i' with having all my code in a for loop
<java><for-loop>
2016-01-29 22:49:11
LQ_EDIT
35,095,950
What are the benefits of cfn-init over userdata?
<p>My CloudFormation template has gotten pretty long. One reason is because my <code>AWS::CloudFormation::Init</code> section has gotten pretty huge. This is a very small sample of what I have:</p> <pre><code>"ConfigDisk": { "commands": { "01formatFS": { "command": "/sbin/mkfs.ext4 /dev/xvdf" }, "02mountFS": { "command": "/bin/mount /dev/xvdf /var/lib/jenkins" }, "03changePerms": { "command": "/bin/chown jenkins:jenkins /var/lib/jenkins" }, "04updateFStab": { "command": "/bin/echo /dev/xvdf /var/lib/jenkins ext4 defaults 1 1 &gt;&gt; /etc/fstab" } } }, </code></pre> <p>Wouldn't it be better to just put this into the userdata section as a bunch of commands?</p> <pre><code>/sbin/mkfs.ext4 /dev/xvdf /bin/mount /dev/xvdf /var/lib/jenkins /bin/chown jenkins:jenkins /var/lib/jenkins /bin/echo /dev/xvdf /var/lib/jenkins ext4 defaults 1 1 &gt;&gt; /etc/fstab </code></pre> <p>What are the benefits of leaving this in the Init over userdata?</p>
<amazon-web-services><aws-sdk><amazon-cloudformation>
2016-01-29 23:28:28
HQ
35,096,746
Substituting parameters in log message and add a Throwable in Log4j 2
<p>I am trying to log an exception, and would like to include another variable's value in the log message. Is there a Logger API that does this? </p> <pre><code>logger.error("Logging in user {} with birthday {}", user.getName(), user.getBirthdayCalendar(), exception); </code></pre>
<java><exception><logging><log4j>
2016-01-30 00:59:51
HQ
35,097,113
Get base url in AngularJS
<p>I want to get the base path of my Angular app.</p> <p>Right now I'm doing this: <code>$scope.baseUrl = '$location.host()</code></p> <p>But I only get this: <code>/localhost</code>. My current baseURL is <code>http://localhost:9000/</code>.</p>
<javascript><angularjs>
2016-01-30 01:57:29
HQ
35,097,167
How to center Masonry Items?
<p>I have set up masonry to display items as such:</p> <pre><code>$('#list').masonry({ itemSelector: '.propitem', columnWidth: 230 }); </code></pre> <p>This works, but all items (<code>.propitem</code>) float to the left. For example if my container <code>#list</code> is 600px wide there will be two columns to the left but a gap to the right of them where the remaining 140px is. I would like to center the 2 columns with a 70px 'margin' on either side.</p> <p>I have tried using css to centre these, but had no luck, eg:</p> <pre><code>#list { text-align: center; } </code></pre> <p>Would anyone know the correct way of achieving this?</p>
<jquery><css><jquery-masonry>
2016-01-30 02:05:11
HQ
35,097,193
Can I bundle the Visual Studio 2015 C++ Redistributable DLL's with my application?
<p>I've built a C++ application using Microsoft Visual Studio 2015 Community Edition. I'm using Advanced Installer to make sure that the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=48145">Visual C++ Redistributable for Visual Studio 2015</a> is a prerequisite.</p> <p>However, the redistributable's installer isn't perfect. Some of my users have reported that the redistributable installer hangs, or it fails to install when it says it does, and then users get the "This program can't start because MSVCP140.dll is missing from your computer" error.</p> <p>According to Microsoft, <a href="https://msdn.microsoft.com/en-us/library/ms235299.aspx">I can now package the redistributable DLLs along with my application, though they don't recommend it:</a></p> <blockquote> <p>To deploy redistributable Visual C++ files, you can use the Visual C++ Redistributable Packages (VCRedist_x86.exe, VCRedist_x64.exe, or VCRedist_arm.exe) that are included in Visual Studio. ... It's also possible to directly install redistributable Visual C++ DLLs in the application local folder, which is the folder that contains your executable application file. For servicing reasons, we do not recommend that you use this installation location.</p> </blockquote> <p>There are 4 files in <code>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x64\Microsoft.VC140.CRT</code>. Does that mean I just need to copy them to my application's directory during the install process?</p> <ul> <li>MyApp.exe</li> <li>concrt140.dll</li> <li>msvcp140.dll</li> <li>vccorlib140.dll</li> <li>vcruntime140.dll</li> </ul> <p>Is this OK to do? Do I need to show a license? Why aren't more people doing this instead of requiring yet another preinstall of the redistributable?</p>
<c++><windows><visual-studio><dll><visual-studio-2015>
2016-01-30 02:10:00
HQ
35,097,220
How to have a transparent gradient over an Image in React Native iOS?
<p>I have been dealing with the a gradient rectangle over an Image that has a black and a transparent sides, I have been looking about a gradient object in react native and I didn't found, but there is a react-native module that does this, but the problem is that it does work in android the transparency, but in iOS, it doesn't work, it shows white in place of the transparent side</p> <p><a href="https://i.stack.imgur.com/mBE9O.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/mBE9O.jpg" alt="transparent gradient"></a> </p> <p>and than I was looking about a native iOS solution, I did but it's a bit complex, and I can't implement in react native this the snippet </p> <pre><code>CAGradientLayer *gradientMask = [CAGradientLayer layer]; gradientMask.frame = self.imageView.bounds; gradientMask.colors = @[(id)[UIColor whiteColor].CGColor, (id)[UIColor clearColor].CGColor]; self.imageView.layer.mask = gradientMask; &lt;-- // looking for a way to achieve this in react native </code></pre> <p>this is my react native code</p> <pre><code> &lt;Image ref={r =&gt; this.image = r} style={styles.container} source={require('../assets/default_profile_picture.jpg')}&gt; &lt;LinearGradient ref={r =&gt; this.gradiant = r} locations={[0, 1.0]} colors={['rgba(0,0,0,0.00)', 'rgba(0,0,0,0.80)']} style={styles.linearGradient}&gt; &lt;/LinearGradient&gt; &lt;/Image&gt; </code></pre> <p>I don't know how to pass <code>LinearGradient</code> to <code>Image</code> as a mask</p>
<android><ios><react-native>
2016-01-30 02:14:52
HQ
35,097,221
Keep TextInputLayout always focused or keep label always expanded
<p>I was wondering if it's possible to always keep the label expanded regardless of whether or not there is text in the <code>EditText</code>. I looked around in the source and it is a using a <code>ValueAnimator</code> and a <code>counter</code> inside a <code>TextWatcher</code> to animate or not animate changes. Maybe I can set a custom <code>TextWatcher</code> with a custom <code>ValueAnimator</code> on the <code>EditText</code> inside the <code>TextInputLayout</code>? </p>
<android><android-textinputlayout>
2016-01-30 02:14:57
HQ
35,097,433
How to speed up c code?
<p>I am wondering if there is any way to speed up this simple .c program I made alongside a friend. Is there any things I could change to clean it up as well? And maybe add a pop up to say how many images it has processed. Thanks!</p> <pre><code>#include "stdio.h" #include "string.h" #include "malloc.h" #define DDS_MAGIC "DDS " int ipos[10240]; int iposind=0; int tfilelen; char* TransBuf=NULL; int main(int argc, char** argv){ int i,r; FILE* sFile=NULL; FILE* tFile=NULL; char ifn[256]; char ofn[256]; char qc; if (argc !=2){ printf("usage: %s filename\n",argv[0]); return 0; } strcpy(ifn,argv[1]); sFile=fopen(argv[1],"rb"); fseek(sFile,0,SEEK_END); tfilelen=ftell(sFile); fseek(sFile,0,SEEK_SET); TransBuf=(char*)malloc(tfilelen); for(i=0,r=0;r&lt;tfilelen;){ /* read the file in */ i=fread(TransBuf+r,1,tfilelen-r,sFile); if(i&gt;0)r+=i; } qc=DDS_MAGIC[0]; for(i=0;i&lt;tfilelen;i++){ if(TransBuf[i]!=qc)continue; if(strncmp(DDS_MAGIC,TransBuf+i,4)==0){ ipos[iposind]=i; iposind++; } } ipos[iposind]=tfilelen; for(i=0;i&lt;iposind;i++){ char* s; int l; int j; s=TransBuf+ipos[i]; l=ipos[i+1]-ipos[i]; if(l&lt;4)continue; /* don't write out dds files with no data*/ /* write each dds segment to it's own file */ sprintf(ofn,"%s_%d.dds",ifn,i); tFile=fopen(ofn,"w+b"); for(j=0,r=0;r&lt;l;){ j=fwrite(s+j,1,l-r,tFile); if(j&gt;0)r+=j; } fclose(tFile); system("pause"); } printf("extracted %d files\n",i); return 0; } </code></pre>
<c>
2016-01-30 02:53:36
LQ_CLOSE
35,097,577
pytest run only the changed file?
<p>I'm fairly new to Python, trying to learn the toolsets.</p> <p>I've figured out how to get <code>py.test -f</code> to watch my tests as I code. One thing I haven't been able to figure out is if there's a way to do a smarter watcher, that works like Ruby's Guard library.</p> <p>Using guard + minitest the behavior I get is if I save a file like <code>my_class.rb</code> then <code>my_class_test.rb</code> is executed, and if I hit <code>enter</code> in the cli it runs all tests.</p> <p>With pytest so far I haven't been able to figure out a way to only run the test file corresponding to the last touched file, thus avoiding the wait for the entire test suite to run until I've got the current file passing.</p> <p>How would you pythonistas go about that?</p> <p>Thanks!</p>
<python><pytest>
2016-01-30 03:18:51
HQ
35,097,731
explain about this code jquery
<p>I found this code to get value from scan barcode</p> <pre><code>$(document).ready(function() { $(document).focus(); var coba=[]; $(document).on('keypress',function(e){ coba.push(String.fromCharCode(e.which)); if (coba[coba.length-1]=="\r") { console.log(coba.join('')); simpan(coba.join('')); coba = []; }; }); }); </code></pre> <p>anyone can explain about it?</p>
<javascript><jquery>
2016-01-30 03:43:57
LQ_CLOSE
35,097,837
Capture video data from screen in Python
<p>Is there a way with Python (maybe with OpenCV or PIL) to continuously grab frames of all or a portion of the screen, at least at 15 fps or more? I've seen it done in other languages, so in theory it should be possible. </p> <p>I do not need to save the image data to a file. I actually just want it to output an array containing the raw RGB data (like in a numpy array or something) since I'm going to just take it and send it to a large LED display (probably after re-sizing it).</p>
<python><opencv><numpy><screenshot>
2016-01-30 04:03:56
HQ
35,098,864
Resize issue in Windows form application in 2560x1600 resolution display
<p>I have a form application working fine on various displays with varying screen resolution but in a machine with 2560x1600 resolution it shrinks to a very small size.</p> <p>It works fine all smaller resolution and i am not able to find a reason behind it. I have used anchor, docking, autoscalemode and various other properties still it fails only in this above mentioned screen resolution</p>
<c#><.net><windows><winforms><visual-studio>
2016-01-30 06:36:24
LQ_CLOSE
35,099,130
Change spacing of dashes in dashed line in matplotlib
<p>In Python, using matplotlib, is there a way to change the distance of the dashes for different linestyles, for example, using the following command:</p> <pre><code>plt.plot(x,y,linestyle='--') </code></pre>
<python><matplotlib><plot><line><subplot>
2016-01-30 07:12:24
HQ
35,100,107
Make Youtube 360 degree Videos work on mobile
<p>I recently embedded the youtube 360 degree videos in my side. But I found that the 360 videos don't work on mobile browsers in devices like Android or iOS. Is there anyway to make work the 360 videos on mobile or Is it possible that when someone clicks on video link, then youtube app installed in mobile opens up ? Because I found that 360 videos works really well in native youtube app.</p> <p>Thanks</p>
<javascript><php><html><video><youtube>
2016-01-30 09:29:11
HQ
35,100,759
serviceworkers focus tab: clients is empty on notificationclick
<p>I have a common serviceworker escenario, where I want catch a notification click and focus the tab where the notification has come from. However, clients variable is always empty, its lenght is 0</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>console.log("sw startup"); self.addEventListener('install', function (event) { console.log("SW installed"); }); self.addEventListener('activate', function (event) { console.log("SW activated"); }); self.addEventListener("notificationclick", function (e) { // Android doesn't automatically close notifications on click console.log(e); e.notification.close(); // Focus tab if open e.waitUntil(clients.matchAll({ type: 'window' }).then(function (clientList) { console.log("clients:" + clientList.length); for (var i = 0; i &lt; clientList.length; ++i) { var client = clientList[i]; if (client.url === '/' &amp;&amp; 'focus' in client) { return client.focus(); } } if (clients.openWindow) { return clients.openWindow('/'); } })); });</code></pre> </div> </div> </p> <p>And the registration is this one:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> this.doNotify = function (notification) { if ('serviceWorker' in navigator) { navigator.serviceWorker.register('sw.js').then(function (reg) { requestCreateNotification(notification, reg); }, function (err) { console.log('sw reg error:' + err); }); } ... }</code></pre> </div> </div> </p> <p>chrome://serviceworker-internals/ output shows that registration and installation are fine. However, when a notification is pushed, clientList is empty. I have tried removing the filter type:'window' but the result is still the same. As clients are empty, a new window is always opened. What am I doing wrong?</p>
<google-chrome><service-worker>
2016-01-30 10:39:43
HQ
35,100,966
c ++ code test if a inn value is in one of the hundred years (Ex: 1900, 1800 , 200)
<p>Does anyone know of a good code I can use for test if a value is one of the hundred years? </p> <p>Example: 1200 or 2000 or 2100 or 300.</p> <p>A easy one, so I dont have to write inn every year like this. </p> <p>The reason is that i want to do something else with this numbers in a if statement. </p> <p>Thanks for answers.</p>
<c++>
2016-01-30 11:01:14
LQ_CLOSE
35,101,099
How do I safely remove items from an array in a for loop?
<p>Full disclose, this is for a homework question:</p> <blockquote> <p>It should have a private property of type [Circle]. An array of circles. The method should remove any circles that have a radius larger than the minimum requirement, and smaller than the max requirement.</p> </blockquote> <p>It seems obvious that I should use <code>removeAtIndex()</code> to remove array items that don't meet a condition determined in the loop. However, many have pointed out before the perils of removing items in a loop because of what I guess is a "iterator/index mismatch".</p> <p>Ultimately I ended up creating an empty array and using <code>.append()</code> to push the values that meet the "good" condition to a <code>filteredCircles</code> array, but I can't help but to feel that this this doesn't meet the criteria for the assignment.</p> <p>Is there a solution that actually removes the items from the array in a loop?</p>
<arrays><swift><for-loop>
2016-01-30 11:15:25
HQ
35,101,206
Android Studio: Re-download dependencies and sync project
<p>I downloaded an open source game "<a href="https://github.com/tvbarthel/ChaseWhisplyProject" rel="noreferrer">ChaseWhisplyProject</a>" source code from Github.</p> <p>I imported the project in my Android Studio (Version 1.5.1). </p> <p>It shows following error message:</p> <p>Error:Failed to open zip file.<br> Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)<br> Re-download dependencies and sync project (requires network)<br> Re-download dependencies and sync project (requires network)</p> <p>I changed all the dependency versions to latest one bu still it is showing the same message.</p> <p>It has two modules under the main project 1) BaseGameUtils &amp; 2)ChaseWhisply. The above modules are not shown in bold letters (I think it should be shown in bold letters like module "app").</p> <p>Following are the gradle files.</p> <p>1) Root Gradle:</p> <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules. allprojects { repositories { jcenter() } } </code></pre> <p>2) BaseGameUtils Module Gradle</p> <pre><code>apply plugin: 'com.android.library' android { compileSdkVersion 23 buildToolsVersion "23.0.1" } buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' } } dependencies { compile 'com.android.support:support-v4:23.1.1' compile 'com.google.android.gms:play-services:8.4.0' } </code></pre> <p>3) ChaseWhisply Module Gradle:</p> <pre><code>buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' } } apply plugin: 'com.android.application' dependencies { compile 'com.android.support:gridlayout-v7:23.1.1' compile 'com.android.support:support-v4:23.1.1' compile 'com.android.support:cardview-v7:23.1.1' compile 'com.nineoldandroids:library:2.4.0' compile project(':BaseGameUtils') } android { compileSdkVersion 23 buildToolsVersion "23.0.1" lintOptions { // TODO fix and remove ! disable 'MissingTranslation', 'DuplicateIds', 'ExtraTranslation' } defaultConfig { minSdkVersion 14 targetSdkVersion 23 versionCode 22 versionName "0.3.6" } } </code></pre> <p>4) Settings.gradle</p> <pre><code>include ':ChaseWhisply', ':BaseGameUtils' </code></pre> <p>What is wrong over here? Please help.</p>
<android><android-studio><android-gradle-plugin><build.gradle>
2016-01-30 11:28:10
HQ
35,101,850
Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed. (Django 1.8 and OSX ElCapitan)
<p>I'm trying to internationalize a Django app by following the wonderful Django documentation. The problem is when I try to run command to create language files: </p> <pre><code>python manage.py makemessages -l fr </code></pre> <p>It outputs an error :</p> <pre><code>CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed. </code></pre> <p>My configuration : </p> <ul> <li>OS : <strong>OSX El Capitan v10.11.3</strong> </li> <li>Python : <strong>v3.5</strong> </li> <li>Django : <strong>v1.8</strong></li> </ul>
<python><django><macos><gettext><osx-elcapitan>
2016-01-30 12:34:48
HQ
35,102,269
library in C11 or C99 good practice
<p>What is better idea: write library which will be used by others in C11 or C99? Is it good justification that many people rather use C99 in theis project than C11 or it's not true? And what is better for microcontrollers? I am not professional and I want to have good excuse to not use generic C11 :P Thank you for your help. I hope it's not 'silly' question.</p>
<c><c99><c11>
2016-01-30 13:19:06
LQ_CLOSE
35,102,415
Why cant we use .append with string object in java?
import java.lang.StringBuffer.*; import java.io.*; class chk { public static void main() { System.out.print('\u000c'); String k="catering"; * String l=k.append(5); (shows error here) System.out.println(l); } } i cant understand why it is showing an error?? is it that we cant access methods from other class(ex.Stringbuffer class) from string class?? plz help!!
<java>
2016-01-30 13:34:05
LQ_EDIT
35,102,559
What happens if I forget to close a scanset?
<p>Suppose I forgot to close the right square bracket <code>]</code> of a scanset. What will happen then? Does it invoke Undefined Behavior?</p> <p>Example:</p> <pre><code>char str[] = "Hello! One Two Three"; char s1[50] = {0}, s2[50] = {0}; sscanf(str, "%s %[^h", s1, s2); /* UB? */ printf("s1='%s' s2='%s'\n", s1, s2); </code></pre> <p>I get a warning from GCC when compiling:</p> <pre><code>source_file.c: In function β€˜main’: source_file.c:11:5: warning: no closing β€˜]’ for β€˜%[’ format [-Wformat=] sscanf(str, "%s %[^h", s1, s2); /* UB? */ </code></pre> <p>and the output as</p> <pre><code>s1='Hello!' s2='' </code></pre> <p>I've also noticed that the <code>sscanf</code> returns 1. But what exactly is going on here?</p> <p>I've checked the C11 standard, but found no information related to this.</p>
<c><scanf><format-specifiers>
2016-01-30 13:49:04
HQ
35,102,641
I can't post data to database with ajax in laravel5.2
I am trying to send / post data to database with ajax in laravel 5.2 but I am not able to post data to database with ajax. what is the problem I can not figure out this. please help me ASAP [1]: http://i.stack.imgur.com/heHSC.jpg [2]: http://i.stack.imgur.com/NuAGa.jpg [3]: http://i.stack.imgur.com/R7isz.jpg [4]: http://i.stack.imgur.com/MqccC.jpg
<ajax><database><post><laravel-5.2>
2016-01-30 13:57:37
LQ_EDIT
35,102,642
what is the use of plus sign in a given code below?
<p>I am a beginner in programming and have been seeing plus signs like +sum, +result, but not sure what is the use of it. could anyone put some light on this issue for me.</p> <pre><code> SimpleIO.println("Enter gear: "); gear = SimpleIO.readInteger(); SimpleIO.println("Enter power: "); power = SimpleIO.readInteger(); System.out.println("speed= " +power*gear);` </code></pre> <p>thanks in advance :)</p>
<java>
2016-01-30 13:57:43
LQ_CLOSE
35,103,931
C passing pointet to pointer in function
I am very confused... I am reading about pointer to pointer and now I think I know less than previous. Passing double pointer is needed to change value of that pointer but if we have let's say pointer to some structure and we want to change value of some its member we use passing simple pointer. Am I right or it's incorrect?
<c><pointers>
2016-01-30 16:09:09
LQ_EDIT
35,104,097
How to install psycopg2 with pg_config error?
<p>I've tried to install psycopg2 (PostgreSQL Database adapater) from <a href="http://initd.org/psycopg/" rel="noreferrer">this site</a>, but when I try to install after I cd into the package and write </p> <pre><code>python setup.py install </code></pre> <p>I get the following error: </p> <pre><code>Please add the directory containing pg_config to the PATH or specify the full executable path with the option: python setup.py build_ext --pg-config /path/to/pg_config build ... or with the pg_config option in 'setup.cfg'. </code></pre> <p>I've also tried 'sudo pip install psycopg2' and I got the same message. </p> <p>After reading through the <a href="http://initd.org/psycopg/docs/" rel="noreferrer">docs</a>, it asks to look at the setup.cfg file (which is below): </p> <pre><code>[build_ext] define= # PSYCOPG_DISPLAY_SIZE enable display size calculation (a little slower) # HAVE_PQFREEMEM should be defined on PostgreSQL &gt;= 7.4 # PSYCOPG_DEBUG can be added to enable verbose debug information # "pg_config" is required to locate PostgreSQL headers and libraries needed to # build psycopg2. If pg_config is not in the path or is installed under a # different name uncomment the following option and set it to the pg_config # full path. #pg_config= # Set to 1 to use Python datetime objects for default date/time representation. use_pydatetime=1 # If the build system does not find the mx.DateTime headers, try # uncommenting the following line and setting its value to the right path. #mx_include_dir= # For Windows only: # Set to 1 if the PostgreSQL library was built with OpenSSL. # Required to link in OpenSSL libraries and dependencies. have_ssl=0 # Statically link against the postgresql client library. #static_libpq=1 # Add here eventual extra libraries required to link the module. #libraries= </code></pre> <p>However, I'm not sure if I'm suppose to edit this file, since the documentation states the following: </p> <pre><code>then take a look at the setup.cfg file. Some of the options available in setup.cfg are also available as command line arguments of the build_ext sub-command. For instance you can specify an alternate pg_config version using: $ python setup.py build_ext --pg-config /path/to/pg_config build Use python setup.py build_ext --help to get a list of the options supported. </code></pre> <p>I've gotten the list of options supported but I'm not sure where to go from there</p>
<python><postgresql><psycopg2>
2016-01-30 16:25:02
HQ
35,104,679
Am i being hacked??
I run a web server at home that hosts a website for a company that i built for in Texas. I read server logs all day at work; so i figured I'd take a look at my own IIS logs on my home server to see how they differ.... well i noticed something that appeared in the log this morning that has me a little concerned. It is the only POST http requests other than the ones that are accepted when calling the Contact Us page. Take a look and let me know what you guys think... 2016-01-30 10:34:12 192.168.1.3 GET / - 80 - 180.76.15.146 Mozilla/5.0+ (compatible;+Baiduspider/2.0;++http://www.baidu.com/search/spider.html) - 304 0 0 252 2016-01-30 10:37:38 192.168.1.3 POST /1/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 116 2016-01-30 10:37:38 192.168.1.3 POST /admin/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 115 2016-01-30 10:37:38 192.168.1.3 POST /a/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 126 2016-01-30 10:37:38 192.168.1.3 POST /aspq/aspx.gif - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 128 2016-01-30 10:37:38 192.168.1.3 POST /dh/count.asp - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 129 2016-01-30 10:37:39 192.168.1.3 POST /do.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 119 2016-01-30 10:37:39 192.168.1.3 POST /extralog/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 120 2016-01-30 10:37:39 192.168.1.3 POST /folder/gate.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 102 2016-01-30 10:37:39 192.168.1.3 POST /forum/login.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 113 2016-01-30 10:37:39 192.168.1.3 POST /gate - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 152 2016-01-30 10:37:40 192.168.1.3 POST /jackposprivate12/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 116 2016-01-30 10:37:40 192.168.1.3 POST /jacpos/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 113 2016-01-30 10:37:40 192.168.1.3 POST /jk/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 119 2016-01-30 10:37:40 192.168.1.3 POST /kp/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 121 2016-01-30 10:37:40 192.168.1.3 POST /loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 105 2016-01-30 10:37:41 192.168.1.3 POST /panel2asdasd/up.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 122 2016-01-30 10:37:41 192.168.1.3 POST /Panelll/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 118 2016-01-30 10:37:41 192.168.1.3 POST /panel/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 118 2016-01-30 10:37:41 192.168.1.3 POST /Panel/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 118 2016-01-30 10:37:41 192.168.1.3 POST /post/echo - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 119 2016-01-30 10:37:42 192.168.1.3 POST /pub/adobe/reader/win/11.x/11.0.11/misc/AdbeRdrUpd11011_incr.msp - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 116 2016-01-30 10:37:42 192.168.1.3 POST /tj.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 127 2016-01-30 10:37:42 192.168.1.3 POST /vcxud91x83/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 118 2016-01-30 10:37:42 192.168.1.3 POST /whynot/sam.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 122 2016-01-30 10:37:42 192.168.1.3 POST /wordpress/post.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 122 2016-01-30 10:37:44 192.168.1.3 POST /wp-log/push.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 115 2016-01-30 10:37:44 192.168.1.3 POST /alinew/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 115 2016-01-30 10:37:44 192.168.1.3 POST /jackpos/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 114 2016-01-30 10:37:44 192.168.1.3 POST /jackposv1/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 116 2016-01-30 10:37:44 192.168.1.3 POST /jackposv2/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 104 2016-01-30 10:37:45 192.168.1.3 POST /alina/loading.php - 80 - 46.101.132.199 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+InfoPath.1+Eagle+++++++++++++Special+v12+->+1.1 - 404 0 2 122 2016-01-30 10:42:11 192.168.1.3 GET / - 80 - 180.76.15.24 Mozilla/5.0+(compatible;+Baiduspider/2.0;++http://www.baidu.com/search/spider.html) - 200 0 0 238 2016-01-30 10:43:20 192.168.1.3 GET / - 80 - 180.76.15.148 Mozilla/5.0+(compatible;+Baiduspider/2.0;++http://www.baidu.com/search/spider.html) - 200 0 0 241 Any advice is appreciated! Thanks, Grant
<iis><logging>
2016-01-30 17:20:43
LQ_EDIT
35,104,984
Insert 2D Array into MySQL Database
<p>So i have a multidimensional array as follows:</p> <pre><code>int[][] multiarray = { { 0, 1, 0, 1, 0 }, { 1, 0, 1, 0, 1 }, { 0, 1, 0, 1, 0 }, { 1, 0, 1, 0, 1 }, { 0, 1, 0, 1, 0 }, }; </code></pre> <p>I have a MySQL database with 5 columns:</p> <pre><code>|number1|number2|number3|number4|number5| </code></pre> <p>My question is, how would i insert this array into the mysql database?</p> <p>Thanks</p>
<java><mysql>
2016-01-30 17:47:09
LQ_CLOSE
35,104,992
Is it possible to see a log or history of previous iTerm2 sessions?
<p>Is there a log of recent terminal sessions at all? Or anyway I can see what was written to console before I last quit?</p>
<console><iterm2><iterm>
2016-01-30 17:48:09
HQ
35,105,100
Start app as root with pm2
<p>I have a daemon that must be run as root on startup.</p> <p>I use pm2 to start other apps but can not figure out if it can start an app as root. Can it be done?</p> <p>If not, what are my options?</p>
<node.js><root><pm2>
2016-01-30 17:57:33
HQ
35,105,194
My code isn't working,What have i done wrong?
This is a program designed to, ask a customer for their order,then display their order at the end. For some reason my code isn't working.I have displayed the plan of the code below. print("Welcome to Hungary house.") addDrink = input("Do you want a drink?\n").lower() drinkChoice = "None" dish = "" order = [] if addDrink == "yes": print ("What drink would you prefer?") print ("1: Fanta") print ("2: Coke") print ("3: Pepsi") print ("4: Sprite") drinkChoice = input("please select a drink from the options above\n") if drinkChoice == "1" or drinkChoice == "fanta": drinkChoice = "Fanta" order.insert(0,drinkChoice) if drinkChoice == "2" or drinkChoice == "coke": drinkChoice = "Coke" order.insert(0,drinkChoice) if drinkChoice == "3" or drinkChoice == "pepsi": drinkChoice = "Pepsi" order.insert(0,drinkChoice) if drinkChoice == "4" or drinkChoice == "sprite": drinkChoice = "Sprite" order.insert(0,drinkChoice) print ("you have chosen this drink: " + drinkChoice) foodGroup = input("Do you want Italian, Indian or Chinese food?\n") if foodGroup == "italian" or foodGroup == "Italian": dish = input("Do you want Pasta or Pizza?\n") if dish == "pizza": dish = input("Do you want Grilled chicken or Seasonal vegetables?\n") if dish == "seasonal vegetables": order.insert(1,dish) if dish == "grilled chicken": order.insert(1,dish) if dish == "pasta": dish = input("Do you want Vegetarian Toppings or meat toppings?\n") if dish == "Vegetarian Toppings": order.insert(1,dish) if dish == "meat toppings": order.insert(1,dish) if foodGroup == "indian" or foodGroup == "Indian": dish = input("Do you want Curry or onion bhaji?\n") if dish == "Curry": dish = input("Do you want Rice or Naan?\n") if dish == "Rice": order.insert(1,dish) if dish == "Naan": order.insert(1,dish) if dish == "onion bhaji": dish = input("Do you want Chilli or Peppers?\n") if dish == "Chilli": order.insert(1,dish) if dish == "Peppers": order.insert(1,dish) if foodGroup == "chinese" or foodGroup == "Chinese": dish = input("Do you want Chicken Wings or onion Noodles?\n") if dish == "Chicken Wings": dish = input("Do you want Chips or Red peppers?\n") if dish == "Chips": order.insert(1,dish) if dish == "Red peppers": order.insert(1,dish) if dish == "Noodles": dish = input("Do you want Meatballs or Chicken?\n") if dish == "Meatballs": order.insert(1,dish) if dish == "Chicken": order.insert(1,dish) print ("You have ordered",order"enjoy your meal") This is how the code is supposed to work: Welcome to Hungary house. Do you want a drink? If no, Move on to the next question If yes, ask what drink the customer wants. (Coke, Fanta, lemonade are the options) If coke is chosen, set coke as drink If Fanta is chosen, set Fanta as drink If Lemonade is chosen, set Lemonade as drink Do you want Italian, Indian or Chinese food? If Italian food is entered ask the following questions. Do you want Pasta or chicken-cacciatore? If chicken cacciatore is chosen ask, Do you want with your chicken-cacciatore? Grilled free-range chicken Or Seasonal vegetables If Grilled free-range chicken is chosen add that to the chicken-cacciatore. If Seasonal vegetables is chosen add that to the chicken-cacciatore. If pasta is chosen ask the following questions. Do you want Vegetarian Toppings? If user enters yes, add vegetarian topping add it on the pasta If user enters no, move on to the next question Do you want Meaty Toppings? If yes, add Meaty Toppings on the pasta If no, add Meaty Toppings on the pasta If Indian food is entered ask the following questions Do you want Curry or onion bhaji? If curry is selected ask the following questions. What toppings you want on top of your Curry? Rice Or Naan If user enters rice, add rice on to the curry. If user enters Naan, add naan on to the curry. If user enters onion ask the following questions. What toppings do you want on top of your onion bhaji? Chilli source Or Peppers If user enters Chilli source, add chilli source on to the onion bhaji. If user enters Peppers, add Peppers on to the onion bhaji. If Chinese food is entered ask the following questions. Do you want Chicken wings or Noodles? If Chicken wings is chosen ask, Do you want with your Chicken wings? Chips Or Red Peppers If Chips is chosen add that to the Chips to the Chicken wings If Red Peppers are chosen add that to the Chicken wings. If the user enters Noodles ask the following questions. Choose the toppings you want with Noodles. Meatballs Or Chicken If user enters Meatballs, add Meatballs to the Noodles. If user enters Chicken, add Chicken to the Noodles. After this, Display the order the user wanted. Tell the customer that their order will come within the next 10-50 minutes. If they wish to cancel tell them to contact this number β€˜077 3475 609334’.
<python><list><if-statement><input><syntax-error>
2016-01-30 18:06:00
LQ_EDIT
35,105,228
Ruby find and return objects in an array based on an attribute
<p>How can you iterate through an array of objects and return the entire object if a certain attribute is correct? </p> <p>I have the following in my rails app</p> <pre><code>array_of_objects.each { |favor| favor.completed == false } array_of_objects.each { |favor| favor.completed } </code></pre> <p>but for some reason these two return the same result! I have tried to replace <code>each</code> with <code>collect</code>, <code>map</code>, <code>keep_if</code> as well as <code>!favor.completed</code> instead of <code>favor.completed == false</code> and none of them worked! </p> <p>Any help is highly appreciated!</p>
<ruby-on-rails><arrays><ruby>
2016-01-30 18:09:13
HQ
35,105,449
Creating CGI page, with div tags
I plan to add load a java applet from this page, and can add the code and anything else necessary to the page later. But for some reason I cannot get this page to load, I think it is the div tags. Can anyone explain to me why? !/usr/bin/perl require "/home/bob/public_html/cgi-bin/cookie.pl"; print "Content-type: text/html\n"; # Make sure the passed date is reasonable $theTime = $ENV{'QUERY_STRING'}; $theTime = time - $theTime; &Do_Cookies(); print "\n"; print "\n"; print "<html><head><title>Title</title><link rel=\"stylesheet\"type=\"text/css\" href=\"stylesheet.css\"></head><body>"; print "<div id=\"header\"></div>"; print "<div class=\"content\"><p>CENTER STUFF</p></div>"; print "<div id=\"copy\"><center>Copyright Notice HERE</center><br></div></center>"; print "<div id=\"navLeft\">LEFT STUFF</div>"; print "<div id=\"navRight\">RIGHT STUFF</div></body></html>"; exit 0;
<html><perl><cgi>
2016-01-30 18:30:48
LQ_EDIT
35,105,545
How to mock a SharedPreferences using Mockito
<p>I have just read about Unit Instrumented Testing in Android and I wonder how I can mock a SharedPreferences without any SharedPreferencesHelper class on it like <a href="https://github.com/googlesamples/android-testing/blob/master/unit/BasicSample/app/src/test/java/com/example/android/testing/unittesting/BasicSample/SharedPreferencesHelperTest.java" rel="noreferrer">here</a></p> <p>My code is:</p> <pre><code>public class Auth { private static SharedPreferences loggedUserData = null; public static String getValidToken(Context context) { initLoggedUserPreferences(context); String token = loggedUserData.getString(Constants.USER_TOKEN,null); return token; } public static String getLoggedUser(Context context) { initLoggedUserPreferences(context); String user = loggedUserData.getString(Constants.LOGGED_USERNAME,null); return user; } public static void setUserCredentials(Context context, String username, String token) { initLoggedUserPreferences(context); loggedUserData.edit().putString(Constants.LOGGED_USERNAME, username).commit(); loggedUserData.edit().putString(Constants.USER_TOKEN,token).commit(); } public static HashMap&lt;String, String&gt; setHeaders(String username, String password) { HashMap&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;(); String auth = username + ":" + password; String encoding = Base64.encodeToString(auth.getBytes(), Base64.DEFAULT); headers.put("Authorization", "Basic " + encoding); return headers; } public static void deleteToken(Context context) { initLoggedUserPreferences(context); loggedUserData.edit().remove(Constants.LOGGED_USERNAME).commit(); loggedUserData.edit().remove(Constants.USER_TOKEN).commit(); } public static HashMap&lt;String, String&gt; setHeadersWithToken(String token) { HashMap&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;(); headers.put("Authorization","Token "+token); return headers; } private static SharedPreferences initLoggedUserPreferences(Context context) { if(loggedUserData == null) loggedUserData = context.getSharedPreferences(Constants.LOGGED_USER_PREFERENCES,0); return loggedUserData; }} </code></pre> <p>Is is possible to mock SharedPreferences without creating other class on it?</p>
<android><sharedpreferences><mockito>
2016-01-30 18:39:09
HQ
35,106,022
Adding buttons to toolbar programmatically in swift
<p>I'm having a hard time adding a button to the toolbar in swift, below you can see an image of the toolbar that I'm after, unfortunately even though I have it designed in my Storyboard file, it doesn't show up when setting the toolbar to be visible.</p> <p>The way that I have designed this is two items, the first being a <code>flexable space</code> element, and the second being an <code>add</code> element. It looks like this:</p> <p><a href="https://i.stack.imgur.com/tPFXA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tPFXA.png" alt="enter image description here"></a></p> <p>Here's the code that I've used to attempt to replicate this in code:</p> <pre><code>self.navigationController?.toolbarHidden = false self.navigationController?.toolbarItems = [UIBarButtonItem]() self.navigationController?.toolbarItems?.append( UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: self, action: nil) ) self.navigationController?.toolbarItems?.append( UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "onClickedToolbeltButton:") ) </code></pre> <p>As you can see I'm setting the toolbar to be visible, initializing (and clearing) the toolbarItems array of UIBarButtonItem, and then adding two UIBarButtonItem's to the array, in the proper order.</p> <p>However, the toolbelt remains empty, why is this? </p>
<ios><swift>
2016-01-30 19:21:57
HQ
35,106,118
What is the best way to call into Swift from C?
<p>Calling into C from Swift is pretty simple, however I'm looking into making a bi-directional wrapper in C, so my C has to call Swift functions.</p> <p>Right now, I can do this by declaring function pointers in C, and having my C functions call them after the Swift side has set them up to call code in Swift.</p> <p>My C header file:</p> <pre><code>typedef void (*callback_t)(void); void callBackIntoSwift( callback_t cb ); </code></pre> <p>My C implementation file:</p> <pre><code>#include "stuff.h" #include &lt;stdio.h&gt; void callBackIntoSwift( callback_t cb ) { printf( "Will call back into Swift\n" ); cb(); printf( "Did call back into Swift\n" ); } </code></pre> <p>After including my C header file in the bridging header, I can do the following on the Swift side:</p> <pre><code>let cb: callback_t = { someKindOfSwiftFunction() } callBackIntoSwift( cb ) </code></pre> <p>Or even:</p> <pre><code>callBackIntoSwift { someKindOfSwiftFunction() } </code></pre> <p>Is there a better way to do this, where function pointers and callbacks are not needed? I'd like to let the C-side call <code>someKindOfSwiftFunction</code> directly … but when I try to apply <code>@convention (c)</code> to function declarations I get the message that the attribute can only be applied to types, and not declarations.</p> <p>Any ideas or codebases in e.g. Github I can take a look at?</p>
<c><swift><callback><wrapper>
2016-01-30 19:29:56
HQ
35,106,467
How can I add broad image recognition to a mobile app?
<p>I'm working on an Android app (though eventually I'll want to do the same thing on iOS) and I'm looking to build an image recognition feature into it. The user would snap a picture, then this component of the app would need to figure out what that image is, whether it's a bowling ball, a salad, a book, you name it. It would also be helpful if it could figure out roughly how big the object in question is, though I imagine the camera focus values could help with that. The objects in question would not be moving.</p> <p>I've heard of neural networks being used, but I'm not sure how this could be implemented, especially since I want to be able to recognize a very wide range of objects. I highly doubt this sort of processing could happen natively on a phone either. What are some solutions to this problem?</p>
<android><image-processing><mobile><neural-network><image-recognition>
2016-01-30 20:02:02
LQ_CLOSE
35,106,811
Unit Testing Strategy, Ideal Code Coverage Baseline
<p>There's still not much information out there on the XCode7 and Swift 2.0 real-world experiences from a unit testing and code coverage perspective. </p> <p>While there're plenty of tutorials and basic how-to guides available, I wonder what is the experience and typical coverage stats on different iOS teams that actually tried to achieve a reasonable coverage for their released iOS/Swift apps. I specifically wonder about this:</p> <p>1) while code coverage percentage doesn't represent the overall quality of the code base, is this being used as an essential metric on your team? If not, what is the other measurable way to assess the quality of your code base?</p> <p>2) For a bit more robust app, what is your current code coverage percentage? (just fyi, we have hard time getting over 50% for our current code base)</p> <p>3) How do you test things like:</p> <ul> <li>App life-cycle, AppDelegate methods</li> <li>Any code related to push/local notifications, deep linking</li> <li>Defensive programming practices, various piece-of-mind (hardly reproducible) safe guards, exception handling etc.</li> <li>Animations, transitions, rendering of custom controls (CG) etc.</li> <li>Popups or Alerts that may include any additional logic</li> </ul> <p>I understand some of the above is more of a subject for actual UI tests, but it makes me wonder:</p> <ul> <li>Is there a reasonable way to get the above tested from the UTs perspective? Should we be even trying to satisfy an arbitrary minimal code coverage percentage with UTs for the whole code base or should we define that percentage off a reasonably achievable coverage given the app's code base?</li> <li>Is it reasonable to make the code base more inflexible in order to achieve higher coverage? (I'm not talking about a medical app where life would be in stake here)</li> <li>are there any good practices on testing all the things mentioned above, other than with UI tests?</li> </ul> <p>Looking forward to a fruitful discussion.</p>
<ios><xcode><swift><unit-testing><code-coverage>
2016-01-30 20:35:50
HQ
35,107,236
Syntax error when i try to insert into table
<h1>My Table</h1> <pre><code>CREATE TABLE IF NOT EXISTS `contas` ( `cod_conta` int(11) NOT NULL AUTO_INCREMENT, `cod_char` int(9) NOT NULL, `username` varchar(180) NOT NULL, `password` varchar(180) NOT NULL, `email` varchar(180) NOT NULL, `datacc` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `adm` int(1) NOT NULL DEFAULT '0', PRIMARY KEY (`cod_conta`) ) ENGINE=InnoDB DEFAULT CHARSET </code></pre> <h1>Insert SQL</h1> <pre><code>&gt; INSERT INTO 'contas'('cod_char','username','password','email') VALUES (2,'sdgsd','186672cc13','aaa') </code></pre> <h1>Error</h1> <blockquote> <p>1064 - Erreur de syntaxe près de ''contas'('cod_char','username','password','email') VALUES</p> </blockquote>
<mysql><syntax><sql-insert>
2016-01-30 21:18:55
LQ_CLOSE