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
36,444,231
How to create a map like the one that's there on ikman.lk
<p>I want to know how to create a map like the one that is there on <a href="http://ikman.lk/" rel="nofollow">ikman.lk</a></p>
<html><css><maps>
2016-04-06 07:25:50
LQ_CLOSE
36,444,553
Transfer content of one array to another, removing duplicates
<p>I have an array of about 1000 words. I want to transfer them to another array while removing any duplicates. How can I do this in C# ? </p>
<c#>
2016-04-06 07:42:14
LQ_CLOSE
36,444,576
The width of my Web page is 1680px. No matter how big the resolution of the other monitors is let the width of my Web page be same as 1680 px.
The width of my Web page is 1680px. No matter how big the resolution of the other monitors is (1920px, 2560px, 2880px,...), let the width of my Web page be same as 1680 px. I tried to make it by using "iframe", but problems occur. How can I do it using Jquery? [enter image description here][1] [1]: http://i.stack.imgur.com/KSglr.jpg
<javascript><jquery>
2016-04-06 07:43:06
LQ_EDIT
36,447,609
remove some line in a java Document
i have a java Document which contains XML, how i can do if i want to take from that Document only some information enclosed in some tags? Example (i want only tag included in <catalog> <catalog/>) //Some VALUES <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> <ORACLE> select * from scott.dept; </ORACLE> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS Records</COMPANY> <PRICE>9.90</PRICE> <YEAR>1988</YEAR> </CD> <ORACLE> begin htp.p('This is the test data'); end; </ORACLE> </CD> </CATALOG> //OTHER VALUES
<java><xml>
2016-04-06 09:54:10
LQ_EDIT
36,447,951
a half gauge/speedometer animation using javascript
Hiiiii, i am having problem with a gauge "[click here][1]", i need this gauge animated on change of amount given below the "GAUGE" not on "Turnover amount" [1]: http://clients.pix10.com/demo/5paisa/index.html
<javascript><gauge>
2016-04-06 10:08:55
LQ_EDIT
36,447,980
PHP Array Readable
<p>I have an Array format.</p> <pre><code>Array ( [0] =&gt; Array ( [order_id] =&gt; 1 ) [1] =&gt; Array ( [order_id] =&gt; 11 ) [2] =&gt; Array ( [order_id] =&gt; 12 ) ) </code></pre> <p>It should to be changed the array format to be like this format:</p> <pre><code>[1,11,12]; </code></pre> <p>Please help. Thank you in advanced.</p>
<php><arrays>
2016-04-06 10:10:09
LQ_CLOSE
36,449,030
Identity auto jumping in sql local db
Hi All friend i have a application that coded with c# and it has Sql Local Db Database as i know one time i attached my database in sql server 2012 and then detach it now one of my user inform me that table id jump from 36 to 1036 after that i change user database to new again it jump from 2 to 1003 i see many solution for this problem but i dont have like this problem to my old user that they have old version and database my new user have this problem also they dont have sql server 2012 on system just local db in your idea if i remove whole database and create new one from c# it can help me or no
<c#><sql-server>
2016-04-06 10:56:04
LQ_EDIT
36,449,641
want to select my my from java gui program not from web
this is my php code checker code for java application but i want to scan a new file in my java GUI program... enter code here: public class test { public static void main(String[] args) throws MalformedURLException, IOException { URL u = new URL("http://www.example.com/my/php/doc.php"); URLConnection c = u.openConnection(); InputStream r = c.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(r)); for (String line; ( line = reader. `enter code here` readLine()) != null; ) System.out.println(line);
<java><file><inputstream>
2016-04-06 11:21:41
LQ_EDIT
36,449,866
Codeignitor 404 Page Not Found in Signup form
Hi everyone I just created my sign up form with email verification but it's giving me error "`404 Page Not Found`" when I click on Sign up button? Here is my view named as sign_up: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Registeration</title> <!-- CSS --> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500"> <link rel="stylesheet" href="<?php echo base_url();?>assets/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="<?php echo base_url();?>assets/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="<?php echo base_url();?>assets/css/form-elements.css"> <link rel="stylesheet" href="<?php echo base_url();?>assets/css/style.css"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> <!-- Favicon and touch icons --> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="<?php echo base_url();?>assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo base_url();?>assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php echo base_url();?>assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="<?php echo base_url();?>assets/ico/apple-touch-icon-57-precomposed.png"> </head> <body> <!-- Top menu --> <nav class="navbar navbar-inverse navbar-no-bg" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#top-navbar-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <!--<a class="navbar-brand" href="index.html">Bootstrap Registration Form Template</a>--> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="top-navbar-1"> <ul class="nav navbar-nav navbar-right"> <li> <span class="li-text"> Put some information </span> <!--<a href="#"><strong>links</strong></a> --> <span class="li-text"> here to get access: </span> <span class="li-social"> <a href="#"><i class="fa fa-facebook"></i></a> <a href="#"><i class="fa fa-twitter"></i></a> <a href="#"><i class="fa fa-envelope"></i></a> <a href="#"><i class="fa fa-skype"></i></a> </span> </li> </ul> </div> </div> </nav> <!-- Top content --> <div class="top-content"> <div class="inner-bg"> <div class="container"> <div class="row"> <div class="col-sm-7 text"> <h1><strong>Register</strong> Here</h1> <div class="description"> <div class="row"> </div> </div> <div class="top-big-link"> <!--<a class="btn btn-link-1" href="#">Button 1</a> <a class="btn btn-link-2" href="#">Button 2</a>--> </div> </div> <div class="col-sm-5 form-box"> <div class="form-top"> <div class="form-top-left"> <h3>Sign up now</h3> <p>Fill in the form below to get instant access:</p> </div> <div class="form-top-right"> <i class="fa fa-pencil"></i> </div> </div> <div class="form-bottom"> <?php $attributes = array("name" => "registrationform"); echo form_open("Register/reg", $attributes);?> <form role="form" action="" method="post" class="registration-form"> <div class="form-group"> <label class="sr-only" for="form-first-name">Full Name</label> <input type="text" name="name" value="<?php echo set_value('name'); ?>" placeholder="Full Name..." class="form-first-name form-control" id="name" required> <?php echo form_error('name'); ?></span> </div> <div class="form-group"> <label class="sr-only" for="form-email">Email</label> <input type="text" name="email" value="<?php echo set_value('email'); ?>" placeholder="Email..." class="form-email form-control" id="email" required> <span class="text-danger"> <span class="text-danger"><?php echo form_error('email'); ?></span> </div> <div class="form-group"> <label class="sr-only" for="form-last-name">Password</label> <input type="password" name="password" placeholder="Password..." class="form-last-name form-control" id="password" required> <span class="text-danger"><?php echo form_error('password'); ?></span> </div> <div class="form-group"> <label class="sr-only" for="form-last-name">Confirm Password</label> <input type="password" name="password" placeholder="Confirm Password..." class="form-last-name form-control" id="cpassword" required> <span class="text-danger"><?php echo form_error('cpassword'); ?></span> </div> <button type="submit" class="btn">Sign me up!</button> <button type="reset" class="btn">Cancel!</button> <?php echo form_close(); ?> <?php echo $this->session->flashdata('msg'); ?> </div> </div> </div> </div> </div> </div> <!-- Javascript --> <script src="<?php echo base_url();?>assets/js/jquery-1.11.1.min.js"></script> <script src="<?php echo base_url();?>assets/bootstrap/js/bootstrap.min.js"></script> <script src="<?php echo base_url();?>assets/js/jquery.backstretch.min.js"></script> <script src="<?php echo base_url();?>assets/js/retina-1.1.0.min.js"></script> <script src="<?php echo base_url();?>assets/js/scripts.js"></script> <!--[if lt IE 10]> <script src="assets/js/placeholder.js"></script> <![endif]--> </body> </html> here is controller named as Register: <?php class Register extends CI_Controller { function index() { $this->reg(); } function reg() { //set validation rules $this->form_validation->set_rules('name', 'Full Name', 'trim|required|alpha|min_length[3]|max_length[30]|xss_clean'); $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|is_unique[users.email]'); $this->form_validation->set_rules('password', 'Password', 'trim|required|matches[cpassword]|md5'); $this->form_validation->set_rules('cpassword', 'Confirm Password', 'trim|required'); $this->load->view('Seller/login'); //validate form input if ($this->form_validation->run() == FALSE) { // fails $this->load->view('sign_up'); } else { //insert the user registration details into database $data = array( 'name' => $this->input->post('name'), 'email' => $this->input->post('email'), 'password' => $this->input->post('password') ); // insert form data into database if ($this->Seller_model->insertUser($data)) { // send email if ($this->Seller_model->sendEmail($this->input->post('email'))) { // successfully sent mail $this->session->set_flashdata('msg','<div class="alert alert-success text-center">You are Successfully Registered! Please confirm the mail sent to your Email-ID!!!</div>'); redirect('Register/reg'); } else { // error $this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Oops! Error. Please try again later!!!</div>'); redirect('Register/reg'); } } else { // error $this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Oops! Error. Please try again later!!!</div>'); redirect('Register/reg'); } } } function verify($hash=NULL) { if ($this->Seller_model->verifyEmailID($hash)) { $this->session->set_flashdata('verify_msg','<div class="alert alert-success text-center">Your Email Address is successfully verified! Please login to access your account!</div>'); redirect('Register/reg'); } else { $this->session->set_flashdata('verify_msg','<div class="alert alert-danger text-center">Sorry! There is error verifying your Email Address!</div>'); redirect('Register/reg'); } } } ?> here is model named Seller_model: <?php class Admin_model extends CI_Model{ function __construct() { // Call the Model constructor parent::__construct(); } //insert into user table function insertUser($data) { return $this->db->insert('users', $data); } //send verification email to user's email id function sendEmail($to_email) { $from_email = 'team@abc.com'; //change this to yours $subject = 'Verify Your Email Address'; $message = 'Dear User,<br /><br />Please click on the below activation link to verify your email address.<br /><br /> anywebsite/user/verify/' . md5($to_email) . '<br /><br /><br />Thanks<br />` `Mydomain Team'; //configure email settings $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.mydomain.com'; //smtp host name $config['smtp_port'] = '465'; //smtp port number $config['smtp_user'] = $from_email; $config['smtp_pass'] = '********'; //$from_email password $config['mailtype'] = 'html'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $config['newline'] = "\r\n"; //use double quotes $this->email->initialize($config); //send mail $this->email->from($from_email, 'Mydomain'); $this->email->to($to_email); $this->email->subject($subject); $this->email->message($message); return $this->email->send(); } //activate user account function verifyEmailID($key) { $data = array('status' => 1); $this->db->where('md5(email)', $key); return $this->db->update('user', $data); } }?>
<php>
2016-04-06 11:32:04
LQ_EDIT
36,449,898
Auto complete box for movies
<p>Is it possible to make an auto-complete box using data from www.omdbapi.com(xml or json)? Or do you know any other way to make a movie auto-complete box? I would be grateful if you could find me a solution.</p> <p>Thank you.</p>
<jquery><html><json><xml><autocomplete>
2016-04-06 11:33:26
LQ_CLOSE
36,452,489
Not sure how to flip these lines to form a diamond in python 3
The idea of this code is to enter a height and form a diamond with asterisks(stars). eg. If the input for the height was 6, I'd want the code to produce: ************ ***** ***** **** **** *** *** ** ** * * ** ** *** *** **** **** ***** ***** ************ I've gotten the top half so far and am wondering if it is possible to 'flip' lines horizontally to get the bottom half. height = int(input('Enter triangle height: ')) star = height while star >= 1: a = int(star)*'*' b = int(2*height-2*star)*' ' c = (height-star)*'' d = star*'*' print(a, b,c,d,sep='') star = star - 1 star = height while star >= 2: a = int(star) b = int(2*height-2*star) c = int((height-star)) d = int(star) print(a*'*', b*' ',c*'',d*'*',sep='') star = star - 1`
<python>
2016-04-06 13:23:01
LQ_EDIT
36,452,696
Trying to learn better lamba coding
While the following code works fine I was wondering if there a cleaner way to accomplish this with lambda expressions? var counter = 1; foreach (var item in model) { item.ID = counter++; }
<c#><linq>
2016-04-06 13:31:48
LQ_EDIT
36,453,175
How can I execute script after entire webpage has loaded
<p>I have a simply script. For example:</p> <pre><code>var rowCount = $('tr').length; document.write(rowCount); </code></pre> <p>I want to load this after entire webpage has loaded. How can I do?</p>
<javascript><jquery>
2016-04-06 13:50:48
LQ_CLOSE
36,454,279
Ruby BigDecimal Method Error
Using Ruby v2.2.1 with following code, i am getting Error - r56.rb:6:in `<module:BigMath>': undefined method `log_slow' for module `BigMath' (NameError) from r56.rb:5:in `<main>' i have created log_slow alias and it is not working require 'bigdecimal' require 'bigdecimal/math' require 'bigdecimal/util' module BigMath alias :log :log_slow def log(x, prec) if x <= 0 || prec <= 0 raise ArgumentError, "Zero or negative argument for log" end return x if x.infinite? || x.nan? sign, fraction, power, exponent = x.split fraction = BigDecimal(".#{fraction}") power = power.to_s.to_d log_slow(fraction, prec) + (log_slow(power, prec) * exponent) end end include BigMath number = BigDecimal("1234.5678") Math.log(number) prec = 50 puts BigMath.log_slow(number, prec).round(prec).to_s("F") puts BigMath.log(number, prec).round(prec).to_s("F") puts BigMath.log(number ** 1000, prec).round(prec).to_s("F")
<ruby>
2016-04-06 14:34:11
LQ_EDIT
36,455,053
Turning a word into stars (*)
<p>I am looking for a way to turn a word into stars *. This may be used to show a password, without actually showing the characters or numbers.</p> <p>The Outcome <code>$word = "hello";</code></p> <pre><code>$newword = "*****"; </code></pre>
<php><word>
2016-04-06 15:04:06
LQ_CLOSE
36,455,100
Weird headers c++
<p>On <code>A.h</code> i do not have to <code>#include</code> anything or use namespace for anything. </p> <p>On the other header, <code>B.h</code> i have to include <code>vector</code> and <code>using namespace std</code>. Both of this headers are not linked. Seems to be a file problem. When i copy the contents of <code>A.h</code> (without any problems) to <code>B.h</code>, i still get a compiler error saying <code>string</code> is not a type name and <code>vector</code> is not a template although the compiler did not state anything when the same content was on <code>A.h</code>. I am coding c++ on visual studio. What is going on?</p>
<c++>
2016-04-06 15:05:48
LQ_CLOSE
36,455,609
How is the Travis CI Github integration actually working?
<p>I am really only interested in how Github can display the Badge status of the passing / failed build. I has to access Travis somehow?</p>
<github><travis-ci><badge>
2016-04-06 15:27:29
LQ_CLOSE
36,455,844
How can I fix this bug in tline 7 of the program below.It keeps returning syntax error
def cube(number): return number*number*number def by_three(number): if number % 3==0: cube(number) return number else: return False
<python-3.x>
2016-04-06 15:37:27
LQ_EDIT
36,457,277
Maintaing order of dictionary when converting list to dictionary
<p>I have a list </p> <pre><code>List = [('The', 'DT'), ('study', 'NN'), ('guide', 'NN'), ('does', 'VBZ'), ('not', 'RB'), ('discuss', 'VB'), ('much', 'JJ'), ('of', 'IN'), ('the', 'DT'), ('basics', 'NNS'), ('of', 'IN'), ('ethics.', 'NN')] </code></pre> <p>I convert it to a dictionary using</p> <pre><code>dic=collections.OrderedDict() dic=dict(List) </code></pre> <p>when i print the dictionary the order isn't maintained in the way it is in the list.</p> <p>I tried using OrderedDict() but still the order isn't maintained</p>
<python><list><dictionary>
2016-04-06 16:41:25
LQ_CLOSE
36,458,542
MS SQL Need help returning information where value from Table A falls between a date range in table B
Table A Transaction details TTime (datetime), TableAValues, TableAValues, <etc>... Table B Related table ID, DateTimeStart (datetime), DateTimeEnd (datetime), TableBValues, TableBValues, <etc>... I need a way to return a row of information which includes All TableAValues as well as all TableBValues where TTime Table A falls between DateTimeStart and DateTimeEnd of table B.
<sql-server><tsql>
2016-04-06 17:45:07
LQ_EDIT
36,458,737
c++ array of type class
<p>I have just started learning c++. I have a question in an assignment that reads: Consider the following class declaration with a main() function. There are two errors in the main() function. Name them and explain how to fix them.</p> <pre><code>//Question Three Start #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; class Restaurant { public: Restaurant(); int getTables(); int getTempStaff(); int getPermStaff(); string getShifts(); private: string Menu; int Tables; int TempStaff; int PermStaff; string Shifts[3]; }; int main() { Restaurant mimmos; //.........(additional code) string menu = mimmos.Menu; //.........(additional code) //get information about shift 3 cout &lt;&lt; "Shift info:" &lt;&lt; mimmos[2].getShifts() &lt;&lt; endl; return 0; } </code></pre> <p>I know that the first issue is that the member variable Menu is private, but i am not sure how to fix the issue with the mimmos[2].getShifts() and how to use an accessor/mutator function. Any help will be greatly appreciated.</p>
<c++><arrays><class>
2016-04-06 17:53:35
LQ_CLOSE
36,459,131
installing packages in R - warning messages
<p>I tried to install packages in R. But, R software gives warning messages in the below picture. How to install packages in ?</p> <p><a href="https://i.stack.imgur.com/naDtw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/naDtw.png" alt="enter image description here"></a></p>
<r>
2016-04-06 18:13:22
LQ_CLOSE
36,459,379
How can i check if file exist and create if not and then append text to the file in some places?
<pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using Newtonsoft.Json; namespace Youtube_Player { public partial class Authentication : Form { public static string AuthenticationApplicationDirectory; public static string AuthenticationFileName = "Authentication.txt"; StreamWriter w; public static bool formclosed = false; static Authentication() { AuthenticationApplicationDirectory = Path.GetDirectoryName(Application.LocalUserAppDataPath) + "Authentication"; if (!Directory.Exists(AuthenticationApplicationDirectory)) { Directory.CreateDirectory(AuthenticationApplicationDirectory); } AuthenticationFileName = Path.Combine(AuthenticationApplicationDirectory, AuthenticationFileName); if (!File.Exists(AuthenticationFileName)) File.Create(AuthenticationFileName); } public Authentication() { InitializeComponent(); cTextBox1.Text = Form1.AuthenticationValues.ApiKey; cTextBox2.Text = Form1.AuthenticationValues.UserId; cTextBox3.Text = Form1.AuthenticationValues.JsonFileDirectory; label1.Visible = false; button1.Enabled = false; button4.Enabled = false; cTextBox2.WaterMarkForeColor = Color.Blue; cTextBox3.WaterMarkForeColor = Color.Green; cTextBox2.WaterMarkActiveForeColor = Color.Blue; cTextBox3.WaterMarkActiveForeColor = Color.Green; cTextBox1.ForeColor = Color.Red; cTextBox2.ForeColor = Color.Blue; cTextBox3.ForeColor = Color.Green; cTextBox1.WaterMark = "Enter Api Key"; cTextBox2.WaterMark = "Enter Email Account"; cTextBox3.WaterMark = "Browse To The Json File Location"; } private void Authentication_Load(object sender, EventArgs e) { } private void cTextBox1_TextChanged(object sender, EventArgs e) { if (cTextBox1.Text != "Enter Api Key" &amp;&amp; cTextBox1.Text != "") { button1.Enabled = true; } else { button1.Enabled = false; } } private void cTextBox2_TextChanged(object sender, EventArgs e) { if (cTextBox2.Text != "Enter Email Account" &amp;&amp; cTextBox2.Text != "") { button4.Enabled = true; } else { button4.Enabled = false; } } private void cTextBox3_TextChanged(object sender, EventArgs e) { if (cTextBox3.Text != "Browse To The Json File Location" &amp;&amp; cTextBox3.Text != "") button6.Enabled = false; } private void button1_Click(object sender, EventArgs e) { button1.Text = "Confirmed"; button1.Enabled = false; label1.Text = "Updating Settings File"; label1.Visible = true; if (label1.Visible == true) { button6.Enabled = false; button4.Enabled = false; button1.Enabled = false; } FileInfo fi = new FileInfo(AuthenticationFileName); if (fi.Length == 0) { w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("Api" + "=" + cTextBox1.Text); w.Close(); } else { w = new StreamWriter(AuthenticationFileName); w.WriteLine("Api" + "=" + cTextBox1.Text); w.Close(); } timer1.Start(); } private void button4_Click(object sender, EventArgs e) { button4.Enabled = false; label1.Text = "Updating Settings File"; label1.Visible = true; if (label1.Visible == true) { button6.Enabled = false; button4.Enabled = false; button1.Enabled = false; } w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("UserId" + "=" + cTextBox2.Text); w.Close(); timer1.Start(); } private void button6_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.Filter = "Json Files (*.json)|*.json"; openFileDialog1.FilterIndex = 0; openFileDialog1.RestoreDirectory = true; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { cTextBox3.BackColor = Color.White; cTextBox3.ForeColor = Color.Green; cTextBox3.Text = openFileDialog1.FileName; label1.Text = "Updating Settings File"; label1.Visible = true; if (label1.Visible == true) { button6.Enabled = false; button4.Enabled = false; button1.Enabled = false; } w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("JsonFileDirectory" + "=" + cTextBox3.Text); w.Close(); timer1.Start(); } } private void button2_Click(object sender, EventArgs e) { ResetValues(true); } int count = 0; private void timer1_Tick(object sender, EventArgs e) { count += 1; if (count == 2) { label1.Visible = false; timer1.Stop(); count = 0; } } private void Authentication_FormClosing(object sender, FormClosingEventArgs e) { ResetValues(false); } private void ResetValues(bool DeleteFile) { cTextBox1.Text = ""; cTextBox2.Text = ""; cTextBox3.Text = ""; button1.Text = "Confirm"; button4.Text = "Confirm"; button6.Enabled = true; timer1.Stop(); count = 0; if (DeleteFile == true) { if (File.Exists(AuthenticationFileName)) File.Delete(AuthenticationFileName); } Form1.AuthenticationValues.ApiKey = ""; Form1.AuthenticationValues.JsonFileDirectory = ""; Form1.AuthenticationValues.UserId = ""; if (Form1.AuthenticationValues.AuthenticationMenu.Enabled == false &amp;&amp; (Form1.lines.Length &lt; 3 &amp;&amp; Form1.lines.Length &gt; 0)) Form1.AuthenticationValues.AuthenticationMenu.Enabled = true; formclosed = true; } } } </code></pre> <p>The first problem is in the constructor when checking for the file existing:</p> <pre><code>if (!File.Exists(AuthenticationFileName)) File.Create(AuthenticationFileName); </code></pre> <p>This make the file to be busy in use. When later in my code i'm trying to use the file again to write to it i'm getting exception that the file is in use by another process.</p> <p>The second problem is in the 3 places i'm trying to write to the file. The first place:</p> <pre><code>w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("Api" + "=" + cTextBox1.Text); w.Close(); </code></pre> <p>Then under it in another place in the code i'm writing again to the file:</p> <pre><code>w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("UserId" + "=" + cTextBox2.Text); w.Close(); </code></pre> <p>And last:</p> <pre><code>w = new StreamWriter(AuthenticationFileName, true); w.WriteLine("JsonFileDirectory" + "=" + cTextBox3.Text); w.Close(); </code></pre> <p>The problems are first the file is busy in use since the checking if exist i'm doing in the constructor.</p> <p>The second problem is that i want to make that if in the file there is no line that start with "Api" then write the Api part:</p> <pre><code>w.WriteLine("Api" + "=" + cTextBox1.Text); </code></pre> <p>But if it does exist and the text is changed in the textBox cTextBox1.Text i want to write to the file the changed text to the place where the Api line is. And to append a new Api line.</p> <p>Same for all two other places i'm writing to the file. If i will make it all false not to appen when writing it will write one line each time and will overwrite the line. But if i'm doing true it will append many Api lines or many UserId lines. And i want each to time to replace the line with the textBox to overwrite only on this line but with the new text.</p> <p>If in cTextBox1 there is the text: Hello World Then i changed it to: Hello World Now Then replace the Api line Hello World with Hello World Now</p>
<c#><.net><winforms>
2016-04-06 18:24:48
LQ_CLOSE
36,461,085
C method gives warning: expression result unused and freezes
<p>I have small problem with my home task. I have to create a method that sums an array, but with specific, given step. I did something like this: </p> <pre><code>int sum_step(int t[], int size, int step) { int i; int sum = 0; for(i=0; i &lt; size; i+step) { sum += t[i]; } return sum; } </code></pre> <p>and console returns warning:</p> <pre><code>warning: expression result unused [-Wunused-value] i + step; ~ ^ ~~~~ </code></pre> <p>Someone knows what is wrong? Thank in advance!</p>
<c><compiler-warnings><gcc-warning>
2016-04-06 19:52:39
LQ_CLOSE
36,461,405
Issue of reading input from filepointer
I'm trying to do a DFS search on a given graph using the following code: #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <vector> #include <queue> typedef struct G{ int vertex1; int vertex2; float num; } graph; typedef struct adj{ std::vector<int> element; }adj; void dfs (int v, bool marked[], adj*p){ marked[v]=true; std::vector<int>::iterator i; for (i=p[v].element.begin(); i!=p[v].element.end();i++){ if (!marked[*i]){ dfs(*i, marked, p); } } } void Search(adj*p, int*tvertex){ bool *marked=new bool[*tvertex]; for (int v=0; v<*tvertex; v++){ marked[v]=false; q.push(v); } for (int v=0; v<*tvertex;v++){ if (marked[v]==false){ dfs(v, marked,p); while (!q.empty()){ bfs(v, marked,p, q); } } } } void buildadj(graph*g, adj*p, int * tvertex, int *edge ){ for (int e=0; e<*edge; e++){ p[g[e].vertex1].element.push_back(g[e].vertex2); p[g[e].vertex2].element.push_back(g[e].vertex1); } } void readInData(FILE *fp, graph*g, int *tvertex) { char buffer[500]; char *token; const char delimiters[] = " "; int i; int n; memset(buffer, 0, 499); for(i = 0;!feof(fp);) { i++; if (i>=2){ fscanf(fp, " %[^\n]", buffer); token = strtok(buffer, delimiters); n = (int) atoi(token); g[i-2].vertex1 = n; g[i-2].vertex2 = (int) atoi(strtok(NULL, delimiters)); g[i-2].num = (float)atof(strtok(NULL, delimiters)); } } } void readstrct(FILE *fp,int*edge, int*tvertex){ int i; int a[2]; while (EOF!=fscanf(fp, "%d\n", &a[i])) { i++; if(i>=2){ break; } } *tvertex=a[0]; *edge=a[1]; } void sendMessage() { char message[200]; sprintf(message, "Needs to be in this format:\n./exe_name NAME.txt\n"); printf("%s", message); } int main(int argc, char * argv[]) { FILE *fp; int edge; int tvertex; if(argc < 2) { printf("File not given\n"); sendMessage(); return 0; } fp=fopen(argv[1], "r"); if(fp == NULL) { printf("file not found\n"); sendMessage(); return 0; } readstrct(fp,&edge, &tvertex); graph *g=new graph[edge]; adj *p=new adj[tvertex]; readInData(fp, g, &tvertex); buildadj(g,p,&tvertex, &edge); Search(p,&tvertex); } The input is of the following form: 13 13 0 5 2.1 4 3 2.3 0 1 3.2 9 12 4.2 6 4 5.1 5 4 2.2 0 2 0.2 11 12 0.22 9 10 0.22 0 6 0.22 7 8 0.22 9 11 0.22 5 3 0.22 I intend to read the first two lines and returns the edges and vertex num in the 'readstruct' function. Line 3 and Line 15 are read in the readIndata function. The code is compling fine using g++. But gives segmentation fault when reading input. I tried to use gdb to debug and found that the code continues to read the file when it reaches line 15(or i=13) in readIndata function. Best
<c++><user-input><eof><scanf>
2016-04-06 20:12:46
LQ_EDIT
36,461,449
Why isn't this action abstract?
<p>I am having a hard time understanding why one of the Actions in a class is abstract and the Action in the other class not.</p> <p>Source code 1: (Error when compiling: <a href="https://gyazo.com/cd3c21a8562589451814903febaf89fe" rel="nofollow">https://gyazo.com/cd3c21a8562589451814903febaf89fe</a>)</p> <pre><code>import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Play extends JFrame{ Engine drawPanel = new Engine(); private int x = 0; private int y = 0; public int getX(){ return x; } public int getY(){ return y; } public Play(){ Action rightAction = new AbstractAction(){ public void actionPreformed(ActionEvent e){ x+=10; drawPanel.repaint(); } }; Action leftAction = new AbstractAction(){ public void actionPreformed(ActionEvent e){ x-=10; drawPanel.repaint(); } }; InputMap inputMap = drawPanel.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = drawPanel.getActionMap(); inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "rightAction"); actionMap.put("rightAction", rightAction); inputMap.put(KeyStroke.getKeyStroke("LEFT"), "leftAction"); actionMap.put("leftAction", leftAction); add(drawPanel); pack(); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(640, 480); setTitle("Game"); setLocationRelativeTo(null); setVisible(true); } public static void main(String[] args){ EventQueue.invokeLater(new Runnable(){ @Override public void run(){ new Play(); } }); } } </code></pre> <p>Source code 2:(The code that compiles just fine)</p> <pre><code>import java.awt.*; import java.awt.event.*; import javax.swing.*; public class KeyBidings extends JFrame { int x = 0; int y = 0; DrawPanel drawPanel = new DrawPanel(); public KeyBidings(){ Action rightAction = new AbstractAction(){ public void actionPerformed(ActionEvent e) { x +=10; drawPanel.repaint(); } }; InputMap inputMap = drawPanel.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = drawPanel.getActionMap(); inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "rightAction"); actionMap.put("rightAction", rightAction); add(drawPanel); pack(); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocationRelativeTo(null); setVisible(true); } private class DrawPanel extends JPanel { protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.GRAY); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Color.GREEN); g.fillRect(x, y, 50, 50); } public Dimension getPreferredSize() { return new Dimension(400, 200); } } public static void main(String[] args) { EventQueue.invokeLater(new Runnable(){ public void run(){ new KeyBidings(); } }); } } </code></pre>
<java><action>
2016-04-06 20:15:37
LQ_CLOSE
36,462,378
Evaluate expression in parentheses, in String
<p>In Java, if I have a string like <code>"(3+5)x + x^(6/2)"</code>, how could I replace all expressions in parentheses with their evaluations, to get the string <code>"8x + x^3"</code>?</p>
<java><string><parsing><replace>
2016-04-06 21:07:54
LQ_CLOSE
36,463,608
Go: invalid operation - type *map[key]value does not support indexing
<p>I'm trying to write a function that modifies original map that is passed by pointer but Go does not allow it. Let's say I have a big map and don't want to copy it back and forth.</p> <p>The code that uses passing by value is working and is doing what I need but involves passing by value (<a href="https://play.golang.org/p/-UUiJ9vbMa" rel="noreferrer">playground</a>):</p> <pre><code>package main import "fmt" type Currency string type Amount struct { Currency Currency Value float32 } type Balance map[Currency]float32 func (b Balance) Add(amount Amount) Balance { current, ok := b[amount.Currency] if ok { b[amount.Currency] = current + amount.Value } else { b[amount.Currency] = amount.Value } return b } func main() { b := Balance{Currency("USD"): 100.0} b = b.Add(Amount{Currency: Currency("USD"), Value: 5.0}) fmt.Println("Balance: ", b) } </code></pre> <p>But if I try to pass parameter as pointer like here (<a href="https://play.golang.org/p/kVCAt7074j" rel="noreferrer">playground</a>):</p> <pre><code>func (b *Balance) Add(amount Amount) *Balance { current, ok := b[amount.Currency] if ok { b[amount.Currency] = current + amount.Value } else { b[amount.Currency] = amount.Value } return b } </code></pre> <p>I'm getting compilation error:</p> <pre><code>prog.go:15: invalid operation: b[amount.Currency] (type *Balance does not support indexing) prog.go:17: invalid operation: b[amount.Currency] (type *Balance does not support indexing) prog.go:19: invalid operation: b[amount.Currency] (type *Balance does not support indexing) </code></pre> <p>How should I deal with this?</p>
<go><pass-by-reference>
2016-04-06 22:43:45
HQ
36,465,189
JSON Web Token (JWT) as a url for email activation
<p>How secure it is to make JWT as the activation url in email?</p> <p>For example: Click link to activate your account <a href="http://127.0.0.1:8000/account/activate/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cnVlLCJjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0.yRQYnWzskCZUxPwaQupWkiUzKELZ49eM7oWxAQK_ZXw" rel="noreferrer">http://127.0.0.1:8000/account/activate/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cnVlLCJjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0.yRQYnWzskCZUxPwaQupWkiUzKELZ49eM7oWxAQK_ZXw</a></p>
<jwt>
2016-04-07 01:34:35
HQ
36,465,224
how to pull up specific records in MySQL
I have some SQL i would like to pull up some records with a certain criteria please help, thank you :) **SQL Statement:** `SELECT b.*, e.Lastname, e.Firstname, e.ID_SC, e.Program, r.BReasonDetails FROM tblbadgetemporaryborrower b INNER JOIN (SELECT e.*, p.Program FROM tblemployee e INNER JOIN tblemployeeprogram p ON p.ID_P = e.ID_P) e ON e.EmployeeID = b.EmployeeID INNER JOIN tblbadgetemporaryborrowerreason r ON r.ID_BR = b.ID_BR HAVING e.ID_SC = {$_GET['ID_SC']} ORDER BY b.EmployeeID ASC` **Here's what i have:** **Q:** How can i pull up the employee data with `Lost` reason only [![enter image description here][1]][1] [1]: http://i.stack.imgur.com/vN6x0.png
<mysql>
2016-04-07 01:39:12
LQ_EDIT
36,465,836
MUST iOS live video use HLS?
<p>I'd like to make an app that can play live video and start to learn hls, rtmp, rtsp.But documentation of Apple require developer use hls for live video, or will be rejected for distribution.Does any one use rtmp in your app and success to sale in AppStore?</p>
<ios><rtmp><http-live-streaming>
2016-04-07 02:47:41
LQ_CLOSE
36,465,912
Local Server for Gaming C#
<p>[C#] Hello all, I am curious on how I can go about creating my own local server and allowing people outside to connect an return data stored on it. I am not looking for an "XNA" solution. I would like to kind of digest the bare bones of client to server. Here is an outline for what I am looking for:</p> <p>My PC [Server] -> Constantly Updates/Receives Player data so it can be obtained by other PC's. Stores data from other clients.</p> <p>[Client PC] -> Writes to server (Creates new player data/updates) and obtains further information to update visuals, other players, etc. </p>
<c#>
2016-04-07 02:55:30
LQ_CLOSE
36,466,092
Custom domain for API Gateway returning 403
<p>I am creating an api using API Gateway and Lambda. Using the url designated in the API Gateway Stage editor everything works fine; however, when I try and move to a custom domain I am running into some issues. </p> <p>The first thing I tried was using a CNAME record in Route 53 straight from my domain onto the domain that I got from the API Gateway. That was returning some errors and I think it is the incorrect solution is that correct?</p> <p>Next I tried the Custom Domain Names feature in API Gateway. My understanding is this will roll up a CloudFront distribution that I can then map onto from Route 53. When I created the custom domain and added a Domain Mapping it provides me with a url to what I assume is a CloudFront distribution. The link is returning a 403 response and no distribution has been made in CloudFront. What is a good way of debugging this problem?</p>
<amazon-web-services><amazon-cloudfront><aws-api-gateway>
2016-04-07 03:16:24
HQ
36,466,973
Why NSIndexPath length always show 2?
<p>I have created a NSIndexPath object but when I print the value of its length property it will always show the value as 2. </p> <pre><code> NSIndexPath *index = [NSIndexPath indexPathForItem:0 inSection:4]; </code></pre> <blockquote> <p> {length = 2, path = 4 - 0}</p> </blockquote> <p>Why length is always 2?</p>
<ios><nsindexpath>
2016-04-07 04:52:32
HQ
36,467,063
Can any one provide the code for merging two images in django
<p>I tried merging two images in django. But I am unsuccessful can any one please provide me code for merging two imges such that , one image should be placed on another and to be saved as .jpg. My mail id is srikanthmadireddy78@gamil.com</p>
<python><django>
2016-04-07 05:00:31
LQ_CLOSE
36,467,150
When using conemu with Windows 10 bash shell, why doesn't the UP key show the previous command?
<p>The up arrow scrolls through command history, but it doesn't work after I launch bash shell.</p>
<windows><bash><conemu>
2016-04-07 05:09:08
HQ
36,467,298
MySQL - Table 'my_table' was not locked with Lock Tables
<p>I try and load tables via MySQL and get the following error?</p> <blockquote> <p>MySQL said: Table 'cms' was not locked with LOCK TABLES</p> </blockquote> <p>Why does the table need to be Locked? I haven't seen this before? is there any way to unlock? do you even want to?</p>
<mysql>
2016-04-07 05:19:36
HQ
36,467,378
percentEven, won't compile
<p>So this is the percentEven method from the Java textbook. I cannot get it to compile and was wondering if you guys could see my mistake.</p> <p>"Write a method called "percentEven" that accepts an array of integers as a parameter and returns the percentage of even numbers in the array as a real number."</p> <p>that is the instructions. this is what I have so far.</p> <pre><code>import java.util.*; public class percentEven { public class void main ( String [] args ) { int [] integers = {34, 56, 4, 17, 9, 83, -300, 5}; int evenResult = percentEven (integers); System.out.println ( " The percent of even numbers is" + evenResult + "." ); } public class int percentEven ( int [] integers ) { int count = 0; int even = 0; for (i=0,i&lt;integers.length,i++){ if ( integers[i] % 2 == 0 ){ even++; } count++; } count= (even/count)*100; return count; } } </code></pre>
<java>
2016-04-07 05:26:12
LQ_CLOSE
36,467,445
what does the following Line of code do in javascript $('div[class^="remainingQtyErrMsg"]').hide();
<p>what does the following Line of code do in <strong>javascript/JQuery</strong>?</p> <pre><code>$('div[class^="remainingQtyErrMsg"]').hide(); </code></pre>
<javascript><jquery>
2016-04-07 05:31:08
LQ_CLOSE
36,467,469
Is key-value pair available in Typescript?
<p>Is key,value pair available in typescript? If yes how to do that. Can anyone provide sample example links.</p>
<typescript>
2016-04-07 05:33:02
HQ
36,467,974
php Difference between -> and
<p>I'm fairy new to php, but have a lot of OOP experience. I was just wondering why you do this in php.</p> <p>What I think your meant to do:</p> <pre><code>$example-&gt;functionName(); </code></pre> <p>What I thought you would've done:</p> <pre><code>$example.functionName(); </code></pre> <p>(Please tell me if Ive got it all wrong)</p> <p>So the question is, why do you use -> instead of . in php? Or is there no difference?</p>
<php>
2016-04-07 06:09:46
LQ_CLOSE
36,468,317
<layout> <Edittext hint='enter your text'/> <layout>layout tag android not working hint
<layout> <Edittext hint='enter your text'> </Edittext? </layout> when I am using data binding library with tab layout that time Edit text hint not hide after typing.
<android><android-edittext><hint>
2016-04-07 06:31:20
LQ_EDIT
36,468,509
Strange black box appearing in wpf application
<p><a href="https://i.stack.imgur.com/YUiOz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YUiOz.png" alt="enter image description here"></a></p> <p>Hi!</p> <p>I am new in wpf application development. I just create a demo application and I see that the black box appearing in the top of my application. Can anyone tell me how can I remove this ? </p> <p>I am sorry, I don't even know the name of it.</p>
<c#><wpf><user-interface>
2016-04-07 06:41:22
HQ
36,468,726
Get first and second element of array
<p>How I get first and second element in this array?</p> <p><a href="https://i.stack.imgur.com/hkxB5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hkxB5.png" alt="enter image description here"></a></p> <p>for example the first "AF" and second "Afghanistan", I need to put the value in html select tag</p>
<php><arrays><laravel>
2016-04-07 06:51:26
LQ_CLOSE
36,468,900
start rule: <select from navigator or grammar> in antlr plugin in IntelliJ
<p>I have created simple grammar file in IntelliJ but failing to see any effect of Antlr plugin. When I open file in ANTLR preview, it says </p> <pre><code>start rule: &lt;select from navigator or grammar&gt; </code></pre> <p><a href="https://i.stack.imgur.com/3vMgl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3vMgl.png" alt="enter image description here"></a></p> <p>What is start rule? How to select it from navigator? How to select it from grammar?</p>
<intellij-idea><antlr><antlr4>
2016-04-07 07:01:14
HQ
36,469,496
Laravel 5 Migration change length of existed column
<p>It not work, I search so many ways, How can I change length of value in laravel 5</p> <pre><code>public function up() { Schema::table('articles', function (Blueprint $table) { $table-&gt;string('name',50)-&gt;change(); }); } </code></pre> <p>Thank you all for reading!</p>
<laravel>
2016-04-07 07:30:44
HQ
36,469,631
How to get Leaflet for R use 100% of Shiny dashboard height
<p>I am in the process of creating a Shiny dashboard application, where the dashboard body is supposed to show some maps. So far no problem to get the map expand over the entire width of the body, but it's somehow not willing to adjust to the full height. <a href="https://i.stack.imgur.com/jxEEI.png"><img src="https://i.stack.imgur.com/jxEEI.png" alt="enter image description here"></a></p> <p>The leaflet itself is already set to cover 100% of the height, but it doesn't do the trick. As soon as I use the height attribute for the leafletOutput the leaflet object will not show at all, and I am left with an empty box.</p> <p>The code can be found below:</p> <pre><code>library(shinydashboard) library(leaflet) ui &lt;- dashboardPage( dashboardHeader(title = "Basic dashboard"), dashboardSidebar( sidebarMenu( menuItem( "Maps", tabName = "maps", icon = icon("globe"), menuSubItem("Watersheds", tabName = "m_water", icon = icon("map")), menuSubItem("Population", tabName = "m_pop", icon = icon("map")) ), menuItem( "Charts", tabName = "charts", icon = icon("bar-chart"), menuSubItem("Watersheds", tabName = "c_water", icon = icon("area-chart")), menuSubItem("Population", tabName = "c_pop", icon = icon("area-chart")) ) ) ), dashboardBody( tabItems( tabItem( tabName = "m_water", box( title = "Baltic catchment areas", collapsible = TRUE, width = "100%", height = "100%", leafletOutput("l_watershed") ) ), tabItem( tabName = "m_pop", # Map in Dashboard leafletOutput("l_population") ), tabItem( tabName = "charts", h2("Second tab content") ) ) ) ) server &lt;- function(input, output) { set.seed(122) histdata &lt;- rnorm(500) output$l_watershed &lt;- renderLeaflet({ leaflet(height = "100%") %&gt;% addTiles() %&gt;% setView(19.08, 60.25, zoom = 4) %&gt;%addWMSTiles( "http://62.236.121.188/arcgis/services/DataAndMaps/Background/MapServer/WMSServer?", layers = "11", options = WMSTileOptions( format = "image/png", transparent = TRUE ), attribution = "Catchment area provided by HELCOM" ) }) output$l_population &lt;- renderLeaflet({ leaflet(height = "100%") %&gt;% addTiles() %&gt;% setView(19.08, 60.25, zoom = 4) %&gt;%addWMSTiles( "http://62.236.121.188/arcgis/services/DataAndMaps/Background/MapServer/WMSServer?", layers = "17", options = WMSTileOptions( format = "image/png", transparent = TRUE ), attribution = "Population data provided by HELCOM" ) }) } shinyApp(ui, server) </code></pre>
<r><shiny><leaflet><shinydashboard>
2016-04-07 07:37:54
HQ
36,469,693
Allow AlfaNumeric and other symbol using javascipt
I have use this code for allow numeric only in textbox, but how make Caharkey only allow AlfaNumeric and other symbol like **-./** (dash,dot,slash) this my code for allow Numeric function NumericKey(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } thankyou
<javascript>
2016-04-07 07:41:23
LQ_EDIT
36,469,722
RestAssured: How to check the length of json array response?
<p>I have an endpoint that returns a JSON like:</p> <pre><code>[ {"id" : 4, "name" : "Name4"}, {"id" : 5, "name" : "Name5"} ] </code></pre> <p>and a DTO class:</p> <pre><code>public class FooDto { public int id; public String name; } </code></pre> <p>Now, I'm testing the length of the returned json array this way:</p> <pre><code>@Test public void test() { FooDto[] foos = RestAssured.get("/foos").as(FooDto[].class); assertThat(foos.length, is(2)); } </code></pre> <p>But, is there any way to do it without cast to FooDto array? Something like this:</p> <pre><code>@Test public void test() { RestAssured.get("/foos").then().assertThat() .length(2); } </code></pre>
<json><rest-assured>
2016-04-07 07:42:47
HQ
36,470,475
Using a function to return a value on a plotLine [HighCharts]
<p>I want to return a value in form of a plotLine in my chart.</p> <pre><code>plotLines: [{ color: 'red', value: resp.data.res0.map(function(a){ sum += parseInt(a[1]); return sum; }), width: '1', zIndex: 2 }] }, </code></pre> <p>The value of sum here is not that important, just that it is a number. But I am not sure how I am supposed to render it to the chart. The response in a[1] is JSON.</p>
<javascript><json><highcharts>
2016-04-07 08:18:45
LQ_CLOSE
36,470,840
what is the advantage of using Alamofire over NSURLSession/NSURLConnection for networking?
<p>Can anyone help me in understanding these question : What is the advantage of using Alamofire over NSURLSession/ NSURLConnection? </p> <p>What are the differences between NSURLSession and NSURLConnection?</p>
<nsurlconnection><alamofire><nsurlsession><mobile-application>
2016-04-07 08:36:28
HQ
36,470,936
How to get "v.3.1.2" in string by regex php
<p>I need get "v3.4.2" in string by regex php. String: "ABCDEF v3.4.2 GHI KLMN";</p>
<php><regex>
2016-04-07 08:41:09
LQ_CLOSE
36,471,077
What does HTTP/2 mean for a reverse proxy server?
<p>How HTTP/2 affects the implementation of a proxy server? Especially, for example, when a client sends an HTTP/2 request to a content server that only supports HTTP/1.x, should the proxy server tranform the HTTP/2 request to HTTP/1.x request before directing the client request to the content server? And upon receiving response from the content server, should the proxy server transform the response to the HTTP/2 format before sending it back to the client?</p>
<reverse-proxy><http2>
2016-04-07 08:47:24
HQ
36,471,101
C++ doesn't tell you the size of a dynamic array. But why?
<p>I know that there is no way in C++ to obtain the size of a dynamically created array, such as:</p> <pre><code>int* a; a = new int[n]; </code></pre> <p>What I would like to know is: Why? Did people just forget this in the specification of C++, or is there a technical reason for this?</p> <p>Isn't the information stored somewhere? After all, the command</p> <pre><code>delete[] a; </code></pre> <p>seems to know how much memory it has to release, so it seems to me that <code>delete[]</code> has some way of knowing the size of <code>a</code>.</p>
<c++><dynamic-arrays>
2016-04-07 08:48:28
HQ
36,471,464
How to get handle of MessageBox in order to change font of MessageBox c++ builder
*I'm using c++ builder (bcb6) I would like change the font of MessageBox. I searched over google and find that it's possible to use by WM_SETFONT. My question is how can I get the handle of the MessageBox? HFONT hFont=CreateFont(18,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Courier New")); MessageBox(NULL,message.c_str(),"Info",MB_OK | MB_ICONINFORMATION); SendMessage(??handle of the message box??, WM_SETFONT,(WPARAM) hFont, MAKELPARAM(TRUE, 0)); Any suggestions please? Your help is very appreciated.
<c++><winapi><fonts><c++builder-6>
2016-04-07 09:05:26
LQ_EDIT
36,471,869
Rendering a string as React component
<p>I want to render the react components with a string as the input which i am receiving dynamically from another page. BUt i will have the references for the react components. Here is the example</p> <pre><code>Page1: ----------------------------- loadPage('&lt;div&gt;&lt;Header value=signin&gt;&lt;/Header&gt;&lt;/div&gt;'); Page2: -------------------------------- var React =require('react'); var Header = require('./header'); var home = React.createClass({ loadPage:function(str){ this.setState({ content : str }); }, render : function(){ return {this.state.content} } }); </code></pre> <p>In this example i am receiving Header component as string , and i have the reference of Header component in my receiving page . How can i substitute the string with the actual react component</p>
<reactjs>
2016-04-07 09:23:40
HQ
36,472,186
Abstract methods in Swift?
<p>I have few questions for Swift developers regarding the concept of abstract classes.</p> <ol> <li><strong>How do you define an abstract class in Swift?</strong> Is there any way to prevent a class from being instantiated, while providing an initializer for its subclasses to use?</li> <li><strong>How do you define abstract methods, while implementing others?</strong> When defining abstract methods, Apple generally points you to protocols (interfaces). But they only solve the first part of my question, since <em>all</em> of the methods they define are abstract. What do you do when you want to have both abstract and non-abstract methods in your class?</li> <li><strong>What about generics?</strong> You might have thought about using protocols together with extensions (categories). But then there is an issue with generics because protocols can't have generic types, only <em>typealiases</em>.</li> </ol> <p>I have done my homework and I know about solving these issues using methods, such as <code>fatalError()</code> or <code>preconditionFailure()</code> in the superclass and then overriding them in a base class. But that seems like <em>ugly</em> object design to me.</p> <p>The reason I'm posting this is to find out whether there exists more general and universal solution.</p> <p>Thanks in advance, Petr.</p>
<swift><abstract-class><abstract>
2016-04-07 09:35:29
HQ
36,472,648
Sqlsrv for PHP 5.6 on WAMP server
<p>After looking so many posts about this problem, I don't understand why it don't work because it should be working. I will post all the information I have so far:</p> <ul> <li><p>Windows 10 64-bit</p></li> <li><p>WampServer 3 64-bit (<a href="http://www.wampserver.com/" rel="noreferrer">http://www.wampserver.com/</a>)</p></li> <li><p>PHP 5.6.16 </p></li> <li><p>Apache 2.4.17 </p></li> <li>Microsoft SQL Server 2016</li> </ul> <p>I downloaded SQLSRV32.exe from microsoft. I extracted the dll files to C:\wamp\bin\php\php5.6.16\ext.</p> <p>In my php.ini given by wampserver:</p> <ul> <li><p>extension_dir = "c:/wamp/bin/php/php5.6.16/ext/"</p></li> <li><p>extension=php_sqlsrv_56_ts.dll</p></li> <li><p>extension=php_pdo_sqlsrv_56_ts.dll</p></li> </ul> <p>I have php5ts.dll in my php5.6.16 folder, so I think I have thread safe which is why I am using ts.dll ones.</p> <p>If I'm in phpinfo() I should see a 'sqlsrv' section in there, but I don't see one, so I guess I did something wrong here somewhere?</p> <p>I even did restart on wampserver many times and run as an administrator. It still don't show up on phpinfo()... But I can see this in php extension at the Wampserver: <a href="https://i.stack.imgur.com/Rf2bk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Rf2bk.png" alt="Extension showed up here"></a></p> <p>Any ideas to what I did wrong or why it don't show up in phpinfo()?</p>
<php><sql-server><apache><dll><wampserver>
2016-04-07 09:56:05
HQ
36,472,969
Php get parameter from SEO URL
<p>I have my seo url such as</p> <blockquote> <p><a href="http://domain.com/product/export-grade-large-size-3-tier-organizer-shelf-and-non-woven-storage-box-with-cover-21665223" rel="nofollow">http://domain.com/product/export-grade-large-size-3-tier-organizer-shelf-and-non-woven-storage-box-with-cover-21665223</a></p> </blockquote> <p>at the tail of string there is a number represented an id, which I need it for DB processing, how can I separate and get the last id? I cannot use explode because it may have long string parameter with 'dash'.</p> <p>thanks. </p>
<php><friendly-url>
2016-04-07 10:07:52
LQ_CLOSE
36,473,418
string concatenation with property binding in angular2
<p>in Angular 2 we have several way to create property bindings in templates. I could do something like this:</p> <pre><code>&lt;li *ngFor="#course of courses; #i = index" id="someselector-{{i}}"&gt;{{course}}&lt;/li&gt; </code></pre> <p>Is it possible to obtain the same result using the square brakets syntax?</p> <pre><code>&lt;li *ngFor="#course of courses; #i = index" [id]="someselector-i"&gt;{{course}}&lt;/li&gt; ^^^^^^^ how create string concatenation? </code></pre> <p>Thanks, G.</p>
<javascript><angular2-template>
2016-04-07 10:26:46
HQ
36,473,731
C# Display questions and wait for reponce
I am writing a program that reads a question document (example below) and presents the question and answers in an appropriate way. But my question is how do i get my program to display one question and then wait for the answer before then displaying the next. The answers are displayed using the method Display*Questiontype*(?). eg DisplayMultipleChoice(Question,CAnswer,Ianswer1,Ianswer2,Ianswer3). Question Document; & Multiple choice question <br/> ~ Correct Answer <br/> - Incorrect Answer <br/> - Incorrect Answer <br/> - Incorrect Answer <br/> ? Textbox answer question <br/> ~Correct Answer <br/> $ Webpage Question <br/> @ Webpage <br/>
<c#><wpf>
2016-04-07 10:40:34
LQ_EDIT
36,473,884
how to delete all lines after a certain string in a file and then add some more lines using python
<p>I want to delete all the lines in a file smart.txt and then add some strings of my own. smart.txt contains alot of lines.</p> <p>I tried</p> <pre><code>import sys import os output=[] f= open(smart.txt, 'r') for line in f: output.append(line) if '*** P R O P E R T I E S ***' in line: break f=open(smart.txt, 'w') [f.write(data) for data in output] f.write('*** Inclusions ***\n ') f.write('*** Permanent ***\n ') f.close() </code></pre> <p>I am getting an error</p> <pre><code>f= open(smart.txt, 'r') NameError: name 'smart' is not defined </code></pre> <p>cannot figure out because smart.txt is present in the same directory.</p> <p>Any suggestions?</p>
<python><linux><append>
2016-04-07 10:47:06
LQ_CLOSE
36,474,120
How to make multiple request and wait until data is come from all the requests in retrofit 2.0 - android
<p>current code:</p> <pre><code>Retrofit retrofit = new Retrofit.Builder() .baseUrl(Constant.BASEURL) .addConverterFactory(GsonConverterFactory.create()) .build(); APIService service = retrofit.create(APIService.class); Call&lt;ResponseWrap&gt; call = service.getNewsData(); call.enqueue(new Callback&lt;ResponseWrap&gt;() { @Override public void onResponse(Call&lt;ResponseWrap&gt; call1, Response&lt;ResponseWrap&gt; response) { if (response.isSuccess()) { ResponseWrap finalRes = response.body(); for(int i=0; i&lt;finalRes.getResponse().getResults().size(); ++i){ String title = finalRes.getResponse().getResults().get(i).getWebTitle(); News n = new News(titleCategory, title, null); newsList.add(n); } AdapterRecommendation adapter = new AdapterRecommendation(getApplicationContext(), newsList); listView.setAdapter(adapter); } else{ Toast.makeText(getApplicationContext(), "onResponse - something wrong" + response.message(), Toast.LENGTH_LONG).show(); } } @Override public void onFailure(Call&lt;ResponseWrap&gt; call1, Throwable t) { Toast.makeText(getApplicationContext(), "exception: " + t.getMessage(), Toast.LENGTH_LONG).show(); } }); </code></pre> <p>works fine.</p> <p>Now i want to make multiple calls (number of call will be decided at run time) and all calls gives data in same format. data from all calls needs to be add to newsList. Once data is available from all calls and added to newsList, call</p> <pre><code>AdapterRecommendation adapter = new AdapterRecommendation(getApplicationContext(), newsList); listView.setAdapter(adapter); </code></pre> <p>Can anyone help me what is the best way to get data from multiple calls and wait until all request is not over in retrofit 2.0.</p>
<android><retrofit2>
2016-04-07 10:56:32
HQ
36,474,303
Pulling double inverted commas from the database
<p>I need some assistance. I have a table and I am loading info to it from the database, everything loads how it is in the database but as soon as I want to edit a row with a value that has a double inverted comma in it for eg: 40" Samsung. What it will do when I want to edit it it will show the 40 but everything after the 40 wont appear.</p> <p>How my edit works, I have checkbox in on column of the table linked to its row so when I tick the check box and I select edit all the information on that row(s) will be present on their respected textboxes and I edit the info and click save. If I add any character it will save exactly as I typed into the database but if on of the columns contains a double inverted comma it shows everything before the inverted comma, example: 40" Samsung will show the 40 but everything after the zero won't show.</p> <p>Please help</p>
<php>
2016-04-07 11:04:22
LQ_CLOSE
36,475,088
Dynamically generate html files to display image and video
<p>I am uploading some images and videos to upload folder and then I display those to my webpage using array. that takes extra load on browser. so I want when I upload any image/video to upload folder it should create dynamic html or php file to display for each image/video. Can anyone tell me how to do?</p>
<javascript><php><html>
2016-04-07 11:38:51
LQ_CLOSE
36,475,859
Error when making my own stack
<p>So for learning python and just in general some data structures, I am creating a Stack to start with. This is a simple <strong>array-based</strong> stack.</p> <p>Here is my code:</p> <pre><code>class ArrayBasedStack: 'Class for an array-based stack implementation' def __init__(self): self.stackArray = [] def pop(): if not isEmpty(): # pop the stack array at the end obj = self.stackArray.pop() return obj else: print('Stack is empty!') return None def push(object): # push to stack array self.stackArray.append(object) def isEmpty(): if not self.stackArray: return True else: return False ''' Testing the array-based stack ''' abs = ArrayBasedStack() abs.push('HI') print(abs.pop()) </code></pre> <p>But I'm getting this error:</p> <blockquote> <p>Traceback (most recent call last):</p> <p>File "mypath/arrayStack.py", line 29, in abs.push('HI')</p> <p>TypeError: push() takes 1 positional argument but 2 were given [Finished in 0.092s]</p> </blockquote>
<python>
2016-04-07 12:14:09
LQ_CLOSE
36,476,383
Cannot concatenate 'str' and 'int' objects. Python
<pre><code>if int(gtin) == barcode[1]: print "You have ordered", item[1] **quantity1 = raw_input("Please select a quantity of 100mm bolts") quantitybolt = int(quantity1) quantity1 += quantitybolt** </code></pre> <p>TypeError:cannot concatenate 'str' and 'int' objects. Python</p> <p>Please help :) </p>
<python><string><int>
2016-04-07 12:35:34
LQ_CLOSE
36,476,402
How to import moment.js in ES6 using npm?
<p>I am using angular js and nodejs along with ES6. I want to import the moment.js in the angular js code. I did <code>'npm install moment --save'</code></p> <p>Now I am able to see moment.js file in moment folder which is inside node modules. </p> <p>and in my app.js file I have wriiten like this</p> <pre><code>'import moment from 'moment'; </code></pre> <p>But if search something with date range It is showing error in console. Can anybody help me how to do this..?</p>
<javascript><angularjs><node.js><ecmascript-6>
2016-04-07 12:36:18
HQ
36,476,751
Associate a color palette with ggplot2 theme
<p>I want my ggplot2 theme to use a specific set of colors, but don't see how to avoid a separate line outside of the theme.</p> <p>I have this data:</p> <pre><code>library(ggplot2) mycars &lt;- mtcars mycars$cyl &lt;- as.factor(mycars$cyl) </code></pre> <p>And here's a dummy theme I plot with:</p> <pre><code>mytheme &lt;- theme(panel.grid.major = element_line(size = 2)) ggplot(mycars, aes(x = wt, y = mpg)) + geom_point(aes(color = cyl)) + mytheme </code></pre> <p><a href="https://i.stack.imgur.com/sQaY2m.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sQaY2m.png" alt="without custom colors"></a></p> <p>I want the point colors to default to my custom palette:</p> <pre><code>mycolors &lt;- c("deeppink", "chartreuse", "midnightblue") </code></pre> <p>Can I somehow add that to my ggplot2 theme so that I don't constantly repeat this extra line of code at the end:</p> <pre><code>ggplot(mycars, aes(x = wt, y = mpg)) + geom_point(aes(color = cyl)) + mytheme + scale_color_manual(values = mycolors) </code></pre> <p><a href="https://i.stack.imgur.com/wy6SCm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wy6SCm.png" alt="with colors"></a></p> <p>I tried:</p> <pre><code>mytheme2 &lt;- mytheme + scale_color_manual(values = mycolors) </code></pre> <p>But got:</p> <blockquote> <p>Error: Don't know how to add scale_color_manual(values = mycolors) to a theme object</p> </blockquote>
<r><ggplot2>
2016-04-07 12:51:06
HQ
36,477,145
how to upload image file and display using express nodejs
<p>I have used following code :</p> <p>fileupload.html</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;File Uploading Form&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h3&gt;File Upload:&lt;/h3&gt; Select a file to upload: &lt;br /&gt; &lt;form action="http://127.0.0.1:8081/file_upload" method="POST" enctype="multipart/form-data"&gt; &lt;input type="file" name="file" size="50" /&gt; &lt;br /&gt; &lt;input type="submit" value="Upload File" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>fileupload.js:</p> <pre><code>var express = require('express'); var app = express(); var fs = require("fs"); var bodyParser = require('body-parser'); var multer = require('multer'); //console.log(multer); app.use(express.static('public')); app.use(bodyParser.urlencoded({ extended: false })); app.use(multer({ dest: '/tmp/'})); app.get('/fileupload.html', function (req, res) { res.sendFile( __dirname + "/" + "fileupload.html" ); }) app.post('/file_upload', function (req, res) { console.log(req.files.file.name); console.log(req.files.file.path); console.log(req.files.file.type); var file = __dirname + "/" + req.files.file.name; fs.readFile( req.files.file.path, function (err, data) { fs.writeFile(file, data, function (err) { if( err ){ console.log( err ); }else{ response = { message:'File uploaded successfully', filename:req.files.file.name }; } console.log( response ); res.end( JSON.stringify( response ) ); }); }); }) var server = app.listen(8081, function () { var host = server.address().address var port = server.address().port console.log("Example app listening at http://%s:%s", host, port) }) </code></pre> <p>I have used these above code for file uploading But when excute using node fileupload.js in terminal i am getting type error <code>TypeError('app.use() requires middleware functions');</code> </p> <p>Can any one help to resolved this problem.</p>
<javascript><node.js><file-upload>
2016-04-07 13:06:18
HQ
36,477,444
Java Object return type vs. Generic Methods
<p>I saw several questions about generic return type, but none answers my question. <br>If there is no bound for any of the arguments, such as the following method in <a href="https://github.com/jayway/JsonPath/blob/master/json-path/src/main/java/com/jayway/jsonpath/JsonPath.java">JayWay</a> :</p> <pre><code>public static &lt;T&gt; T read(String json, String jsonPath, Filter... filters) { return new JsonReader().parse(json).read(jsonPath, filters); } </code></pre> <p>What is the point of using this as generic ?<br> I told the guys from my team that this method should be used as :</p> <pre><code>JsonPath.&lt;Boolean&gt;read(currentRule, "$.logged") </code></pre> <p>instead of:</p> <pre><code>(boolean) JsonPath.read(currentRule, "$.logged") </code></pre> <p>But I really can't tell the difference...</p>
<java><generics>
2016-04-07 13:18:29
HQ
36,478,901
Switching from native iOS gui to Qt gui
<p>I currently have a native iOS GUI and a Qt-GUI. I'm trying to switch from one to another.</p> <p>To be clear: When i click on a button on the native GUI i want the Qt-GUI to show up and vice versa.</p> <p>I already found out which libraries i have to add to be able to use the Qt-Stuff. I created a <code>QApplication</code> in the <code>AppDelegate.mm</code> file:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions { // receive int argc, and char** argv for the QApplication. _qApp = new QApplication(_argc, _argv); } </code></pre> <p>Furthermore my Qt application looks (at the moment) like this:</p> <pre><code>void createQtGUI() { QPushButton* btn = new QPushButton("Some Button"); QLabel* lbl = new QLabel("QTGui"); QVBoxLayout* layout = new QVBoxLayout(); layout-&gt;addWidget(lbl); layout-&gt;addWidget(btn); QWidget* window = new QWidget(); window-&gt;setLayout(layout); window-&gt;show(); } </code></pre> <p>I'm calling the <code>createQtGUI</code> method in my <code>ViewController.mm</code> when pressing a button in the native iOS GUI. The code runs without throwing any error, but:</p> <p><strong>The Qt-GUI is not shown. The application still shows the native gui without switching to the Qt-GUI.</strong></p> <p>Has anybody got any idea how to fix that?</p>
<c++><ios><objective-c><qt>
2016-04-07 14:14:55
HQ
36,478,906
What is the working logic of '==' while comparing two objects?
<p>What logic works when we compare two objects using '==' ? This logic is written in which file ? FYI I am aware that JVM checks if both reference variable point to the same object; I want to know what code must be there to determine if both reference point to same object ?</p>
<java>
2016-04-07 14:15:07
LQ_CLOSE
36,478,925
Why is AppTheme.NoActionBar not working?
<p>I've created an Android app in Android Studio, and it has created these styles by default:</p> <pre><code>&lt;style name="AppTheme.NoActionBar"&gt; &lt;item name="windowActionBar"&gt;false&lt;/item&gt; &lt;item name="windowNoTitle"&gt;true&lt;/item&gt; &lt;/style&gt; </code></pre> <p>However, in an activity, I try to set this as a theme:</p> <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" ... android:theme="@style/AppTheme.NoActionBar"&gt; </code></pre> <p>But when I run the app I'm getting the action bar:</p> <p><a href="https://i.stack.imgur.com/dVFTn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dVFTn.png" alt="enter image description here"></a></p> <p>Why am I getting an action bar? Am I doing something obviously wrong, or is Android Studio, Google's official IDE for it's own platform, trying to confuse/mislead its developers?</p> <p>Here is my activity code, there's nothing in it that can cause the action bar to appear by itself:</p> <pre><code>public class WelcomeActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); setContentView(R.layout.activity_welcome); } } </code></pre>
<android><android-studio><android-actionbar><android-studio-2.0>
2016-04-07 14:16:14
HQ
36,479,159
Why are numpy calculations not affected by the global interpreter lock?
<p>I'm trying to decide if I should use multiprocessing or threading, and I've learned some interesting bits about the <a href="https://wiki.python.org/moin/GlobalInterpreterLock" rel="noreferrer">Global Interpreter Lock</a>. In this nice <a href="http://nathangrigg.net/2015/04/python-threading-vs-processes/" rel="noreferrer">blog post</a>, it seems multithreading isn't suitable for busy tasks. However, I also learned that some functionality, such as I/O or numpy, is unaffected by the GIL.</p> <p>Can anyone explain why, and how I can find out if my (probably quite numpy-heavy) code is going to be suitable for multithreading?</p>
<python><multithreading><numpy><multiprocessing><gil>
2016-04-07 14:24:39
HQ
36,479,963
The number of registers in CUDA CC 5.0?
I have a GeForce GTX 745 (CC 5.0). The deviceQuery command shows that the total number of registers available per block is 65536 (65536 * 4 / 1024 = 256KB) I wrote a kernel that uses an array of size 10K and the kernel is invoked as following. I tried two ways to allocated the array: // using registers fun1() { short *arr = new short[100*100]; // 100*100*sizeof(short)=256K / per thread .... delete[] arr; } fun1<<<4, 64>>>(); // using global memory fun2(short *d_arr) { ... } fun2<<<4, 64>>>(d_arr); I can get the correct result in both manner. The first one which uses registers runs much faster. But when invoking the kernel using 6 blocks i got the wrong answer. fun1<<<6, 64>>>(); Now i'm wondering actually how many of registers can i use? And how is it related to the number of blocks ?
<cuda><gpu>
2016-04-07 14:57:15
LQ_EDIT
36,480,978
Equals method in OCPJP
Hi I have encountered an OCPJP question that I cannot understand. Following is the question.. [![enter image description here][1]][1] [1]: http://i.stack.imgur.com/UCdL9.png The answer provided is (B). Need a explanation on the answer. Thanks in advance.
<java><hashcode>
2016-04-07 15:38:48
LQ_EDIT
36,481,124
Why Eclipse give me errors on the break statments of this switch case structure?
<p>I have created this <strong>switch case</strong> structure in a Java program but Eclipse sign me errors on all the <strong>break</strong> statments:</p> <pre><code>public class LoadPlacesService { public String getPlaces(String source, String selval) { switch(source) { case "country": if (selval.equals("italy")) { return "&lt;option value='marche'&gt;Marche&lt;/option&gt;\n&lt;option value='lazio'&gt;Lazio&lt;/option&gt;\n&lt;option value='lombardia'&gt;Lombardia&lt;/option&gt;\n&lt;option value='puglia'&gt;Puglia&lt;/option&gt;"; } else { return "0"; } break; case "region": if (selval.equals("lazio")) { return "&lt;option value='roma'&gt;Roma&lt;/option&gt;\n&lt;option value='viterbo'&gt;Viterbo&lt;/option&gt;\n&lt;option value='latina'&gt;Latina&lt;/option&gt;\n&lt;option value='rieti'&gt;Rieti&lt;/option&gt;\n&lt;option value='frosinone'&gt;Frosinone&lt;/option&gt;"; } else { return "0"; } break; // eventuali altri case case "district": if (selval.equals("roma")) { return "&lt;option value='roma'&gt;Roma&lt;/option&gt;\n&lt;option value='guidonia-montecelio'&gt;Guidonia Montecelio&lt;/option&gt;\n&lt;option value='fiumicino'&gt;Fiumicino&lt;/option&gt;\n&lt;option value='aprilia'&gt;Aprilia&lt;/option&gt;"; } else { return "0"; } break; } return ""; } } </code></pre>
<java><switch-statement>
2016-04-07 15:43:58
LQ_CLOSE
36,483,661
Best way to find duplicates from two List
<p>In Java, I have two ArrayLists:</p> <pre><code>A = [Ab, cd, df, FE, ...] B = [ab, cde, de, fE, ...] </code></pre> <p>If the lists are a little big, the brute force method is very slow:</p> <pre><code>for(String a : A) { for(String b : B) { if(a.equalsIgnoreCase(b)) { System.out.println("duplicate: " + a "-&gt;" + b); } } } </code></pre> <p>What's the best way to make it faster, but not super complicated to implement? </p>
<java><algorithm>
2016-04-07 17:50:06
LQ_CLOSE
36,483,928
A Python implementation of GitHub flavored markdown
<p>I've been searching for a while now but still can't find anything. I basically need a Python converter for Github flavored markdown, that supports syntax highlighting. I currently use <a href="https://github.com/stewart/gfm" rel="nofollow">gfm</a>, however, that doesn't seem to support syntax highlighting. Not only it doesn't color it, it also does weird things with the code and puts it all on one line.</p>
<python><markdown><github-flavored-markdown>
2016-04-07 18:04:13
LQ_CLOSE
36,484,238
Pointers give seg fault
<p>here's the program</p> <pre><code> #include &lt;iostream&gt; #include &lt;time.h&gt; #include &lt;conio.h&gt; #include &lt;cstdlib&gt; #include &lt;windows.h&gt; using namespace std; const int widht = 117,height = 26; class Paddle { private: int y; int originalY; public: Paddle() { y=height/2-2; originalY=y; } inline int getY() { return y; } inline void moveUp() { y--; } inline void moveDown() { y++; } void checkWall() { if (y&lt;0) { while (y&lt;0) { y++; } } else if (y&gt;height) { while (y&gt;height) { y--; } } } void Reset() { y=originalY; } }; class Ball { private: int x,y; int originalX,originalY; public: Ball() { x=widht/2; y=height/2; originalX=x; originalY=y; } inline int getX() { return x; } inline int getY() { return y; } inline void moveRight() { x++; } inline void moveUpRight() { x++; y--; } inline void moveDownRight() { x++; y++; } inline void moveLeft() { x--; } inline void moveUpLeft() { y--; x--; } inline void moveDownLeft() { y++; x--; } inline void Reset() { x=originalX; y=originalY; } }; class Manager { private: int score1,score2; int columns, rows; public: int p1y; int p2y; int ballX,ballY; bool gameOver; Manager() { gameOver = false; } void Draw(Paddle *p1,Paddle *p2,Ball *b) { system("cls"); p1y=p1-&gt;getY(); p2y=p1-&gt;getY(); ballX=b-&gt;getX(); ballY=b-&gt;getY(); for (int i=0;i&lt;height;i++) { for (int j=0;j&lt;widht;j++) { if (i==p1y &amp;&amp; j==2) { cout &lt;&lt; "\xDB"; } else if (i==p1y+1 &amp;&amp; j==2) { cout &lt;&lt; "\xDB"; } else if (i==p1y+2 &amp;&amp; j==2) { cout &lt;&lt; "\xDB"; } else if (i==p1y+3 &amp;&amp; j==2) { cout &lt;&lt; "\xDB"; } else if (i==p1y+4 &amp;&amp; j==2) { cout &lt;&lt; "\xDB"; } else if (i==p2y &amp;&amp; j==widht-1) { cout &lt;&lt; "\xDB"; } else if (i==p2y+1 &amp;&amp; j==widht-1) { cout &lt;&lt; "\xDB"; } else if (i==p2y+2 &amp;&amp; j==widht-1) { cout &lt;&lt; "\xDB"; } else if (i==p2y+3 &amp;&amp; j==widht-1) { cout &lt;&lt; "\xDB"; } else if (i==p2y+4 &amp;&amp; j==widht-1) { cout &lt;&lt; "\xDB"; } else if (i==ballX &amp;&amp; j==ballY) { cout &lt;&lt; "O"; } cout &lt;&lt; " "; } cout &lt;&lt; endl; } cout &lt;&lt; p1 -&gt; getY(); } void Input(Paddle *p1,Paddle *p2) { if (_kbhit()) { switch(_getch()) { case 'w': p1-&gt;moveUp(); break; case 's': p1-&gt;moveDown(); break; case 'i': p2-&gt;moveUp(); break; case 'k': p2-&gt;moveDown(); break; } } } void Run(Paddle *p1,Paddle *p2, Ball *b) { while(!gameOver) { Draw(p1,p2,b); Input(p1,p2); Sleep(10); } } }; int main() { Paddle *p1; Paddle *p2; Ball *b; Manager *m; m-&gt;Run(p1,p2,b); return 0; } </code></pre> <p>I can't understand why when i launch the program it give (with the debugger) segmentation fault. I think cause are pointers, because before it worked perfectly(but without modifiyng values); Hae any tips?</p>
<c++>
2016-04-07 18:21:10
LQ_CLOSE
36,484,324
R Macro with Iteration through URL
Having a problem creating a macro variable within an API call in R. I am trying to loop through a vector of zip codes and make an API call on that vector iteratively. Pretty unfamiliar with iterating through a R list that needs to be macro'd out. Familiar with sas macros where I'd Here is my code: #creating a dataframe of 10 sample California zip codes to iterate through from database zip_iterations<-sqlQuery(ch,"Select distinct zip from zip_codes where state='CA' limit 10",believeNRows="F") #Calling the api to retrieve the JSON json_file <- "http://api.openweathermap.org/data/2.5/weather?zip=**'MACRO VECTOR TO ITERATE'** My goal is to go through the list of 10 zip codes in the dataframe by using a macro. Thanks
<r>
2016-04-07 18:25:12
LQ_EDIT
36,484,761
Allowing table column to change color when clicking checkboxes - HTML/angularJS
I have a table and I am attempting to make it so that when one or more checkboxes in the table are clicked, the entire checkbox column changes color. For better understanding, I want it to look like this before being clicked (which I already have now): [Before][1] And this is what I want it to look after one or more boxes are clicked: [After][2] Here is the HTML I have for the grid: <table id="table-users" class="table table-condensed"> <thead> <tr> <th>#</th> <th> User ID <a href="#" class="filter-link" ng-click="sortType = 'name'; sortReverse = !sortReverse" > <span class="glyphicon glyphicon-sort-by-alphabet"></span> <span ng-show="sortType == 'name' && !sortReverse"></span> <span ng-show="sortType == 'name' && sortReverse"></span></a> </th> <th> Notification Email <a href="#" class="filter-link" ng-click="sortType = 'email'; sortReverse = !sortReverse" > <span class="glyphicon glyphicon-sort-by-alphabet"></span> <span ng-show="sortType == 'email' && !sortReverse"></span> <span ng-show="sortType == 'email' && sortReverse"></span></a> </th> <th> Role <a href="#" class="filter-link" ng-click="sortType = 'type'; sortReverse = !sortReverse" > <span class="glyphicon glyphicon-sort-by-alphabet"></span> <span ng-show="sortType == 'type' && !sortReverse"></span> <span ng-show="sortType == 'type' && sortReverse"></span></a> </th> <th> Last Activity <a href="#" class="filter-link" ng-click="sortType = 'lastActivity'; sortReverse = !sortReverse" > <span class="glyphicon glyphicon-sort-by-alphabet"></span> <span ng-show="sortType == 'lastActivity' && !sortReverse"></span> <span ng-show="sortType == 'lastActivity' && sortReverse"></span></a> </th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr ng-repeat="user in users | orderBy:sortType:sortReverse | filter:searching"> <td>{{ $index+1 }}</td> <td>{{ user.name }}</td> <td>{{ user.email }}</td> <td> <!--<span class="circle-user" ng-class="{'circle-admin': user.type === 'Admin'}"><span class="glyphicon glyphicon-user"></span></span>--> {{ user.type }} </td> <td>{{getLastDate(user.lastActivity) | date:'short'}}</td> <td><input type="checkbox"></td> <td> <span ng-hide="user.name === authInfo.user"> <a href="#" ng-click="showUserAddDialog(user)">Edit</a> </span> </td> <td> <span ng-hide="user.name === authInfo.user"> <a href="#" ng-click="showDeleteUser(user.id,user.name)">Delete</a> </span> </td> <td> <span ng-hide="user.name === authInfo.user"> <a href="#" ng-click="showResetPassword(user.name)">Reset</a> </span> </td> </tr> </tbody> </table> Not sure where to go from here to make this change. [1]: http://i.stack.imgur.com/ZYk60.png [2]: http://i.stack.imgur.com/AymdV.png
<html><angularjs><checkbox><html-table>
2016-04-07 18:50:14
LQ_EDIT
36,484,888
How to return a pointer to an object?
<p>I have created two classes one called Pair(as data members has a dynamically allocated array of chars for KEY and double for value) and the other Collection(which is a collection of Pairs, as data members it has a dynamically allocated array of pairs, and a int variable for the sizeOfPairs). The Collection class should have a method that should return a pointer to the first objects with the provided key, if such object does not exist returns NULL pointer. This is how far I got with that method, but I get an error(error: indirection requires pointer operand ('Pair' invalid)) for the 4th line. Is the way I am returning a pointer to an object correct?</p> <pre><code>Pair *find(const char *key){ for(int i = 0; i &lt; sizeOfPair; ++i){ if(pair[i].getKey() == key){ return *pair[i]; }else{ return NULL; } } } </code></pre>
<c++>
2016-04-07 18:57:48
LQ_CLOSE
36,485,069
C++ Easiest Way to sort and read this file?
<p>This file seems a bit... awkward to manage. I need to sort the file by the highest score and here is a small sample of the file at hand:</p> <pre><code>reece 0 john 5 alex 2 </code></pre> <p>Just a few bits of the data. Basically I need it sorted in the following arrangement and then wrote back to the original file:</p> <pre><code>john 5 alex 2 reece 0 </code></pre> <p>This also needs to be possible with an infinite amount of data (not inf but you understand what I mean). I have tried this:</p> <pre><code>void read() { vector&lt;string&gt; arr; string a, b; ifstream file1; file1.open("Scores.txt", ios::out); int count = 0; while (file1 &gt;&gt; a &gt;&gt; b) { string toVec = a + b; arr.push_back(toVec); count++; } for (int outLoop = 0; outLoop &lt; count; outLoop++) cout &lt;&lt; arr[outLoop]; } </code></pre> <p>Now this reads from the file and put them into a vector but I don't know what to do from that point. The cout just shows this:</p> <pre><code>reece0john5alex2 </code></pre> <p>How would I go about splitting that up and sorting it?</p>
<c++><file><sorting><vector>
2016-04-07 19:07:10
LQ_CLOSE
36,485,256
Comparing two integers in : java
Actally i am in pretty interesting problem when i run this method with n = 64, its gives me x = 64 but beside running the if statement it runs the else statement. the actal answer need to be 32 but it return 64. /** * Complete the method to find the largest power of 2 less than the given number * Use a loop */ public class MathUtil { public int largestPowerOf2(int n) { //TODO: implement this method. int i = 0; while(n > 1) { n = n / 2; i++; } System.out.printf("i = %d\n" , i); int x = (int)Math.pow(2,i); System.out.println(x); if(x == n) { return (int)Math.pow(2,i - 1); } else { return (int)Math.pow(2, i); } } }
<java><debugging>
2016-04-07 19:18:04
LQ_EDIT
36,485,526
JAVASCRIPT calculator program
so I'm trying to make a calculator for my job. Basically it is suppose to calculate someones savings if they came with our firm. I have 3 working sections, but when I try to add another it doesn't work. I'll post a working section, and then the section that doesn't work. WORKING: <div id="VISABOX"> <h4 id="VISA">Visa</h4> <input id="vVol" placeholder="Visa Volume..." type="text"><br> <input id="vFees" placeholder="Visa Fees..." type="text"><br> <button id="vCalc"> Calculate </button> <p id="vEMDR" class="words">EMDR=<span id="vEMDRSPAN"></span></p> <p id="vMonthly" class="words">Monthly Savings=<span id="vMonthlySpan"></span></p> <p id="vYearly" class="words">Yearly Savings=<span id="vYearlySpan"> </span></p> <p id="vFive" class="words">Five Year Savings=<span id="vFiveSpan"> </span></p> </div> document.getElementById("vCalc").onclick=function(){ var visaVol=document.getElementById("vVol").value; var visaFees=document.getElementById("vFees").value; var visaEMDR; visaEMDR=visaFees/visaVol*100; var visaMonthly=visaFees-(visaVol*.0171); var visaYearly=visaMonthly*12; var visaFive=visaYearly*5; document.getElementById("vMonthlySpan").innerHTML=" "+visaMonthly+"$"; document.getElementById("vYearlySpan").innerHTML=" "+visaYearly+"$"; document.getElementById("vFiveSpan").innerHTML=" "+visaFive+"$"; document.getElementById("vEMDRSPAN").innerHTML=" "+visaEMDR+"%"; } NOT WORKING (also stops other buttons from working too): <div id="OCBOX"> <h4 id="OCTitle">Other Charges</h4> <input id="otherCharges" placeholder="Total Other Charges..." type="text"><br> <input id="ourCharges" placeholder="Our Charges..." type="text"><br> <button id="ocCalc"> Calculate </button> <p id="ocMonthly" class="words">Monthly Savings=<span id="ocMonthlySpan"></span></p> <p id="ocYearly" class="words">Yearly Savings=<span id="ocYearlySpan"></span></p> <p id="ocFive" class="words">Five Year Savings=<span id="ovFiveSpan"> </span></p> </div> document.getElementById("ocCalc").onclick=function(){ var otherFees=document.getElementById("otherCharges").value; var ourFees=document.getElementById("ourCharges").value; var ocMonthlySav=otherFees-ourFees; var ocYearlySav=ocMonthlySav*12; var ocFiveSav=ocYearlySav*5; document.getElementById("ocMonthlySpan").innerHTML=" "+ocMonthlySav+"$"; document.getElementById("ocYearlySpan").innerHTML=" "+ocYearlySav+"$"; document.getElementById("ocFiveSpan").innerHTML=" "+ocFiveSav+"$"; } I have NO idea what is happening.. any help would be greatly appreciated. Edit: JavaScript is in the correct <script type="text/javascript"></script> tags, i just didn't put them in the post.
<javascript><html><calculator>
2016-04-07 19:32:17
LQ_EDIT
36,485,657
iframe in PHP does not work
The following code in a PHP script used to work. But now it does not work any more. I tried with the URL directly and it works well. I replaced the URL with something else it works too. I could not figure out what could go wrong. Any ideas? thanks. <iframe src="http://www.pathwaycommons.org/pc/webservice.do?version=3.0&q=TP53&format=html&cmd=get_by_keyword&snapshot_id=GLOBAL_FILTER_SETTINGS&record_type=PATHWAY" WIDTH="100%" HEIGHT="600" MARGINWIDTH=0 MARGINHEIGHT=0 FRAMEBORDER="NO" SCROLLING="AUTO" ></iframe>
<html><iframe>
2016-04-07 19:38:45
LQ_EDIT
36,486,155
running a saved script in python interpreter
<p>I am a beginner in python programming. I am trying to run a file I saved in the interpreter but it always returns a Traceback error after importing and it does not import the file. Thanks for your candid answers </p>
<python>
2016-04-07 20:05:58
LQ_CLOSE
36,487,591
Getter-Setter method and Array List
<p>I have a class NewClass2 and a class with main method. Basically what I want to to is I wanna save a book title, release date, number of pages and the isbn number in an ArrayList and then print the Info.</p> <pre><code>public class NewClass2 { int pages; String released; String title; int isbn; public int getPages() { return pages; } public void setPages(int pages) { this.pages = pages; } public String getReleased() { return released; } public void setReleased(String released) { this.released = released; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public int getIsbn() { return isbn; } public void setIsbn(int isbn) { this.isbn = isbn; } public NewClass2(int pages, String released, String title, int isbn) { this.pages = pages; this.released = released; this.title = title; this.isbn = isbn; } public NewClass2() { } public void printInfo(){ System.out.println("The book has "+pages+" pages and was released on "+released+" and is called "+title); } } </code></pre> <p>And the main class:</p> <pre><code> public class mainClass { public static void main(String[] args){ ArrayList&lt;NewClass2&gt; listTest = new ArrayList&lt;&gt;( ); listTest.add(new NewClass2( 200,"Book 1", "8.9.14",2222) ); listTest.add(new NewClass2( 200,"Book 2", "1.2.04",5555) ); listTest.add(new NewClass2( 200,"Book 3", "5.4.06",6666) ); listTest.add(new NewClass2( 200,"Book 4", "7.4.13",7777) ); listTest.add(new NewClass2( 200,"Book 5", "2.2.03",8888) ); NewClass2 book = new NewClass2(listTest); book.printInfo(); } } </code></pre> <p>The IDE tells me that </p> <pre><code>NewClass2 book = new NewClass2(listTest); </code></pre> <p>is wrong but why? and how to i fix it??</p>
<java><arraylist><get><set>
2016-04-07 21:32:17
LQ_CLOSE
36,487,621
Card Hangover C
<p>I am trying to do this problem: <a href="http://poj.org/problem?id=1003" rel="nofollow">http://poj.org/problem?id=1003</a> </p> <pre><code> #include &lt;stdio.h&gt; int c; int a = 0; int i; int main() { scanf("%.2f", &amp;c); if (0.01 &lt;= c &lt;= 5.20){ for (i = 1; a &lt; c; ++i){ a += (1/(i + 1)); } printf("%d card(s)", i + 1); } return 0; } </code></pre> <p>My code isn't working? For some reason it always returns 2 card(s) no matter what I enter. Can someone find the problem?</p> <p>Thanks!</p>
<c>
2016-04-07 21:34:12
LQ_CLOSE
36,488,051
How to convert JOptionPane String Input into an Int?
<p>I am beginning to learn Java and I am stuck on how to receive the user's input as a String and converting it to an int afterwards so I can use If Statements. Thank you for reading guys, good programming for all.</p>
<java>
2016-04-07 22:05:15
LQ_CLOSE
36,488,282
Does SQL have a condition like 'IS UNIQUE'?
<p>Wherever I was looking for, I've never heard about that any SQL implementations would have an <code>IS UNIQUE</code> "command". Did I miss something? If I'm right, what is the reason?</p> <p>In other words, why I can't state in SQL that a certain command, such as <code>INSERT INTO</code> (<em>especially</em> that) can be done only if a value is or is not considered UNIQUE?</p>
<sql><unique-constraint>
2016-04-07 22:24:57
LQ_CLOSE
36,489,617
JSON: error expecting property name line 1 column 2 (char 1)
This may be a dumb question but I cannot figure it out for the life of me Please excuse my confusing variable naming I would be ecstatic ef anyone could tell me why the error in the title is happening and/or any other mistakes any my code import json import twitter a = twitter.get_account("@Suppert2") q = "cxdffcfctftcvft" ac = twitter.search(a,q, count=1, parameters=None) abg = str(ac) print (abg) ah = json.loads(abg) #here is where the error is accruing print ah["completed_in"] And when you print abg it comes out as: {u'search_metadata': {u'count': 1, u'completed_in': 0.048, u'max_id_str': u'718234026394443782', u'since_id_str': u'0', u'refresh_url': u'?since_id=718234026394443782&q=x597567654dfv&include_entities=1', u'since_id': 0, u'query': u'x597567654dfv', u'max_id': 718234026394443782L}, u'statuses': []} thank you for reading
<python><json><twitter>
2016-04-08 00:39:06
LQ_EDIT
36,490,017
how can I fix this code
<p>Somethings wrong with this code.I input “gender-m,age-20,tickets-10” and it gives me 3200.It supposed to be 3500. I have no idea what's wrong with it, can you please help me? iiiiiiiiiiiiiiiiiiii</p> <pre><code>#include&lt;iostream&gt; using namespace std; int main() { char gender; int age, numTix, premium; cout &lt;&lt; "Enter your gender: "; cin &gt;&gt; gender; cout &lt;&lt; "Enter your age: "; cin &gt;&gt; age; cout &lt;&lt; "Tickets you have gotten: "; cin &gt;&gt; numTix; if (gender == 'M') { if (age &lt; 21) { premium = 1500 + 200 * numTix; } else if (age &gt;= 21 &amp;&amp; age &lt; 30) { premium = 1200 + 100 * numTix; } else { premium = 1000 + 100 * numTix; } } else { if (age &lt; 21) { premium = 1200 + 200 * numTix; } else { premium = 1000 + 100 * numTix; } cout &lt;&lt; "Your premium is $" &lt;&lt; premium &lt;&lt; endl; } system("pause"); return 0; } </code></pre>
<c++>
2016-04-08 01:30:28
LQ_CLOSE
36,490,867
i wanna sum these two arrays with for loop ex. num_array[1]+num2_array[5] num_array[2]+num2_array[4]
i wan to sum two arrays 1)num_array 2)num2_array using for loops... please help me thank you <!-- begin snippet: js hide: false --> <!-- language: lang-js --> var num_array,num2_array; var i,j,sum=0; for(i=0;i<6;i++) { num_array[i] = get_integer("NUMBER: ",""); while(num_array[i] < 1 && num_array[i] > 500) { num_array[i] = get_integer("Enter a number inn limit of 1 to 500",0); } } for(i=5;i>=0;i--) { num2_array[i] = num_array[i]; show_message(num2_array[i]); } <!-- end snippet -->
<javascript>
2016-04-08 03:11:27
LQ_EDIT
36,491,307
how to copy linked list in Python
class _ListNode: def __init__(self, value, next_): """ ------------------------------------------------------- Initializes a list node. Use: node = _ListNode(value, _next) ------------------------------------------------------- Preconditions: _value - data value for node (?) _next - another list node (_ListNode) Postconditions: Initializes a list node that contains a copy of value and a link to the next node in the list. ------------------------------------------------------- """ self._value = copy.deepcopy(value) self._next = next_ return class List: def __init__(self): """ ------------------------------------------------------- Initializes an empty list. Use: l = List() ------------------------------------------------------- Postconditions: Initializes an empty list. ------------------------------------------------------- """ self._front = None self._count = 0 return def copy(self): """ ------------------------------------------------------- Duplicates the current list to a new list in the same order. Use: new_list = l.copy() ------------------------------------------------------- Postconditions: returns: new_list - a copy of self (List) ------------------------------------------------------- """ The requirement is to write the copy function. But when I finish this function as my opinion the new list only contains one item or None item. Does anyone could tell me how to finish this function? Really appreciate for your help.
<python><linked-list>
2016-04-08 04:02:05
LQ_EDIT
36,492,201
how to Increase Form Size?? Thisn't working
private void button2_Click(object sender, EventArgs e) { int i; for (i = 243; i >= 850; i++) { this.Width = i; } }
<c#>
2016-04-08 05:30:09
LQ_EDIT
36,492,339
Can't figure out whats the cause of seg fault
<p>Total C noob here. Having difficulty location the cause of this seg fault. I have tried running a debugger the <code>GBD</code> debugger but I can't figure out how to get it working. The function I'm trying to test removes the contents of an array, puts it in a linked list and then puts the values of the linked list into the second array given to the function. Heres my test and function code. </p> <h3>Test</h3> <pre><code>int test_transfer(void) { #define ARRAY_LENGTH 10 void *arr1[ARRAY_LENGTH]; for (int i = 0; i &lt; ARRAY_LENGTH; i++) { arr1[i] = &amp;i; } void *ptr; void *arr2[ARRAY_LENGTH]; for (int i = 0; i &lt; ARRAY_LENGTH; i++) { arr2[i] = ptr; } transfer(arr1, arr2, ARRAY_LENGTH, sizeof(int), add_to_front, remove_from_front); for (int i=0; i &lt; ARRAY_LENGTH; i++) { printf("%d\n", *((int *)arr2[i])); } return 0; } </code></pre> <h3>Transfer Function</h3> <pre><code>void transfer(void **arr1, void **arr2, int length, int size, void (*insert)(List *, void *), void* (*remove)(List *)) { List *list = List_create(); for (int i=0; i &lt; length; i++) { (*insert)(list, &amp;arr1[i]); } for (int i=0; i &lt; length; i++) { void *indexPtr = arr2 + i*size; indexPtr = (*remove)(list); } } </code></pre>
<c><segmentation-fault>
2016-04-08 05:41:10
LQ_CLOSE
36,492,586
Asp message box with yesno buttons with close button enabled at the top right of the message box
I have asp .net web site in where I created one message box show using dialog result class with yesnocancel buttons but i want only yes no buttons message box but with close button enabled to the top right of the message box without cancel button.With yesno message box it displays only yes no buttons with close button disabled at the top right of the message box.Could it be possible?
<asp.net>
2016-04-08 06:00:45
LQ_EDIT