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
38,555,877
valgrind showing invalid write of size 4 at fread and memory leaks
the load function below tries to load contents of file pointed by pointer "file" and save it's location at "content" and length in "length". The code works fine but with valgrind show error of "invalid write at fread" and several memory leaks while using realloc. Following is the code bool load(FILE* file, BYTE** content, size_t* length) { // providing default values to content and length *content = NULL; *length = 0; // initializing buffer to hold file data int size = 512; BYTE* buffer = NULL; buffer = (BYTE*) malloc(sizeof(BYTE) * size); if(buffer == NULL) return false; // bytes_read will store bytes read at a time int bytes_read = 0; // reading 512 bytes at a time and incrmenting writing location by 512 // reading stops if less than 512 bytes read while((bytes_read = fread(buffer + size - 512 , 1, 512, file)) == 512) { //increasing the size of size = size + 512; if(realloc(buffer,size) == NULL) { free(buffer); return false; } } // undoing final increment of 512 and increasing the size by bytes_read on last iteration size = size - 512 + bytes_read; // triming buffer to minimum size if(size > 0) { BYTE* minimal_buffer = malloc(size + 1); memcpy(minimal_buffer, buffer, size); minimal_buffer[size] = '\0'; free(buffer); *content = minimal_buffer; *length = size; return true; } return false; }
<c><memory-leaks><valgrind><fread>
2016-07-24 19:24:21
LQ_EDIT
38,556,304
pass mutliple variable value into url in python
I ahve below code to get data using url. I pass ticker value from text file and its successful and its;works (part-1) but as code per part-2, when I pass multiple value using multiple variable by raw_input(), its give **error "TypeError: not enough arguments for format string"** Part-1 ticker = line.strip(); url = "http://ichart.finance.yahoo.com/table.csv?s=%s.ns&a=08&b=08&c=2015&d=08&e=08&f=2016&g=d&ignore=.csv" % ticker r = requests.get(url) Part-2 ticker = line.strip(); url = "http://ichart.finance.yahoo.com/table.csv?s=%s.ns&a=%s&b=%s&c=%s&d=%s&e=%s&f=%s&g=d&ignore=.csv" %ticker %a %b %c %d %e %f r = requests.get(url)
<python>
2016-07-24 20:10:45
LQ_EDIT
38,556,520
PHP/cURL - Trying to get the text only from a specifc table row
Here is my code: <?php error_reporting(E_ALL); ini_set('display_errors', 1); $url = 'https://www.fibank.bg/bg/valutni-kursove/page/461'; $curl = curl_init(); curl_setopt($curl, CURLOPT_COOKIE, "ChosenSite=www; SportsDirect_AnonymousUserCurrency=GBP; language=en-GB"); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSLVERSION, 3); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($curl, CURLOPT_VERBOSE, true); $str = curl_exec($curl); curl_close($curl); libxml_use_internal_errors(true); $doc = new \DOMDocument(); $doc->loadHTML($str); $xpath = new \DOMXpath($doc); $value = $xpath->query('//td[em="GBP"]/parent::tr/td[last()]')->item(0)->nodeValue; print_r($value); With this code i am trying to parse the URL and get the line from the table which contains `GBP` and the get the text from the last `td`. However my code seems to be not working. Where is my mistake and how can i fix it? Thanks in advance!
<php><curl><domxpath>
2016-07-24 20:34:18
LQ_EDIT
38,556,979
PHP split string
<p>Hey how can I split string into 2 string, exemple:</p> <pre><code>$ipadd = "192.168.1.60"; </code></pre> <p>From here I want to print 2 result, one is: 192.168.1 secend is:60</p> <p>Always split by the last point and print 2 string.</p>
<php>
2016-07-24 21:27:35
LQ_CLOSE
38,557,133
Scopes in blank function c++
<p>Hy, my question is simple.. I have this function.</p> <pre><code>CPythonMessenger::CPythonMessenger(): m_poMessengerHandler(NULL) { } </code></pre> <p>What scope have and why is there since constructor is empty and also is not used <code>m_poMessengerHandler(NULL)</code> i want to say the function is not used anywhere is constructor.</p>
<c++>
2016-07-24 21:44:37
LQ_CLOSE
38,557,585
php header works fine with local host but does not work with real server
I am trying to header my page in real server but it does not work, I try it in xamp localhost it work fine :|? if(empty($_POST)===false){ include_once("db.php"); $username = $_POST['user']; $pwd = $_POST['pwd']; $rs = mysqli_query($con,"select *from admin_acc where username = '".$username."'"); $num_rows = mysqli_num_rows($rs); if($num_rows > 0){ while($rows = mysqli_fetch_assoc($rs)) { $db_username = $rows['username']; } if($username == $db_username && md5($pwd) == $db_password){ $_SESSION['username'] = $db_username; //Header to Home Page header('Location: customers.php'); }else{ $wrng_pwd = "Wrong Password!"; $msg_type = 1; } }else{ $user_nt = "User name not exsit!!"; $msg_type = 2; } } So can you please help me guys? because I was looking for the answer throw the internet but I have not find a good answer
<php><apache><header>
2016-07-24 22:45:42
LQ_EDIT
38,559,857
How to split the interger into an array?
I need to split the integer into an array. For example, The interger variable a contains 48. a = 48 I need to split the 48 into an array based on the count of 10. I need to get the array like, arr = [ 10, 20, 30, 40, 48] I know the split method and also I know how to split the string into an array based one the character available in the string. but i don't know how to use the split method splitting the integer into an array based on the count. Any one please explain me how to do this ? Thanks in advance!
<ruby-on-rails><arrays><ruby><split><integer>
2016-07-25 04:41:16
LQ_EDIT
38,560,115
php pdo sql constraint violation
Good morning, i have a big problem with this sql error when i,m trying to insert a event in my database with this pdo: <hr/> PDO: `$subsquery1 = "SELECT cat_id FROM categories WHERE cat_name = ".$event_cat; $subsquery2 = "SELECT tournament_id FROM tournaments WHERE tournament_name = ".$event_tournament; $sqlx = "INSERT INTO events(event_team1, event_team2, event_cat, event_tournament, event_start_at, event_end_to, event_by) VALUES(:event_team1, :event_team2, :event_cat, :event_tournament, :event_start_at, :event_end_to, :event_by)"; // Prepare statement $statementx = $pdo->prepare($sqlx); // execute the query $resultx = $statementx->execute(array(':event_team1' => $event_team1, ':event_team2' => $event_team2, ':event_cat'=> $subsquery1, ':event_tournament'=> $subsquery2, ':event_start_at' => $event_start_at, ':event_end_to' => $event_end_to,':event_by'=>$event_by));` <hr/> SQL ERROR FOLLOW : <br/> `Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`datenbank`.`events`, CONSTRAINT `events_ibfk_1` FOREIGN KEY (`event_cat`) REFERENCES `categories` (`cat_id`) ON DELETE CASCADE ON UPDATE CASCADE)` -- Table structure for table `events` CREATE TABLE `events` ( `event_id` int(8) NOT NULL AUTO_INCREMENT PRIMARY KEY, `event_team1` varchar(255) NOT NULL, `event_team2` varchar(255) NOT NULL, `event_start_at` timestamp NOT NULL, `event_end_to` timestamp NOT NULL, `event_cat` int(8) NOT NULL, `event_by` int(8) NOT NULL, `event_tournament` int(8) NOT NULL, KEY `event_cat` (`event_cat`), KEY `event_by` (`event_by`), KEY `event_tournament` (`event_tournament`) )ENGINE=InnoDB DEFAULT CHARSET=latin1; -- Constraints for table `posts` ALTER TABLE `posts` ADD CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`post_event`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `posts_ibfk_2` FOREIGN KEY (`post_by`) REFERENCES `users` (`id`) ON UPDATE CASCADE; -- Constraints for table `events` ALTER TABLE `events` ADD CONSTRAINT `events_ibfk_1` FOREIGN KEY (`event_cat`) REFERENCES `categories` (`cat_id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `events_ibfk_2` FOREIGN KEY (`event_by`) REFERENCES `users` (`id`) ON UPDATE CASCADE, ADD CONSTRAINT `events_ibfk_3` FOREIGN KEY (`event_tournament`) REFERENCES `tournaments` (`tournament_id`) ON DELETE CASCADE ON UPDATE CASCADE; Please could somebody helps by ...
<php><mysql><sql><pdo>
2016-07-25 05:09:45
LQ_EDIT
38,560,879
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath is not be called
I have a viewcontroller called BNRItemViewcontroller In the implementation: - (instancetype)init{ self = [super initWithStyle:UITableViewStylePlain]; if (self) { for (int i = 0; i < 5; i++) { [[BNRItemStore sharedStore]createItem]; } } return self; } - (instancetype)initWithStyle:(UITableViewStyle)style{ return [self init]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [[[BNRItemStore sharedStore] allItems] count]; } I add a breakpoint in the **cellForRowAtIndexPath:** method,but it didn't get in the method. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath]; NSArray *items = [[BNRItemStore sharedStore] allItems]; BNRItem *item = items[indexPath.row]; cell.textLabel.text = [item description]; return cell; }
<ios><objective-c>
2016-07-25 06:18:19
LQ_EDIT
38,561,083
Can we make submit the iPhone and iPad version of an app on iTunes store?
I have an iPad app,and converted my iPad app into an iPhone app. Now I want to submit my app for both iPhone and iPad version using same bundle id. Is it possible to do so? Please Help and Suggest Thanks
<ios><appstore-approval>
2016-07-25 06:33:35
LQ_EDIT
38,561,633
Limit insert in column in mysql
<p>How can I limit the maximum times a string can be inserted in a column in MySQL. If it reaches the maximum amount, it moves to the next. For an example if 1 is entered 3 times it moves to 2. Like 1 1 1 2 2 2 3 3 3 4 4 4..... and so on.</p>
<php><mysql>
2016-07-25 07:09:11
LQ_CLOSE
38,561,799
i didnt get the datatable format in my page
i added datatable for one page. but its should not get the datatable format <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script> <table class="example3" id="example1"> <tr> <td></td> <td></td> </tr> </table> <script> $(document).ready(function() { $('.example3').DataTable(); alert('1234567890'); } ); </script> i got the error like this i checked both the class and id class the are get from the database. if i remove the data also i didnt get the values TypeError: c is undefined ...ldren("th, td").each(function(a,b){var c=o.aoColumns[a];if(c.mData===a){var d=s(... please let me know where i done mistake, because same thing i added for other project i work fine for this project get error
<php><jquery><codeigniter><datatables>
2016-07-25 07:20:07
LQ_EDIT
38,562,159
Why the input "abc!!!" but the output is not "abc+++"?
<p>I researching about input/output file.Below code relate some functions such as: fgetc(),fgets(),fputs(). i don't know why it does not work exactly as i want.Thank you so much ! Below is my code:</p> <pre><code>#include &lt;stdio.h&gt; int main() { FILE *fp; //FILE type pointer int c; //using to get each character from file char buffer [256]; //array as buffer to archive string fp = fopen("file.txt", "r"); /*open a file with only read mode*/ if( fp == NULL ) { perror("Error in opening file"); return(-1); } while(!feof(fp)) /*check if has not yet reached to end of file*/ { c = getc (fp); //get a character from fp if( c == '!' ) { ungetc ('+', fp); //replace '!' by '+' } else { ungetc(c, fp); //no change } fgets(buffer,255,fp);//push string of fp to buffer fputs(buffer, stdout); //outputting string from buffer to stdout } return(0); } </code></pre> <hr>
<c><file><fgets><fputs><ungetc>
2016-07-25 07:41:50
LQ_CLOSE
38,562,391
How come this array has a length of 13?
<p>im confused as the following array has only 13 elements in it and shows the length as 13,Why so?</p> <pre><code>class ArrayCopyOfDemo { public static void main(String[] args) { char[] copyFrom = {'d', 'e', 'c', 'a', 'f', 'f', 'e','i', 'n', 'a', 't', 'e', 'd'}; char[] copyTo = java.util.Arrays.copyOfRange(copyFrom, 2, 10); System.out.println(new String(copyTo)); System.out.println(copyFrom.length); } </code></pre> <p>}</p> <p>It should be showing 12</p>
<java><arrays><multidimensional-array>
2016-07-25 07:54:23
LQ_CLOSE
38,562,945
Print multidimensional String array in C
I am trying to print the below two dimensional string array in C as below: char text[10][80] = { "0", "Zero", "1", "One", "2", "Two", "3", "Three", "4", "Four", }; The output should be like this: 1 One 2 Two 3 Three 4 Four ......... and so on. I have written the below program: int main() { char text[10][80] = { "0", "Zero", "1", "One", "2", "Two", "3", "Three", "4", "Four", }; int i, j; for(i=0; i<6; i++) { for(j=0; j<1; j++) { printf("%s ", text[i]); } } return 0; } It does not provide me the desired output. I have tried several ways. But no good luck. If anyone knows, your help would be greatly appreciated !!!
<c><arrays><string><output-formatting>
2016-07-25 08:30:17
LQ_EDIT
38,566,079
Remove some part from a database field mysql
i am saving complete file path in single field now i want to split it. bellow is my current database file path. Current field name is "video_thumb" ../files/thumbs/2014-Oct/1413648778-sm.jpg now i want to split it into 2 fields folder path in one field i want to split the following to "thumb_path" ../files/thumbs/2014-Oct/ the file name in another field "file_name" 1413648778-sm.jpg i tried this but not access UPDATE video_thumb SET video_thumb = SUBSTRING(video_thumb, 24) WHERE video_thumb LIKE '_:%' any one can help me..
<mysql>
2016-07-25 11:05:00
LQ_EDIT
38,566,951
pls help me resize uilabel using content ,in autolayout ios i tried with cgrectmake not working
cell.msglabel=[[UILabel alloc] initWithFrame:CGRectMake(10, 100, myLabel.frame.size.width, myLabel.frame.size.height)]; cell.msglabel.lineBreakMode = NSLineBreakByWordWrapping; [cell.msglabel setFrame:CGRectMake(10, 10, myLabel.frame.size.width, myLabel.frame.size.height)]; cell.msglabel.text=text; [cell.msglabel updateConstraints];
<autolayout><resize><uilabel><constraints>
2016-07-25 11:48:11
LQ_EDIT
38,568,043
jQuery set all select inputs to certain value
<p>I'd like to loop through all of the select inputs on a page and if the selected value is not a certain option then set that value to selected</p> <p>I have some selects (notice in select1, option 2 is selected)</p> <pre><code>&lt;select name="select1"&gt; &lt;option value="1"&gt;One&lt;/option&gt; &lt;option value="2" selected&gt;Two&lt;/option&gt; &lt;option value="3"&gt;Three&lt;/option&gt; &lt;option value="4"&gt;Four&lt;/option&gt; &lt;option value="5"&gt;Five&lt;/option&gt; &lt;/select&gt; &lt;select name="select2"&gt; &lt;option value="1"&gt;One&lt;/option&gt; &lt;option value="2"&gt;Two&lt;/option&gt; &lt;option value="3"&gt;Three&lt;/option&gt; &lt;option value="4"&gt;Four&lt;/option&gt; &lt;option value="5"&gt;Five&lt;/option&gt; &lt;/select&gt; &lt;select name="select3"&gt; &lt;option value="1"&gt;One&lt;/option&gt; &lt;option value="2"&gt;Two&lt;/option&gt; &lt;option value="3"&gt;Three&lt;/option&gt; &lt;option value="4"&gt;Four&lt;/option&gt; &lt;option value="5"&gt;Five&lt;/option&gt; &lt;/select&gt; </code></pre> <p>The idea here would be to have a checkbox that when it's checked set select2 and select3 to have option 2 selected as they don't have that option already selected and append a string to the value so I know they've been updated e.g '-updated' </p> <p>I'm looping through them like so, but I can't figure out how to set the selected property to option '2' if it isn't already selected and then append '-updated' to the value</p> <pre><code>$('select').each(function() { var selected = $(this).find(":selected"); if (selected.val() != 2) { // set option 2 as selected // append '-updated' to value } } </code></pre> <p>Fiddle <a href="https://jsfiddle.net/69zzr6xa/6/" rel="nofollow">https://jsfiddle.net/69zzr6xa/6/</a></p>
<javascript><jquery>
2016-07-25 12:38:42
LQ_CLOSE
38,568,446
Laravel 5.2 mail-tracker
<p>I build new project using laravel 5.2 and I want track emails opens,clicks and bounced emails . But I didn't found the best. If you know please point me</p>
<php><laravel-5.2>
2016-07-25 12:58:56
LQ_CLOSE
38,569,220
) PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\wamp\www\malala\insert_post.php
Please help not able to resolve, trying since three days but not able to know what the reason its throwing me such message. (below is my complete code). <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <!DOCTYPE html> <html> <head> <title>Insert New Post</title> </head> <body> <form method="post" action="insert_post.php" enctype="multipart/form-data"> <table align="center" border="10" width="600"> <tr> <td align="center" colspan="5" bgcolor="yellow"><h1>Insert New Post Here</h1></td> </tr> <tr> <td align="right">Post Title:</td> <td><input type="text" name="title" size="40"></td> </tr> <tr> <td align="right">Post Author:</td> <td><input type="text" name="author"></td> </tr> <tr> <td align="right">Post image:</td> <td><input type="file" name="image_name"></td> </tr> <tr> <td align="right">Post Content:</td> <td><textarea name="content" cols="50" rows="20"></textarea></td> </tr> <tr> <td align="center" colspan="5"><input type="submit" name="submit" value="Publish Now"></td> </tr> </table> </form> </body> </html> <!-- end snippet --> Above Form is to insert and submit data in Database <?php include("includes/connect.php"); if (isset($_POST['submit'])) { $title = $_POST['title']; $datenow = date('Y/m/d'); $author = $_POST['author']; $content = $_POST['content']; $image_name = $_FILES['image_name']['name']; $image_type = $_FILES['image_name']['type']; $image_size = $_FILES['image_name']['size']; $image_tmp = $_FILES['image_name']['tmp_name']; if ($title =='' || $author =='' || $content =='') { echo "<script>alert('Any feild is empty')</script>"; exit(); } if ($image_type =='image/jpeg' || $image_type =='image/png' || $image_type =='image/gif') { if ($image_size<=5000000000) { move_uploaded_file($image_tmp, "images/$image_name"); } else{ echo "<script>alert('Image is larger, only 50kb size is allowed')</script>"; } } else{ echo "<script>alert('image type is invalid')</script>"; } // insert query $sth = $con->prepare(" INSERT INTO posts (post_title, post_date, post_author, post_image, post_content) VALUE (:title,:datenow,:author,:image_name,:content) "); $sth->bindParam(':post_title', $title); $sth->bindParam(':post_date', $datenow); $sth->bindParam(':post_author', $author); $sth->bindParam(':post_image', $image_name); $sth->bindParam(':post_content', $content); $sth->execute(); echo "<h1>Form Submited Successfully</h1>"; } ?> $sth->execute(); is throwing error massage as above
<php><html><css><pdo>
2016-07-25 13:34:30
LQ_EDIT
38,569,306
Regular Expression for " - " and characters after
<p>This is a question for experts on regular expressions, since it is something that I dont have much insight.</p> <p>Its not C#, java specific, its a general regular expression that I need to put in one application that will rename files.</p> <p>Basically I have structures of folders like this.</p> <pre><code>1 - I went to the cinema 1 I went to the cinema 1 - movie title 1 I went to the cinema 1 - movie title 2 I went to the cinema 1 - movie title 3 I went to the cinema 1 - movie title 4 2 - I went to the cinema 2 3 - I went to the cinema 3 </code></pre> <p>I need an expression that pretty much returns the text after " - " because everything is before is the parent folder name.</p> <p>May be a simple question but I did some search and I can't find it.</p> <p>Thanks</p>
<regex><criteria>
2016-07-25 13:38:39
LQ_CLOSE
38,569,513
how to get a html element to overlap another when it is displayed
For example, I have a mobile responsive site, and the main menu works fine, but when I resize the browser window to be small, to replicate a small screen such as a mobile phones.... One of the main menu items that has a drop down list gets displayed on top of the other main menu items. This means that the main menu drop down items are displayed on top of some main menu text directly underneath! i have done z index so the drop down menu does sit on top, but the problem is, even though it sits on top, the main menu underneath is still displayed. please help
<html><css><drop-down-menu><main><overlap>
2016-07-25 13:47:22
LQ_EDIT
38,571,122
How to fit C# application in every resolution
<p>i want to know how to fit c# application in every Resolution my c# application open in my computer is perfect but when i install this application on my client machine so it's show half application.</p> <p>What I have tried:</p> <pre><code>this.WindowState = FormWindowState.Maximized; this.Location = new Point(0, 0); this.Size = Screen.PrimaryScreen.WorkingArea.Size; </code></pre>
<c#><winforms><size><screen><resolution>
2016-07-25 14:57:20
LQ_CLOSE
38,572,002
oracle query that can filter paired data
I need some help with an oracle query that can skip 'pairs' and only pick non paired data. example my data is as follows Id - cost - hour - type 123 $1.00 1 Input 123 $1.00 1 Output 234 $2.00 4 Input 345 $5.00 4 Output 236 $3.00 5 Input 236 $3.00 3 Output In the above example - only the first one is a 'pair' as the first 3 fields match - in the case of the next 2 - the first three fields data do not exactly match
<oracle>
2016-07-25 15:37:13
LQ_EDIT
38,574,658
How get expected output in C#
My program is generating a output but i am expecting some other type. If i send 6 input numbers it should compare using loop and generate answer. using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { string[] tokens_a0 = Console.ReadLine().Split(' '); int a0 = Convert.ToInt32(tokens_a0[0]); int a1 = Convert.ToInt32(tokens_a0[1]); int a2 = Convert.ToInt32(tokens_a0[2]); string[] tokens_b0 = Console.ReadLine().Split(' '); int b0 = Convert.ToInt32(tokens_b0[0]); int b1 = Convert.ToInt32(tokens_b0[1]); int b2 = Convert.ToInt32(tokens_b0[2]); if (a0 > b0 || a0 < b0) { Console.WriteLine(1); } if (a1 > b1 || a1 < b1) { Console.WriteLine(1); } if (a2 > b2 || a2 < b2) { Console.WriteLine(1); } } } This program is generating Output 1 1 I need output to show this way 1 1 How to change the loop to generate this kind of output
<c#><arrays><console>
2016-07-25 18:08:07
LQ_EDIT
38,575,965
What are some machine learning algorithms
<p>I'm kinda confused about machine learning is classification in machine learning is algorithm amd is suprivied and unsupervised is algorithms or type of ML? What are some machine learning algorithms? </p>
<machine-learning>
2016-07-25 19:30:31
LQ_CLOSE
38,576,586
How to sort variables in my particular case
I would like to sort "years" in var yearObject so the menu starts with 2016 instead of 2013. Please help. [Example](http:jsfiddle.net/bond1126/r1nvsta9/)
<javascript>
2016-07-25 20:11:03
LQ_EDIT
38,576,939
PHP array sort using Bubble approach
<p>I have a array such as $arr = array(1,3,2,8,5,7,4,6,0);</p> <p>How can i use bubble sorting method for custom sort ?</p> <p>Thank you</p>
<php><arrays>
2016-07-25 20:32:16
LQ_CLOSE
38,577,124
Differences between Angular JS, JSON and JS?
I know that Angular JS is advanced JavaScript but what will be the extension for it? And know about what is JSON? Also want to know how to select syntax in sublime text editor 3 for Angular JS?
<angularjs><sublimetext3>
2016-07-25 20:44:45
LQ_EDIT
38,577,245
Comparing records in one table to another for large databases in PHP
<p>I have two tables in MySQL database. Lets say there are 1800 records in table 1 and 20000 records in table 2. Now I want to compare each record in table 1 to table 2 and update some fields in table 2 for the records that are matched. </p> <p>I want to know what is the most optimized way to do this.</p>
<php><mysql>
2016-07-25 20:53:19
LQ_CLOSE
38,577,766
I'm trying to do exponent in c, but this is what is get
<p>I'm trying to do a example of exponent en " DEV C++ " compilator and I can't get the output </p> <p>this is the code :</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;math.h&gt; int main (void) { double base, exponent, result; printf("La base:\n"); scanf("%lf",&amp;base); printf("El exponente:\n"); scanf("%lf",&amp;exponent); result = pow(base, exponent); printf("%.1lf^%.1lf = %.21f", base, exponent, result); return 0; } </code></pre> <p>and i get this :</p> <p><a href="https://i.stack.imgur.com/BQ4Ps.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BQ4Ps.png" alt="exponent"></a></p> <p>what could be the problem ?</p> <p>Sincerilly, NIN.</p>
<c><dev-c++>
2016-07-25 21:30:46
LQ_CLOSE
38,577,914
Too many if statements in JAVA
<p>Hello I'm trying to make a java program where a user can enter different commands and this class can identify all the commands and based on that it calls methods from 3-4 different classes. currently for each command I have different if statements as such:</p> <pre><code>if (input.equals("change category FOOD"){...} if (input.equals("Sort by price FOOD"){...} if (input.equals("logout"){...} </code></pre> <p>There are so many commands, and I wanted to know if there is a way to shorten this up.</p>
<java><oop>
2016-07-25 21:44:59
LQ_CLOSE
38,578,528
Base64 encoding new line
<p>I am trying to encode some hex values to base64 in shell script.</p> <pre><code>nmurshed@ugster05:~$ echo -n "1906 1d8b fb01 3e78 5c21 85db 58a7 0bf9 a6bf 1e42 cb59 95cd 99be 66f7 8758 cf46 315f 1607 66f7 6793 e5b3 61f9 fa03 952d 9101 b129 7180 6f1d ca93 3494 55e0 0e2e" | xxd -r -p | base64 GQYdi/sBPnhcIYXbWKcL+aa/HkLLWZXNmb5m94dYz0YxXxYHZvdnk+WzYfn6A5UtkQGxKXGAbx3K kzSUVeAOLg== </code></pre> <p>I get a automatic new line after 76 charecters, Is there a way to avoid that ?</p> <p>Online i found, use "-n" to ignore new lines...Can anyone suggest something ?</p>
<bash><shell>
2016-07-25 22:46:15
HQ
38,578,801
target_compile_options() for only C++ files?
<p>Is it possible to use <code>target_compile_options()</code> for only C++ files? I'd like to use it for a target that is uses as a dependency for other applications so that the library can propagate its compiler flags to those apps. However, there are certain flags, such as <code>-std=c++14</code>, that cause the build to fail if they are used with C or ObjC files.</p> <p>I've read that I should <code>CXX_FLAGS</code> instead to only add those flags to C++ files, however this won't (automatically) propagate through cmake's packages system.</p>
<c++><cmake>
2016-07-25 23:17:33
HQ
38,579,273
how to include a prototype in typescript
<p>I am learning angular 2 and I have written a ts definition for a truncate method I want to use in one of my services.</p> <p>truncate.ts</p> <pre><code>interface String { truncate(max: number, decorator: string): string; } String.prototype.truncate = function(max, decorator){ decorator = decorator || '...'; return (this.length &gt; max ? this.substring(0,max)+decorator : this); }; </code></pre> <p>How do I import this into another typescript module or at least make it available to use globally. </p>
<javascript><typescript><angular>
2016-07-26 00:18:54
HQ
38,579,312
HealthMonitoring Failure Audits Repercussions in ASP.NET
<p>Our event viewer shows two information-level messages that we want to omit from the event logs: </p> <ol> <li>When a user fails authentication (Event code: 4006 Event message: Membership credential verification failed.)</li> <li>When forms authentication has expired and the user navigates to the default page (Event code: 4005 Event message: Forms authentication failed for the request. Reason: The ticket supplied has expired.)</li> </ol> <p>Researching how to exclude these types of messages has led me to understand that if I include the following in my web.config file, these messages won't show up. When I test this, I see that is indeed the case.</p> <pre><code>&lt;healthMonitoring&gt; &lt;rules&gt; &lt;clear /&gt; &lt;add name="All Errors Default" eventName="All Errors" provider="EventLogProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom=""/&gt; &lt;/rules&gt; &lt;/healthMonitoring&gt; </code></pre> <p>In other words, I omit this from the default web.config:</p> <pre><code>&lt;add name="Failure Audits Default" eventName="Failure Audits" provider="EventLogProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom=""/&gt; </code></pre> <p>My question is: what else could I potentially be excluding the event log by removing this node? And if there are other potential repercussions, is there another or a better way to exclude just those two types of error logs that I mentioned above?</p> <p>Thanks in advance!</p>
<asp.net><authentication><web-config><event-log><health-monitoring>
2016-07-26 00:23:06
HQ
38,579,373
Is there Rx.NET for .NET Core?
<p>Found <a href="https://github.com/Reactive-Extensions/Rx.NET/issues/148" rel="noreferrer">https://github.com/Reactive-Extensions/Rx.NET/issues/148</a>, but I could not figure out the bottom line - where is Rx.NET for .NET Core and how to get it?</p> <p>I am using Enterprise Visual Studio 2015 Update 3 with .NET Core installed.</p>
<c#><system.reactive><.net-core>
2016-07-26 00:31:02
HQ
38,579,626
Control multiple cameras with the same controls
<p>I have two different threejs scenes and each has its own camera. I can control each camera individually with a corresponding <code>TrackballControls</code> instance.</p> <p>Is there a reliable way to 'lock' or 'bind' these controls together, so that manipulating one causes the same camera repositioning in the other? My current approach is to add <code>change</code> listeners to the controls and update both cameras to either's change, but this isn't very neat as, for one, both controls can be changing at once (due to dampening).</p>
<three.js>
2016-07-26 01:05:12
HQ
38,580,538
Responsive Inline SVG using Bootstrap
<p>How to make an inline svg icon responsive using Bootstrap? Here is a sample code:</p> <pre><code>&lt;svg id="mute-audio" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewbox="-10 -10 68 68"&gt; &lt;circle cx="24" cy="24" r="34"&gt; &lt;title&gt;Mute Audio&lt;/title&gt; &lt;/circle&gt; &lt;path class="on" transform="scale(0.6), translate(17,18)" d="M38 22h-3.4c0 1.49-.31 2.87-.87 4.1l2.46 2.46C37.33 26.61 38 24.38 38 22zm-8.03.33c0-.11.03-.22.03-.33V10c0-3.32-2.69-6-6-6s-6 2.68-6 6v.37l11.97 11.96zM8.55 6L6 8.55l12.02 12.02v1.44c0 3.31 2.67 6 5.98 6 .45 0 .88-.06 1.3-.15l3.32 3.32c-1.43.66-3 1.03-4.62 1.03-5.52 0-10.6-4.2-10.6-10.2H10c0 6.83 5.44 12.47 12 13.44V42h4v-6.56c1.81-.27 3.53-.9 5.08-1.81L39.45 42 42 39.46 8.55 6z" fill="white"/&gt; &lt;path class="off" transform="scale(0.6), translate(17,18)" d="M24 28c3.31 0 5.98-2.69 5.98-6L30 10c0-3.32-2.68-6-6-6-3.31 0-6 2.68-6 6v12c0 3.31 2.69 6 6 6zm10.6-6c0 6-5.07 10.2-10.6 10.2-5.52 0-10.6-4.2-10.6-10.2H10c0 6.83 5.44 12.47 12 13.44V42h4v-6.56c6.56-.97 12-6.61 12-13.44h-3.4z" fill="white"/&gt; &lt;/svg&gt; </code></pre> <p>I tried different:</p> <ol> <li><p>class="img-responsive" in svg </p></li> <li><p>class="embed-responsive-item" in the container div</p></li> </ol> <p>No luck so far. How to accomplish this?</p>
<html><twitter-bootstrap><svg><responsive>
2016-07-26 03:26:35
HQ
38,580,858
How to change display name of an app in react-native
<p>Apple have <a href="https://developer.apple.com/library/prerelease/content/qa/qa1823/_index.html" rel="noreferrer">clear instructions</a> on how to change the display name of an IOS app, but they are not useful for a react-native app because the folder structure is different. How do you change the display name if you have a react-native app?</p>
<android><ios><react-native>
2016-07-26 04:08:01
HQ
38,580,890
How to return 403 response in JSON format in Laravel 5.2?
<p>I am trying to develop a RESTful API with Laravel 5.2. I am stumbled on how to return failed authorization in JSON format. Currently, it is throwing the 403 page error instead of JSON.</p> <p>Controller: <code>TenantController.php</code></p> <pre><code>class TenantController extends Controller { public function show($id) { $tenant = Tenant::find($id); if($tenant == null) return response()-&gt;json(['error' =&gt; "Invalid tenant ID."],400); $this-&gt;authorize('show',$tenant); return $tenant; } } </code></pre> <p>Policy: <code>TenantPolicy.php</code></p> <pre><code>class TenantPolicy { use HandlesAuthorization; public function show(User $user, Tenant $tenant) { $users = $tenant-&gt;users(); return $tenant-&gt;users-&gt;contains($user-&gt;id); } } </code></pre> <p>The authorization is currently working fine but it is showing up a 403 forbidden page instead of returning json error. Is it possible to return it as JSON for the 403? And, is it possible to make it global for all failed authorizations (not just in this controller)?</p>
<php><laravel-5><laravel-5.2>
2016-07-26 04:11:13
HQ
38,581,074
How do I set the Hibernate dialect in SpringBoot?
<p>I have a custom dialect to set for Hibernate in SpringBoot. The dialect is for Gemfire. The instructions (<a href="https://discuss.zendesk.com/hc/en-us/articles/201724017-Pivotal-GemFire-XD-Hibernate-Dialect" rel="noreferrer">https://discuss.zendesk.com/hc/en-us/articles/201724017-Pivotal-GemFire-XD-Hibernate-Dialect</a>) are for XML-based config. However, I am using SpringBoot and I cannot figure out how to set this property.</p> <p>The dialect is "com.pivotal.gemfirexd.hibernate.GemFireXDDialect"</p>
<spring-boot><gemfire>
2016-07-26 04:34:41
HQ
38,581,724
find a minimum spanning tree in different sets
Here I have two connected undirected graphs G1 = [V ; E1] and G2 = [V ; E2] on the same set of vertices V . And assume edges in E1 and E2 have different colors. Let w(e) be the weight of edge e ∈ E1 ∪ E2. I want to find a minimum weight spanning tree (MSF) among those spanning trees which have at least one edge in each set E1 and E2. In this condition, how to find a proper algorithm for this? I got stuck here a whole night.
<algorithm><graph><minimum-spanning-tree>
2016-07-26 05:34:38
LQ_EDIT
38,581,811
Why didn´t work my OpenFileDialog
I try to open a textdocument and than i get the message: invalid file format from the try-catch. I use Visual Studio 2015 with Visual C# and Windows Forms Application. Here my code for the open function: private void openToolStripMenuItem_Click(object sender, EventArgs e) { try { // Create an OpenFileDialog to request a file to open. OpenFileDialog openFile1 = new OpenFileDialog(); // Initialize the OpenFileDialog to look for RTF files. openFile1.Filter = "Text Files (*.txt)|*.txt| RTF Files (*.rtf)|*.rtf| All (*.*)|*.*"; // Determine whether the user selected a file from the OpenFileDialog. if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK && openFile1.FileName.Length > 0) { // Load the contents of the file into the RichTextBox. TextBox.LoadFile(openFile1.FileName); } } catch (Exception a) { MessageBox.Show(a.Message); } }//end open I hope you can help me with friendly wishes sniffi.
<c#><.net><winforms><rtf>
2016-07-26 05:41:54
LQ_EDIT
38,582,238
How to write to file the values returned by a function in python
Here the calc_property_statistics function returns maximum,minimum,average values. I need to write them to a file. def calc_property_statistics(prop, realisation=0): values = prop.get_values(realisation) maximum = np.max(values) minimum = np.min(values) average = np.average(values) print("maximum: {}, minimum: {}, average: {} for property {}".format( maximum, minimum, average, prop)) return (maximum, minimum, average)
<python>
2016-07-26 06:13:34
LQ_EDIT
38,582,273
app enter background and then enter foreground will appear this bug (Splash Screen)
[about bug][1] [1]: http://i.stack.imgur.com/AGeKu.gif app enter background and then enter foreground will appear this bug (Splash Screen) this bug only appear iPhone6 after If you have ever had this experience, pls tell me thx
<ios><iphone>
2016-07-26 06:15:50
LQ_EDIT
38,582,999
what is difference between find() and children() in jquery?
<p>I got Question in interview. What is main difference between <strong>find()</strong> and <strong>children()</strong>. Please answer . Thanks in advance</p>
<jquery>
2016-07-26 06:57:07
LQ_CLOSE
38,583,745
How to add a HttpResponse to a C# class
<p>I'm generating an Excel file and I want to download it like this in my ASP.NET MVC 5 application:</p> <pre><code>var ef = new ExcelFile(); var ws = ef.Worksheets.Add("Worksheet 1"); ef.Save(this.Response, "asd.xlsx"); </code></pre> <p>In the last line, it gives error because there is no HttpResponse, how can I add HttpResponse to my class? Thanks.</p>
<c#><asp.net><excel><asp.net-mvc-5>
2016-07-26 07:36:53
LQ_CLOSE
38,583,763
Change divs width/height dinamically
<p>Hi stackoverflow community! I'm making some practice with css/html5 "copying" other websites layouts and stuff to learn and understand how things works.</p> <p>Now I'm get into this website codepen.io/picks/10/ where the divs after "Picked Pens" change their size dinamically if i resize my browser. So my question is: what is the "magic" behind this thing? I'm not looking for any code but just some stuff to study to understand how this kind of things works.</p>
<javascript><jquery><css><html>
2016-07-26 07:37:48
LQ_CLOSE
38,583,842
Javscript, How to get sum of multiple fields that have same id and get the value of each summation
Okay so i have a loop dynamic input field ID but i will show how it look likes. the output is like this `<input type="text" id="sp_criteria1">` value -> 20 `<input type="text" id="sp_criteria1">` value -> 25 i need the sum of this ^ = 45 `<input type="text" id="sp_criteria3">` value -> 20 `<input type="text" id="sp_criteria3">` value -> 25 i need the sum of this ^ = 45 `<input type="text" id="sp_criteria5">` value -> 20 `<input type="text" id="sp_criteria5">` value -> 25 i need the sum of this ^ = 45 `<input type="text" id="sp_criteria6">` value -> 20 `<input type="text" id="sp_criteria6">` value -> 25 `<input type="text" id="sp_criteria6">` value -> 20 i need the sum of this ^ = 65 so i need to get those sum at the same time 45 45 45 65
<javascript>
2016-07-26 07:42:42
LQ_EDIT
38,585,002
wpf binding datagrid filled from MySQL
i have that code in my desktop application that fill the datagrid from mysql database var mA = new MySql.Data.MySqlClient.MySqlDataAdapter("SELECT * FROM items", DataHolder.MySqlConnection); var mT = new System.Data.DataTable(); mA.Fill(mT); dataGrid.ItemsSource = mT.DefaultView; but i can't figure out how to bind it to change certain cells in certain column to change it's background color when it's equl to certain values
<c#><mysql><wpf><binding>
2016-07-26 08:42:38
LQ_EDIT
38,585,783
OpenShift CLI: oc vs rhc?
<p>What is the difference between <strong>rhc</strong> and <strong>oc</strong> CLI-tools?</p> <p>As I see, they do almost the same:</p> <p><strong>oc</strong>:</p> <blockquote> <p>The OpenShift CLI exposes commands for managing your applications, as well as lower level tools to interact with each component of your system.</p> </blockquote> <p><strong>rhc</strong> does the same, no?</p> <p>What should I use to manage my containers on OpenShift platform?</p>
<openshift>
2016-07-26 09:16:48
HQ
38,585,973
Access 'Internal' classes with C# interactive
<p>Using the C# interactive console in VS2015, i want to access properties and classes marked as <code>internal</code>. Usually, this is done by adding the InternalsVisibleAttribute to the project in question. Ive tried adding csc.exe as a 'friend' assembly, but i still have the access problems.</p> <ol> <li>Is this the correct approach to access internal class members via the C# interactive console?</li> <li>If it is, what dll/exe do i need to make the internals visible to?</li> </ol>
<c#><visual-studio-2015><c#-interactive>
2016-07-26 09:25:45
HQ
38,586,028
docker-compose up -d <name>; No such service: <name>
<p>I have built an image using my dockerfile with the following command:</p> <pre><code>docker build –t &lt;name&gt;:0.2.34 . </code></pre> <p>and then I have tried to use my docker-compose.yml:</p> <pre><code>strat: container_name: &lt;name&gt; image: &lt;name&gt;:0.2.34 restart: always command: bash -lc 'blah' </code></pre> <p>to bring up my container:</p> <pre><code>docker-compose up -d &lt;name&gt; </code></pre> <p>Which gives me the following 'error':</p> <pre><code>No such service: &lt;name&gt; </code></pre>
<docker><docker-compose>
2016-07-26 09:27:34
HQ
38,586,050
React Native: "Auto" width for text node
<p>I have a text element inside a view:</p> <p><code>&lt;View&gt;&lt;Text&gt;hello world foo bar&lt;/Text&gt;&lt;/View&gt;</code></p> <p>as part of a flex grid.</p> <p>I want this view to have an auto width based on the content i.e. length of the text.</p> <p>How do I achieve this?</p>
<css><react-native><flexbox>
2016-07-26 09:28:45
HQ
38,586,451
Internal Server error 500 for .htaccess file creat
when i creat **.htaccess** file for urlrewrite .i got error Internal Server Error 500.i try to all the solution from net but itn't work. please help me thanx..
<apache><.htaccess><mod-rewrite>
2016-07-26 09:46:31
LQ_EDIT
38,587,682
Sort Divs by ID's name with JQuery
I'm having a strange error here, I'm trying to sort divs by its ID's name. You can take a look here: `https://jsfiddle.net/veeco/t3wu9tss/3/` It looks works... but we're wrong... if we add new ID like the example here: `https://jsfiddle.net/veeco/t3wu9tss/4/` The sort got broken. I don't know why ? it seem strange, can anyone give insight ? Thanks
<javascript><jquery>
2016-07-26 10:42:26
LQ_EDIT
38,587,898
In Influxdb, How to delete all measurements?
<p>I know <code>DROP MEASUREMENT measurement_name</code> used to drop single measurement. How to delete all measurements at once ?</p>
<influxdb>
2016-07-26 10:52:37
HQ
38,589,227
Why "this" is undefined inside a fat arrow function definition?
<p>First I tried this -</p> <pre><code>const profile = { name: 'Alex', getName: function(){ return this.name; } }; </code></pre> <p>Which works fine. Now I tried the same thing with fat arrow. In that case "this" is coming undefined.</p> <pre><code>const profile = { name: 'Alex', getName: () =&gt; { return this.name; } }; </code></pre> <p>This gives me an error </p> <blockquote> <p>TypeError: Cannot read property 'name' of undefined</p> </blockquote> <p>What I learned was, fat arrow syntaxes are way better handling implicit "this". Please explain why is this happening.</p>
<javascript><ecmascript-6>
2016-07-26 11:55:09
HQ
38,590,249
Gets.chomp not working| Learn Ruby the hard way exercise 11
I am currently learning Ruby and I am stuck in the 11th exercise of _Learn Ruby the Hard Way_ and I have to write this: print "How old are you? " age = gets.chomp() print "How tall are you? " height = gets.chomp() print "How much do you weigh? " weight = gets.chomp() puts "So, you're #{age} old, #{height} tall and #{weight} heavy." And I have to get this: How old are you? 35 How tall are you? 6'2" How much do you weigh? 180lbs So, you're 35 old, 6'2" tall and 180lbs heavy. but I get this: How old are you? How tall are you? How much do you weigh? So, you're old, tall and heavy. So that means that gets.chomp is not working and I don't understand anything. Please Help me Thanks in advance, Jason
<ruby>
2016-07-26 12:43:37
LQ_EDIT
38,590,685
The most effective method to discover Birthdays between two Dates regardless of year?
<p>I have rundown of records from which I need to extricate Birthdays between two given dates, paying little heed to the year. </p> <p>That is, I need the birthdays falls between dates, say 2015-12-01 and 2015-12-31 </p> <p>The straightforward between Query checks whether the Date of Birth fields falls between these two or not. </p> <p>It would be ideal if you offer assistance... </p> <p>Much obliged</p>
<c#><sql-server>
2016-07-26 13:03:05
LQ_CLOSE
38,591,514
javascript closures not retaining variable values from outer scope
<pre><code>.filter('asRelapsedTime', function(ConfigService) { var DECIMAL_STYLE = ','; return function(value, decimalPlaces) { let decimalizedNumber; if (decimalPlaces) { decimalizedNumber = value.toFixed(decimalPlaces | 0); } else { decimalizedNumber = value.toString(); } decimalizedNumber = decimalizedNumber.replace('.'. DECIMAL_STYLE); return decimalizedNumber; }; }); </code></pre> <p>From the above code, DECIMAL_STYLE should be available for use within the inner function. However it is not. What am I missing here ?</p>
<javascript>
2016-07-26 13:40:23
LQ_CLOSE
38,591,637
javascript removing copyright character from text
I am using some regex to remove white spaces from some text in javascript. The current regex looks like this var cleaned_plaintext = website_content; cleaned_plaintext = cleaned_plaintext.toLowerCase(); cleaned_plaintext = cleaned_plaintext.replace(/(\0\r\n|\n|\r|\0)/gm," "); cleaned_plaintext = cleaned_plaintext.replace(/\s+/g," "); cleaned_plaintext = cleaned_plaintext.replace(/[...\(\)]/g,""); cleaned_plaintext = cleaned_plaintext.replace(/[…]/g,""); cleaned_plaintext = cleaned_plaintext.replace(/[:!?.,={-}]/g," "); cleaned_plaintext = cleaned_plaintext.replace(/\s+/g," "); The above regex does pretty good at cleaning up most white spaces but say I have symbols like these © How can I remove those with regex? Also any tips on cleaning up that above regex to make it more streamlined, faster, etc....
<javascript><regex><text-processing>
2016-07-26 13:45:26
LQ_EDIT
38,592,012
RegEx to replace a string inside a string in Visual Studio 2015 search
<p>I've got the following string all over my code:</p> <pre><code>languageService.getString("string_from_key"); </code></pre> <p>Now I want to replace <code>"string_from_key"</code> (with the quotation marks) with <code>KeyClass.string_from_key</code>.</p> <p>I am struggling with the RegEx in Visual Studio 2015 to search and replace the mentioned strings all over the code. <code>string_from_key</code> is a changing value, thats why RegEx. Thanks in advance.</p>
<c#><regex><visual-studio>
2016-07-26 14:01:33
LQ_CLOSE
38,593,453
Prevent Visual Studio from trying to parse typescript
<p>Working on a project using Visual Studio as my IDE. It has an API component written in C#, and a webserver component that uses TypeScript. </p> <p>I am using webpack to deal with the typescript compilation and would like to remove the Visual Studio build step from the typescript files. </p> <p>Normally I wouldn't care if it was building them, but I am using Typescript > 1.8.4 which has language features that Visual Studio cannot understand which is making Visual Studio throw errors and prevent compilation. I found a workaround for this in <a href="https://github.com/Microsoft/TypeScript/issues/8518" rel="noreferrer">this github issue thread</a> but I have other developers cross team who are working on this and trying to coordinate a hack to make code among them will not work. </p> <p>I have also tried removing the typescript imports line from the .csproj file, but whenever I add a new ts file, it adds the line back in. </p> <p>Is there a way to completely shut down the typescript compilation/parsing step in Visual Studio and prevent it from coming back?</p> <p>This in in VS 2015.</p>
<visual-studio><typescript>
2016-07-26 15:01:43
HQ
38,593,535
Can link prefetch be used to cache a JSON API response for a later XHR request?
<p>Given a JSON API endpoint <code>/api/config</code>, we're trying to use <code>&lt;link rel="prefetch" href="/api/config"&gt;</code> in the head of an HTML document. Chrome downloads the data as expected when it hits the link tag in the HTML, but requests it again via XHR from our script about a second later.</p> <p>The server is configured to allow caching, and is responding with <code>Cache-Control: "max-age=3600, must-revalidate"</code> in the header. When Chrome requests the data again, the server responds correctly with a 304 Not Modified status.</p> <p>The use case is this: the config endpoint will always be requested from the Javascript in our single page application using XHR (an AngularJS resolve, in case it's relevant). However, our scripts are very large and take a long time to parse, so the JSON config will not be requested until the parsing is finished. Prefetching would allow us to use some of that parsing time to fetch and cache responses from API endpoints that would otherwise have to wait for the scripts to load.</p>
<javascript><html><google-chrome><browser-cache><prefetch>
2016-07-26 15:05:38
HQ
38,593,840
Payload contains two or more files with the same destination path 'System.Diagnostics.Tools.dll'
<p>After I add 2 libraries from Nuget to my project I receive follow error:</p> <pre><code>Error Payload contains two or more files with the same destination path 'System.Diagnostics.Tools.dll'. Source files: C:\Users\Horcrux7\.nuget\packages\runtime.any.System.Diagnostics.Tools\4.0.1\lib\netcore50\System.Diagnostics.Tools.dll C:\Users\Horcrux7\.nuget\packages\System.Diagnostics.Tools\4.0.0\lib\netcore50\System.Diagnostics.Tools.dll App1 </code></pre> <p>How can I solve this version conflict?</p> <p>I have only a very small single UWP project.</p>
<visual-studio><reference><nuget><uwp>
2016-07-26 15:18:43
HQ
38,594,523
How to create page in PHP?
<p>Is there a function in PHP for create page in PHP? I would something like that:</p> <pre><code>create page("file.php", "&lt;html&gt;&lt;body&gt;&lt;p&gt;Hello!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;"); </code></pre> <p>If I run it on <code>site.it</code>, It will create site.it/file.php with <code>&lt;html&gt;&lt;body&gt;&lt;p&gt;Hello!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</code>.</p> <p>Can I do it?</p>
<php>
2016-07-26 15:50:34
LQ_CLOSE
38,594,948
Can I use all the HTML tags inside a script tag of type javascript
<p>I've tried placing some of the HTML tags inside a JavaScript tag but its not working.can anyone explain it.</p>
<javascript><html>
2016-07-26 16:11:27
LQ_CLOSE
38,595,169
In the context of OpenCV, what is `ippicv`?
<p>While building OpenCV 3.1.0 on CentOS I've been getting a hash mismatch error caused by a file called <code>ippicv_linux_20151201.tgz</code>. After some research I have found that the two prevailing solutions suggested by several people (for example <a href="https://github.com/opencv/opencv/issues/5973" rel="noreferrer">here</a>) are the following.</p> <ol> <li>Build again with option <code>-DWITH_IPP=OFF</code>.</li> <li>Manually download the file <code>ippicv_linux_20151201.tgz</code> and put it in the right place.</li> </ol> <p>Now solution 2 above didn't work for me, and I feel a bit nervous about solution 1. My fear is that building OpenCV with <code>-DWITH_IPP=OFF</code> might prevent some things from working properly later, thus making a time bomb. My question is what is IPP? Or <code>ippicv</code>? Or ICV? I'm not even sure what to ask here. I want to know what I'm about to disable in the build before I disable it.</p>
<opencv><opencv3.1>
2016-07-26 16:23:02
HQ
38,595,181
play video extention files on server
hey i would like for files with .3gp or mp4 to play in the browser when you type the url path insted of giving you the download option i want somthing like this http://www.html5videoplayer.net/videos/toystory.mp4 this is what i currently have http://www.reelychat.com/img/1/profileVid/SampleVideo.3gp also i am using godaddy web server
<html><web-services><video>
2016-07-26 16:23:25
LQ_EDIT
38,595,316
how to arrange two divs side by side
<div id="quarterlistpanel" style="display:None; " > <apex:selectList id="QuarterSelList" size="1" title="List of Quartersin year" style=" padding: 2px 4px; margin: 4px 2px;" > <apex:selectOption itemvalue="Quarters" itemLabel="Select a Quarter" /> <apex:selectOption itemvalue="Q1" itemLabel="Quarter 1"/> </apex:selectList> </div> <div id="buttonpanel" style="display:None; float:left"> <apex:commandButton action="{!selectQuarter}" value="Go!" status="actStatusId2" reRender="pgBlckId,panelrender,panelrender1,panelrender14,panelrender15,panelrender24,panelrender23,panelrender12,panelrender13,panelrender2,panelrender21,panelrender22" id="button2"/> <apex:actionStatus id="actStatusId2" title="This is the status for loading image"> <apex:facet name="start" > <img src="/img/loading.gif" width="25" height="25" align="bottom" title="Loading"/> <h3> Loading..</h3> </apex:facet> </apex:actionStatus> </div> I want to display these two div tags side by side.please let me know how can i achieve this.
<html><css><visualforce>
2016-07-26 16:31:33
LQ_EDIT
38,596,002
i want to display Bangla language from my database .
**i want to display Bangla language from my database . but it shows error massage > i want to display Bangla language from my database . Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\dashboard\ban.php on line 362 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\dashboard\ban.php on line 364**
<mysqli><utf-8>
2016-07-26 17:07:06
LQ_EDIT
38,596,079
How do I parse an ISO 8601 Timestamp in GoLang?
<p>I know I need to use a time layout in GoLang (as shown here <a href="https://golang.org/src/time/format.go" rel="noreferrer">https://golang.org/src/time/format.go</a>) but I can't find the layout for an ISO 8601 timestamp. </p> <p>If it helps, I get the timestamp from the Facebook API. Here is an example timestamp: <code>2016-07-25T02:22:33+0000</code></p>
<go><time><timestamp>
2016-07-26 17:11:52
HQ
38,596,430
I insert struct to vector,but address of all the elements of vector are same
<p>I declared a struct treenode</p> <pre><code>struct treenode { int val; treenode *l; treenode *r; }; </code></pre> <p>and a vector</p> <pre><code>vector&lt;int&gt; v = { 1,2,3,4,5,6,7,8,9 }; </code></pre> <p>now I want to create a vector tv to store the value of v</p> <pre><code>vector&lt;treenode* &gt; tv; for (int i = 0; i &lt; v.size(); i++) { treenode mid; mid.val = v[i]; mid.l = NULL; mid.r = NULL; tv.push_back(&amp;mid); } </code></pre> <p>but when I print the value of tv, I found all the element of tv are same(same address), there are 9. I`m confused, I have create a new treenode every iteration, why all the element use same address <a href="http://i.stack.imgur.com/DmrC7.png" rel="nofollow">enter image description here</a></p>
<c++><vector><struct>
2016-07-26 17:33:34
LQ_CLOSE
38,596,834
React enzyme testing, Cannot read property 'have' of undefined
<p>I'm writing a test using <a href="https://github.com/airbnb/enzyme" rel="noreferrer">Enzyme</a> for React.</p> <p>My test is extremely straightforward:</p> <pre><code>import OffCanvasMenu from '../index'; import { Link } from 'react-router'; import expect from 'expect'; import { shallow, mount } from 'enzyme'; import sinon from 'sinon'; import React from 'react'; describe('&lt;OffCanvasMenu /&gt;', () =&gt; { it('contains 5 &lt;Link /&gt; components', () =&gt; { const wrapper = shallow(&lt;OffCanvasMenu /&gt;); expect(wrapper.find(&lt;Link /&gt;)).to.have.length(5); }); }); </code></pre> <p>This code is basically taken directly from <a href="https://github.com/airbnb/enzyme/blob/master/docs/api/shallow.md" rel="noreferrer">airbnb/enzyme docs</a>, but returns the error:</p> <pre><code>FAILED TESTS: &lt;OffCanvasMenu /&gt; ✖ contains 5 &lt;Link /&gt; components Chrome 52.0.2743 (Mac OS X 10.11.6) TypeError: Cannot read property 'have' of undefined </code></pre> <p>I'm a little unclear on what I'm doing differently from the docs. Any guidance greatly appreciated.</p>
<testing><reactjs><enzyme>
2016-07-26 17:57:57
HQ
38,597,908
How do I debug node.js errors when my code is nowhere in the stack trace?
<p>And actually, I don't fully understand <em>why</em> my code is not in the stack trace, if node is single threaded. Maybe I'm fundamentally misunderstanding, something, but why does my application sometimes die with a stack trace that doesn't have anything I've written in it?</p> <p>I'm writing a pretty simple proxy server using node/express. As an example, I was periodically getting this "socket hangup error":</p> <pre><code>Error: socket hang up at createHangUpError (_http_client.js:250:15) at Socket.socketOnEnd (_http_client.js:342:23) at emitNone (events.js:91:20) at Socket.emit (events.js:185:7) at endReadableNT (_stream_readable.js:926:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) code: 'ECONNRESET' } </code></pre> <p>And since none of the javascript files in the stack trace are mine, I had no idea where this was coming from. It was basically trial and error, trying to catch errors and adding .on style error-handlers until I found the right place.</p> <p>I feel like I'm fundamentally missing something - what I should I be doing differently in order to debug errors like this? How do I know where to handle it if I can't see what (in my code) is causing it? How do I know whether I should be using a try/catch block, or something like <code>request.on('error') {...}</code>?</p>
<node.js><express>
2016-07-26 19:01:07
HQ
38,598,280
Is it possible to wrap a function and retain its types?
<p>I'm trying to create a generic wrapper function which will wrap any function passed to it.</p> <p>At the very basic the wrapper function would look something like</p> <pre><code>function wrap&lt;T extends Function&gt;(fn: T) { return (...args) =&gt; { return fn(...args) }; } </code></pre> <p>I'm trying to use it like:</p> <pre><code>function foo(a: string, b: number): [string, number] { return [a, b]; } const wrappedFoo = wrap(foo); </code></pre> <p>Right now <code>wrappedFoo</code> is getting a type of <code>(...args: any[]) =&gt; any</code></p> <p>Is it possible to get <code>wrappedFoo</code> to mimic the types of the function its wrapping?</p>
<typescript>
2016-07-26 19:23:39
HQ
38,598,880
How do I install modules on qpython3 (Android port of python)
<p>I found this great module on within and downloaded it as a zip file. Once I extracted the zip file, i put the two modules inside the file(setup and the main one) on the module folder including an extra read me file I needed to run. I tried installing the setup file but I couldn't install it because the console couldn't find it. So I did some research and I tried using pip to install it as well, but that didn't work. So I was wondering if any of you could give me the steps to install it manually and with pip (keep in mind that the setup.py file needs to be installed in order for the main module to work).</p> <p>Thanks!</p>
<python><module><qpython><qpython3>
2016-07-26 20:00:23
HQ
38,599,484
We aren't able to process your payment using your PayPal account at this time
<p>I'm getting this error on a sandbox account:</p> <blockquote> <p>We aren't able to process your payment using your PayPal account at this time. Please go back to the merchant and try using a different payment method.</p> </blockquote> <p>My .Net app is successfully redirecting to PayPal, with the correct payment details. As soon as I log in with my sandbox account I get the above error. Is there a way to get to a log or anything that could help me source the issue? It was all working fine until this week, so I wonder has something changed in that time?</p> <p>I have checked the accounts have a suitable balance. The payment is for €24 so it is not excessive. There are a few other posts regarding the issue but nothing with any suitable suggestions.</p> <p><a href="https://i.stack.imgur.com/ucujB.jpg"><img src="https://i.stack.imgur.com/ucujB.jpg" alt="enter image description here"></a></p>
<c#><.net><paypal><sandbox>
2016-07-26 20:40:21
HQ
38,599,939
How to get larger favicon from Google's api?
<p>Is it possible to get a larger version of the favicon from the Google's api or from somewhere else?</p> <p>This is the url. <a href="http://www.google.com/s2/favicons?domain=google.com" rel="noreferrer">http://www.google.com/s2/favicons?domain=google.com</a></p> <p>I searched for an alternative api on ProgrammableWeb and Google but many of them don't exist anymore and the one I found that actually seems to work isn't free. (<a href="http://grabicon.com/" rel="noreferrer">http://grabicon.com/</a>)</p> <p>I need the icon for a VB.NET project that has a list of websites with icons. But 16x16 icons are too small for that.</p>
<favicon>
2016-07-26 21:10:58
HQ
38,600,119
Is the default lodash memoize function a danger for memory leaks?
<p>I want to use <code>memoize</code> but I have a concern that the cache will grow indefinitely until sad times occur.</p> <p>I couldn't find anything via google/stackoverflow searches.</p> <p>P.S. I am using lodash v4.</p>
<javascript><lodash>
2016-07-26 21:24:35
HQ
38,600,277
String is equal to an If statement value and yet doesn't work, need help ASAP
I have problem with the following code: if finalName == "London, GB" { let londonImage = UIImage(named: "united-kingdom-1043062.jpg") imageViewPage1.image = londonImage } if finalName == "Novaya Gollandiya, RU" { let StPetersbourgImage = UIImage(named: "architecture-995613_1920.jpg") imageViewPage1.image = StPetersbourgImage } if finalName == "Berlin, DE" { let BerlinImage = UIImage(named: "siegessaule-200714_1920.jpg") imageViewPage1.image = BerlinImage } if finalName == "Tel Aviv, IL" { let TelAvivImage = UIImage(named: "buildings-89111.jpg") imageViewPage1.image = TelAvivImage } else { let elseImage = UIImage(named: "sun-203792.jpg") imageViewPage1.image = elseImage } } I already debugged and the value is "Berlin, DE" and it still does the else instead of the finalName == "Berlin, DE", can anyone help me?
<ios><swift><xcode><if-statement><swift2>
2016-07-26 21:34:48
LQ_EDIT
38,600,297
Is there any "serverless" / gobal database hosting?
Iam bulling a litte python + GTK app. I need a way where I can store some index data on a server. Frist I look at RedHat´s OpenShift as the server rest-backend (python + flask + mysql) But now I am thinking is there a way to just put some data into the "cloud". I know the cloud just i a buzz word for other peoples computers / servers. But something like the bitcoin where you just push some key/val data then any node in the network gets the data after some time. Apache Cassandre look like can do some thing like this. But I don't want to host anything. Some thing like this. $ datacloud <openid> <password> <databucket> $ datacloud add <key> <jsondata / val> $ datacloud get <key> $ <jsondata> Or in python. import datacloud as dc import json def main(): dc.connect("<myopenid.provider.org>", "<password>", "<databucket>") ds.add("key", json.dumps({"hello":"world"})) for data in dc: print data print dc.get("<key>") --> { "hello": "world"} Or better just with jquey. <html> <head> <script href="pathto/jquery.js"></script> <title>ServerLess / local site</title> <script> $(function(){ $.ajax({ url: "magnet:?xt=urn:btih:5dee65101db281ac9c46344cd6b175cdcad53426", data: { "openid": "<openid.myopenidprovier.org>", "password": "<12345>", "bucket": "<databucket>" } }).done(function(keys){ for(var i=0; i < keys.length; i++) $('#news').append('<h3>'+key[i]+'</h3>'); }); }); </script </head> <body> <h1>News with no server</h1> <div id="news"></div> </body> </html> Iam look for an p2p global key/val store. ... an freenet like data global key/val cache or store..
<database><database-design><key-value><p2p>
2016-07-26 21:36:02
LQ_EDIT
38,600,414
What change in Powershell 5 changes meaning of block curly brackets
<p>We recently updated the Powershell version on our build servers from 4.0 to 5.0. This change caused one of our build scripts to start failing in an unexpected way. </p> <p>The code is used to determine which user guides should be included in our product. The code processes a list of xml nodes that describe all available documents with version and culture. We group by document title and culture and then select the most fitting version.</p> <pre><code>$documents = Get-ListItemsFromSharePoint $documents = $documents | Where-Object { $productVersion.CompareTo([version]$_.ows_Product_x0020_Version) -ge 0 } | Where-Object { -not ($_.ows_EncodedAbsUrl.Contains('/Legacy/')) } Write-Verbose -Message "Filtered to: $($documents.length) rows" # Filter to the highest version for each unique title per language $documents = $documents | Group-Object { $_.ows_Title, $_.ows_Localisation } | ForEach-Object { $_.Group | Sort-Object { [version]$_.ows_Product_x0020_Version } -Descending | Select-Object -First 1 } </code></pre> <p>In Powershell 4 this code correctly sorts the documents by title and culture and then selects the most suitable version. In Powershell 5 this code groups all documents in a single list and then selected the most suitable version from that list. Given that we have documents in multiple languages this means that only the language with the most suitable version will be present.</p> <p>The issue was fixed by changing </p> <pre><code>$documents = $documents | Group-Object { $_.ows_Title, $_.ows_Localisation } | </code></pre> <p>to</p> <pre><code>$documents = $documents | Group-Object ows_Title, ows_Localisation | </code></pre> <p>Now I understand that the first syntax is not technically correct according to the documentation because Group-Object expects an array of property names to group on, however in Powershell 4 the code did return the desired results.</p> <p>The question now is what changed in Powershell 5 that the original code worked in Powershell 4 but failed in Powershell 5.</p>
<powershell>
2016-07-26 21:46:17
HQ
38,600,442
Attach button to right side of screen that is responsive to the layout
<p>I am using bootstrap and I am looking for a way to attach a button to the right side of the screen. I have provided a picture to help give an understanding of what I am trying to accomplish. The button in the picture when clicked is attached to a panel that comes out of the right hand side of the screen. </p> <p><a href="https://i.stack.imgur.com/UIisw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UIisw.jpg" alt="enter image description here"></a></p>
<html><css><twitter-bootstrap>
2016-07-26 21:49:23
LQ_CLOSE
38,600,628
undefined method respond_to in Rails 5 controller
<p>I'm upgrading an app from rails 3.something to rails 5. For some reason, I'm am getting undefindied method respond_to anytime I use that method in any of my controllers. This was working before and I was hoping someone here could help.</p> <pre><code>class StatusController &lt; ApplicationController #this throws an error 'undefined method respond_to respond_to :json, :html end </code></pre>
<ruby><ruby-on-rails-5>
2016-07-26 22:05:09
HQ
38,600,950
$(this).parent().remove(); not functioning
<p>I am running through a todo list tutorial for jQuery and I ran into an issue that I cannot figure out. My code looks exactly like what is in the video. I have tried to do this on both Plunker and JSFiddle and was not able to get it to work. Can anyone see what is wrong with this?</p> <p>Here is my HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt;&lt;/title&gt; &lt;link rel="stylesheet" href="style.css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Tasks&lt;/h1&gt; &lt;ul id="todoList"&gt; &lt;/ul&gt; &lt;input type="text" id="newText" /&gt;&lt;button id="add"&gt;Add&lt;/button&gt; &lt;script data-require="jquery" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"&gt;&lt;/script&gt; &lt;script src="script.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and my jQuery:</p> <pre><code>function addListItem() { var text = $('#newText').val(); $('#todoList').append('&lt;li&gt;' + text + ' &lt;button class="delete"&gt;Delete&lt;/button&gt;&lt;/li&gt;'); $('#newText').val(''); } function deleteItem() { $(this).parent().remove(); } $(function() { $('#add').on('click', addListItem); $('.delete').on('click', deleteItem); }); </code></pre>
<javascript><jquery>
2016-07-26 22:36:27
LQ_CLOSE
38,600,964
Force singlethreading in form application (.NET 4.5)
I recently created a form application through the Windows Form Application template in Visual Studio. The program was automatically created with multiple threads, putting the UI on one thread and whatever else on the other thread (I think). Regardless I ran into and fixed the issue described [here][1] What I want to know is how to do manipulate the program to run everything on a single thread so that I do not have to worry about adding the extra code to manipulate UI objects, or do I not have a choice? For reference, the code where I ran into this issue was in the main Form class. [1]: http://stackoverflow.com/a/244614
<c#><asp.net><.net><multithreading><forms>
2016-07-26 22:37:34
LQ_EDIT
38,601,141
What is the difference between "==" and "===" comparison operators in Julia?
<p>What is the difference between <code>==</code> and <code>===</code> comparison operators in Julia?</p>
<julia>
2016-07-26 22:52:56
HQ
38,601,171
Intellij IDEA 2016.2 high CPU usage
<p>I have only one project (an ordinary SpringFramework project) opened. And the IDE is crazy using CPU:</p> <p><a href="https://i.stack.imgur.com/mrlw9.png"><img src="https://i.stack.imgur.com/mrlw9.png" alt="enter image description here"></a></p> <p>JVisualVM CPU sample:</p> <p><a href="https://i.stack.imgur.com/B00GX.png"><img src="https://i.stack.imgur.com/B00GX.png" alt="enter image description here"></a></p> <p><strong>Note</strong> this happened just recently</p> <p>Any idea?</p>
<intellij-idea>
2016-07-26 22:56:34
HQ
38,601,548
How to move files with firebase storage?
<p>Is there a way to move files with firebase.storage()?</p> <p>Example: user1/public/image.jpg to user1/private/image.jpg</p>
<firebase><firebase-storage>
2016-07-26 23:41:50
HQ
38,601,617
What's the most minimalistic way to render "OK" in Elixir/Phoenix?
<p>In Rails you can render text directly, e.g. <code>render :text =&gt; 'OK'</code></p> <p>Is there a shortcut in Elixir/Phoenix to render text directly, without having to define a template or layout?</p> <p>The shortest way I found was this:</p> <pre><code> defmodule MyApp.PageController do use MyApp.Web, :controller def index(conn, _params) do # the file ok.html.eex contains just the string OK render conn, "ok.html", layout: false end end </code></pre> <p>Is there a shorter way to render "OK", without having to provide the template file "ok.html"? </p>
<phoenix-framework>
2016-07-26 23:49:29
HQ
38,602,082
Ionic 2 Align Button Label to left
<p>I created a button in Ionic 2 as follows:</p> <pre><code> &lt;button secondary block round padding style="text-align : left;"&gt; &lt;ion-icon ios="ios-key" md="md-key"&gt;&lt;/ion-icon&gt; Login &lt;/button&gt; </code></pre> <p>I am trying to align the button text to left side but its not coming there. Is there build in twik available to achieve that?</p>
<ionic-framework><ionic2>
2016-07-27 00:55:13
HQ
38,602,146
React router best practices for nested navigation?
<p>I am building a React application, and using React Router for managing routing. The information architecture of the application can be represented as follows:</p> <pre><code> - App - Projects - Project 1 - Objects - Object 1 - Object 2 - etc... - Collaborators - ... - Services - Users </code></pre> <p>The UI of the application would look something like this, when looking at a route such as <code>/#/projects/1/components/1</code></p> <pre><code>----------------------------------------------------------- | | Home &gt; Projects &gt; 0 &gt; Object &gt; 1 | | Home |--------------------------------------------| | | | | Projects | Object 1 | | | | | Services | Blah blah blah | | | | | Users | | | | | ----------------------------------------------------------- </code></pre> <p>Note that for any given route shown in the information architecture scheme above, the view should be rendered in the body section (where 'Component 1' is rendered in the diagram above).</p> <p>Now I will describe how I have been wrongly implementing this in React using React Router:</p> <p>I have been using PlainRoutes to define my routes. Here is a short example of how a route is defined:</p> <pre><code>const routes = [ { path: '/', component: App, name: 'Home', childRoutes: [ // /projects { path: 'projects', component: Projects, name: 'Projects' }, { path: 'projects/:projectid', component: ProjectDetails, name: 'Project Details', childRoutes: [ { path: 'objects', component: Objects, name: 'Objects' }, { path: 'objects/:objectid', component: ObjectDetails, name: 'Object Details' }, { path: 'collaborators', component: Collaborators, name: 'Collaborators' } ] }, // /services { path: 'services', component: Services, name: 'Services' }, // /users { path: 'users', component: Users, name: 'Users' } ] } ]; </code></pre> <p>which then get fed into the React Router component, like this: <code>&lt;Router routes={routes}&gt;&lt;/Router&gt;</code></p> <p>Doing this sort of worked. When I would attempt to navigate to:</p> <p><code>/#/projects</code></p> <p>I would see the Projects component rendered in the body of the app.</p> <p>When I would attempt to navigate to:</p> <p><code>/#/projects/1</code></p> <p>I would see the ProjectDetail component rendered in the body of the app.</p> <p>However, when I would attempt to navigate to:</p> <p><code>/#/projects/1/objects</code></p> <p>I would still see the ProjectDetail component rendered in the body of the app. I am not sure why the router would just stop when the <code>/projects/:projectid</code> parameter was resolved, and not continue to render components assigned to the <code>/projects/:projectid/objects</code> route.</p> <p>I think that the problem was that I was using React Router in the wrong way. Child routes are supposed to be physically nested inside their parent components - not just logically nested. At least, I think that is the problem. Clearly, I am a bit confused as to how React Router is intended to be used - especially the concept of <code>childRoutes</code>.</p> <p>The question then is - how to use React Router to give the application the hierarchical structure that I am seeking, as outlined above? I want the router to be aware of the deeply nested structure of the application (for things like breadcrumbs and navigation), but I don't want to physically nest the components inside one another. What are best practices here?</p>
<reactjs><react-router>
2016-07-27 01:04:44
HQ
38,603,014
Type signature for function with possibly polymorphic arguments
<p>Can I, and if so, how do I, write the type signature for a function:</p> <pre><code>g f x y = (f x, f y) </code></pre> <p>Such that given:</p> <pre><code>f1 :: a -&gt; [a] f1 x = [x] x1 :: Int x1 = 42 c1 :: Char c1 = 'c' f2 :: Int -&gt; Int f2 x = 3 * x x2 :: Int x2 = 5 </code></pre> <p>Such that:</p> <pre><code>g f1 x1 c1 == ([42], ['c']) :: ([Int], [Char]) g f2 x1 x2 == (126, 15) :: (Int, Int) </code></pre>
<haskell>
2016-07-27 03:04:33
HQ
38,604,422
Default constructor does not initialize the instance members of the class?
<p>I encountered a question that asks "Which of the following are true about the "default" constructor?"</p> <p>and an option "It initializes the instance members of the class." was incorrect choice.</p> <p>Now my understanding was that if we have a code such as</p> <pre><code> Class Test { String name; } </code></pre> <p>then the compiler creates default constructor that looks like</p> <pre><code> Class Test { String name; Test(){ super(); name = null; } } </code></pre> <p>Isn't the default constructor initializing the instance member name=null ?</p>
<java><constructor><default-constructor>
2016-07-27 05:29:55
HQ
38,604,524
Laravel : Redis No connection could be made : [tcp://127.0.0.1:6379]
<p>I have installed redis with laravel by adding <code>"predis/predis":"~1.0"</code>,</p> <p>Then for testing i added the following code :</p> <pre><code>public function showRedis($id = 1) { $user = Redis::get('user:profile:'.$id); Xdd($user); } </code></pre> <p>In app/config/database.php i have :</p> <pre><code>'redis' =&gt; [ 'cluster' =&gt; false, 'default' =&gt; [ 'host' =&gt; env('REDIS_HOST', 'localhost'), 'password' =&gt; env('REDIS_PASSWORD', null), 'port' =&gt; env('REDIS_PORT', 6379), 'database' =&gt; 0, ], ], </code></pre> <p>It throws the following error : <code>No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]</code></p> <p>I using <code>virtualhost</code> for the project. Using <code>Xampp with windows</code>.</p>
<php><laravel><redis>
2016-07-27 05:37:53
HQ
38,604,715
How can I remove jenkins completely from linux
<p>I have deleted jenkins all directories from different folders. But still when I access URL it is showing me jenkins login.</p> <p>I want to uninstall jenkins completely. Have tried many commands from internet but still jenkins is there on server. </p> <p>I have only command line access via putty so I tries whatever is possible via command to remove jenkins.</p>
<linux><jenkins>
2016-07-27 05:51:49
HQ
38,604,745
Plzz help as a benineer am not be able to resolve it
try { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); SqlParameter[] pram = new SqlParameter[7]; pram[0] = new SqlParameter("@fname", SqlDbType.VarChar, 50); pram[1] = new SqlParameter("@lname", SqlDbType.VarChar, 50); pram[2] = new SqlParameter("@dob", SqlDbType.VarChar, 50); pram[3] = new SqlParameter("@gender", SqlDbType.Char, 10); pram[4] = new SqlParameter("@fathername", SqlDbType.VarChar, 50); pram[5] = new SqlParameter("@contact", SqlDbType.Int, 100); pram[6] = new SqlParameter("@address", SqlDbType.VarChar, 50); pram[0].Value = fname; pram[1].Value = lname; pram[2].Value = dob; pram[3].Value = gender; pram[4].Value = fathername; pram[5].Value = contact; pram[6].Value = address; for (int i = 0; i < pram.Length; i++) { cmd.Parameters.Add(pram[i]); } cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); } catch(System.Data.SqlClient.SqlException ex_msg) { string msg = "Error occured while inserting"; msg += ex_msg.Message; throw new Exception(msg); } finally { conn.Close(); }
<c#><sql>
2016-07-27 05:53:35
LQ_EDIT