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,897,709
Iterate through an array with multiple dictinaries
I have an array that contains multiple dictionaries.I want to iterate through every dictionary in the array in order to get only the "File_name" .Once i get the "file_name", i will add those values in another array of type [[String:Anyobject]] that i will hold the images .How can i proceed ? Here is my code import UIKit import Alamofire import SwiftyJSON import MapKit import CoreLocation class DetailsViewController: UIViewController , MKMapViewDelegate , CLLocationManagerDelegate { @IBOutlet weak var Price: UILabel! @IBOutlet weak var Floor: UILabel! @IBOutlet weak var scrollerpage: UIScrollView! @IBOutlet weak var mapview: MKMapView! @IBOutlet weak var bath: UILabel! @IBOutlet weak var bed_number: UILabel! @IBOutlet var PhotoDetailsView: UIImageView! @IBOutlet var label1: UILabel! @IBOutlet var label2: UILabel! @IBOutlet var label3: UILabel! @IBOutlet var label4: UILabel! @IBOutlet var label5: UILabel! @IBOutlet var label6: UILabel! @IBOutlet var label7: UILabel! @IBOutlet var label8: UILabel! @IBOutlet var label9: UILabel! @IBOutlet var label10: UILabel! @IBOutlet var label11: UILabel! @IBOutlet var label12: UILabel! @IBOutlet var label13: UILabel! @IBOutlet var label14: UILabel! @IBOutlet var label15: UILabel! @IBOutlet var label16: UILabel! @IBOutlet var label17: UILabel! @IBOutlet var descritpionlabel: UILabel! var CondoIndivi2 = [[String:AnyObject]]() var imageArray = [[String:AnyObject]]() var test = [[String :AnyObject]]() let adress : String = "" override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. scrollerpage.contentSize.height = 15000 test = [ [ "id": 744736, "pic_count": 6, "mls_unique_id": 342947084, "list_price": 1480000, "property_type": "RE2", "city": "Miami", "bedrooms": 3, "bath": 3, "status": "A", "entry_date": "2016-02-11 00:11:52", "mls_number": "A10032455", "street_number": 1060, "street_directional": "", "street_name": "Brickell", "city_id": 65, "zipcode": 33131, "address": "1060 Brickell # 4505", "primary_listing_pid": 3039955, "secondary_listing_pid": "", "municipal_code": 31, "township_number": 22, "section_number": 11, "subdivision_number": "", "area": 41, "parcel_number": 1250, "year_built": 2009, "virtual_tour_link": "", "half_bath": 1, "living_area": 1933, "garage_spaces": 1, "waterfront": "Y", "total_area": "", "pool": "", "maintenance_fee": 1662, "pets_allowed": "Yes", "unit_number": 4505, "lot_area": "", "listing_broker_code": "ZZON01", "listing_broker_office": "Zona", "latitude": 25.764026271539, "longitude": -80.191569328308, "original_list_price": 1780000, "main_photo_url": "http://s3.amazonaws.com/sefpic/large/342947084-1.jpg", "sale_price": 0, "days_on_market": 73, "close_date": "", "selling_broker_code": "", "expiration_date": "", "condo_id": 444, "complex": "Avenue 1060 Brickell", "subdivision": "", "community_name": "", "lot_dimensions": "", "hoa_fees": "", "taxes": 32337, "tax_year": 2015, "rental_type": "", "rental_occupancy": "Tenant Occupied", "rental_furnished": "U", "commercial_type": "", "commercial_lease_sale": "", "commercial_style": "", "commercial_building": "", "commercial_building_alt": "", "county_id": "DADE", "selling_public_id": "", "second_selling_public_id": "", "agent_name": "Eduardo Diez", "broker_office_phone": "305-397-8192", "agent_phone": "305-753-1113", "second_agent_phone": "", "second_agent_name": "", "parking_restrictions": "", "condo_waterfront_view": [ "No Fixed Bridges" ], "foreclosure": "", "short_status": "", "home_design": "", "home_view": "Ocean View,Water View", "short_sale": "N", "reo": "N", "internet_address_ok": "", "modified_date": "2016-02-11 00:44:48", "image_modified_date": "2016-02-11 00:23:16", "directions": "", "property_style": "Condo 5+ Stories", "building_amenities": [ "Elevator", "Exercise Room" ], "equipment": [ "Automatic Garage Door Opener", "Circuit Breaker", "Dishwasher", "Dryer", "ELEVATOR", "Fire Alarm", "Microwave", "Refrigerator", "Self Cleaning Oven", "Smoke Detector" ], "exterior_features": [ "High Impact Doors", "Open Balcony", "Other" ], "interior_features": [ "Closets Cabinetry", "Cooking Island", "Handicap Equipped", "Other Interior Features", "Split Bedroom", "Vaulted Ceilings" ], "construction_type": [ "Concrete Block Construction" ], "floors": "", "roof_type": "", "home_heating": "", "pet_restriction": "Restrictions Or Possible Restrictions", "home_cooling": [ "Central Cooling", "Electric Cooling", "Other" ], "home_design_2": "", "bedroom_2_size": "", "bedroom_3_size": "", "bedroom_4_size": "", "bedroom_master_size": "", "kitchen_size": "", "living_room_size": "", "rental_includes": "", "description": "Unique duplex apartment on brickell avenue. Amazing views. Building with all amenities. Walking distance to restaurants, bars, markets, convenient stores.", "rooms": "", "sewer": "", "water": "", "subdv": "", "dinner": "", "floor_location": "45<sup>th</sup>", "property_type_db": "RE2", "pets_icon": "Yes", "furnished_icon": "", "price_sqft": 765.64924987067, "price_sq_meters": 8241.6496218586, "living_area_meters": 179.5757, "price_change_days": 23, "price_change_type": -1, "price_change_diff": 300000, "price_change_percent": 20.27, "price_change_arrow": "down", "days_on_market_str": "2 months", "days_on_market_unix": 1455167512, "listing_images": [ [ "file_name": "http://s3.amazonaws.com/sefpic/large/342947084-1.jpg", "comments": "", "photo_id": 1 ], [ "file_name": "http://s3.amazonaws.com/sefpic/large/342947084-2.jpg", "comments": "", "photo_id": 2 ], [ "file_name": "http://s3.amazonaws.com/sefpic/large/342947084-3.jpg", "comments": "", "photo_id": 3 ], [ "file_name": "http://s3.amazonaws.com/sefpic/large/342947084-4.jpg", "comments": "", "photo_id": 4 ], [ "file_name": "http://s3.amazonaws.com/sefpic/large/342947084-5.jpg", "comments": "", "photo_id": 5 ], [ "file_name": "http://s3.amazonaws.com/sefpic/large/342947084-6.jpg", "comments": "", "photo_id": 6 ] ], "permalink_url": "/property-view/1060-brickell---4505/miami/342947084/" ] ] let longtitude_map = test[0]["longitude"] as! Double let latitude_map = test[0]["latitude"] as! Double let adress = test[0]["address"] as! String if let image = test[0]["listing_images"]{ // image will be an array of dictionary holding the file names [![this is how image looks like][1]][1] //loop through image and get only the filename so that i can add it in var imageArray = [[String:AnyObject]]() } let latDelta:CLLocationDegrees = 0.05 let lonDelta:CLLocationDegrees = 0.05 let span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, lonDelta) let location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude_map, longtitude_map) let region:MKCoordinateRegion = MKCoordinateRegionMake(location, span) mapview.setRegion(region, animated: false) let annotation = MKPointAnnotation() annotation.coordinate = location annotation.title = adress mapview.addAnnotation(annotation) let uilpgr = UILongPressGestureRecognizer(target: self, action: Selector("action:")) uilpgr.minimumPressDuration = 2 mapview.addGestureRecognizer(uilpgr) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } [1]: http://i.stack.imgur.com/1wpHH.png
<arrays><swift><swift-dictionary>
2016-04-27 18:10:56
LQ_EDIT
36,897,884
drop down value is not appearing in the drop downlist
I have a php code the add delete new row to the html table. Once column has text field and second column has a drop down. Its value is coming from mysql database. First row is coming correctly. But the value in second record dropdown list is misssing. please help code is: <html> <head> <title></title> <style type="text/css"> input { display: block; /* makes one <input> per line */ } </style> </head> <?php include 'dbconnection\dbconnection.php'; // Database connection $count=1; if(isset($_POST['btnadd']) == "ADD NEW ITEM") { // add 1 to the row counter if (isset($_POST['count'])) $count = $_POST['count'] + 1; // set value for first load else $count = 1; } if(isset($_POST['btnremove']) == "DELTE ITEM") { // decrement the row counter $count = $_POST['count'] - 1; // set minimum row number if ($count < 1) $count = 1; } ?> <body> <!-- call same file on submit --> <form name="form1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php $cdquery="select cmc_id,cmc_name from cat_main_category"; $result2=mysqli_query($conn,$cdquery) or die(mysqli_error()); echo ' <table>'; // print $count rows for ($i=1; $i<=$count; $i++) { echo ' <tr> <td> <input type="text" name="text'.$i.'" align="center"> </td>'; echo '<td> <select id="basicgroup'.$i.'" name="basicgroup'.$i.'" onchange=reload(this.form)>'; echo '<option value=0>Select</option>'; while ($row=mysqli_fetch_array($result2)) { $cdTitle=$row["cmc_name"]; $id=$row["cmc_id"]; //if($id==@$basicgroup){ echo "<option selected value=$id> $cdTitle </option>"; /*} else{echo "<option value=$id> $cdTitle </option>""."<BR>";;*/} echo '</select></td></tr> '; } ?> </table> <!-- you only need one set of buttons and only one counter for this script because every button would do the same --> <input type="submit" name="btnadd" id="btnadd" value="ADD NEW ITEM" > <input type="submit" name="btnremove" id="btnremove" value="DELETE ITEM"> <input type="hidden" name="count" value="<?php echo $count; ?>"> </form> </body> </html>
<php><html><forms>
2016-04-27 18:20:17
LQ_EDIT
36,898,404
i want to sort this list in python from a file
def insertionSort(a): for i in range(1, len(a)): #outloop covering the range value = a[i] #value = to list, which will compare items to the left i = i - 1 #i goes lower than index to comapre futher to the left while i >= 0 : #keep comparing till its at the begining of the list if value < a[i]: #if value is less than i a[i+1] = a[i] # shift number in right i to slot i + 1 a[i] = value # shift value that was left into slot i i = i - 1 else: break infile = open("file1.txt", "r") a=[] for aline in infile: a = aline.split() insertionSort(a) print(a) this is what it is in the file 7686850495948548545 how do i get the insertionSort function to work on file?
<python>
2016-04-27 18:48:20
LQ_EDIT
36,899,040
Printing ArrayList<String> into output?
<p>So, i have ArrayList which i store animals in.</p> <pre><code>private ArrayList&lt;Animal&gt; catalog = new ArrayList&lt;&gt;(); </code></pre> <p>Now, i need to print the catalog into my output when i press 4 into my output.</p> <pre><code>case 4: System.out.println("List of animals: "); printIt(); //Function to print catalog break; </code></pre> <p>I tried to do it with </p> <pre><code> private boolean InList(String name) { for (int i = 0; i &lt; catalog.size(); i++) { if (name.equalsIgnoreCase(catalog.get(i).getName())) { return true; } } return false; } </code></pre> <p>But it's not working. Can you guys help me to get this piece of code?</p>
<java><arraylist><printing>
2016-04-27 19:20:22
LQ_CLOSE
36,899,417
Calculating With Very Big Numbers
<p>I'm -kind of- a beginner to C.</p> <p>I made several searches but I haven't seen this question asked. When I try to calculate very big numbers (let's say... Adding 45235432412321312 to 5495034095872309238) my calculator gives answers which are not true. (The answer of my calculator was -2 for the numbers I've given in the previous sentence). </p> <p>But both Linux's and Windows's own calculators calculate these numbers precisely.</p> <p>What causes my calculator written in C/C++ to give these wrong answers with big numbers? What can I do to calculate these?</p>
<c++><c><calculator>
2016-04-27 19:40:01
LQ_CLOSE
36,899,640
C# How to create a zip file from 3 directory contents
<p>pseudo code: c:\temp\Backup.zip = (c:\Temp\Config*.* , c:\Temp\Data*.<em>, c:\Temp\scripts*.</em>)</p> <p>Thanks in Advance!</p>
<c#><zip>
2016-04-27 19:53:30
LQ_CLOSE
36,900,230
Copy lines and replace beginning of some lines
<p>I have a file containing lines of the form</p> <pre><code>this is block 1 a 1 2 3 this is block 2 a 3 1 9 this is block 3 a 10 2 32 ... </code></pre> <p>I would like to copy some of the lines and replace the beginning so that it becomes:</p> <pre><code>this is block 1 a 1 2 3 b 1 2 3 c 1 2 3 this is block 2 a 3 1 9 b 3 1 9 c 3 1 9 this is block 3 a 10 2 32 b 10 2 32 c 10 2 32 ... </code></pre> <p>Not sure how to solve this with awk, sed or another elegant option. </p>
<bash><shell><awk><sed>
2016-04-27 20:28:20
LQ_CLOSE
36,900,800
c# foreach iteration but only within specified date
I want to get files iteratied thru a directory but only from last two months, so I got: ...directory di code here ... DateTime from_date = DateTime.Now.AddMonths(-2); DateTime to_date = Datetime.Now; ... foreach (var filename in di.EnumerateFiles("*.SS*").Where(filename.ToString()=>filename.ToString().LastWriteTime >= from_date && filename.ToString().LastWriteTime <= to_date)) { ...code here.. } Well, it doesn't like that foreach loop for some reason. Is there a correct way of doing this?
<c#><.net>
2016-04-27 21:00:48
LQ_EDIT
36,901,131
Converting char* to System String^ on C++
As part of my code, I need to output in a textBox a string of 8 characters that have been encrypted. So I need to transform an array of 8 characters to System String^. I tried the following: char result[8]; for(int i=0; i<8; i++) { result[i] = (char)DecimalCypher[7-i]; } textBox3->Text = gcnew String(result); However, the textBox is showing more than 8 characters. 8 characters will change depending on the input, and the remaining will stay as is. Example, If my input is > andrew12 , the output in the textBox is > T)W+"Ziz**BVÎ pé** However if my input is > andrew33 , the output will be : > A1-1`+Ta**BVÎ pé** The last 6 characters are the same.. but should not be here in the first place. It is the first 8 characters that matter! Any idea why is this happening ? Thank you
<.net><string><char><c++-cli>
2016-04-27 21:21:02
LQ_EDIT
36,901,182
if clause teminates the workflow in JavaScript?
<p>When I look at the following code, I think "CheckChoice(IntSelect)" will always execute no matter "if (isNaN(IntSelect))" will execute or not.</p> <p>If I input a NaN and the CheckChoice function worked, the alert("The value supplied is out of range!"); should also display as the "default" branch. But it does not happen as I expected.</p> <p>I do not understand what happens when input is a NaN, can anybody explain it please.</p> <p>Thank you.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Using the Default Clause&lt;/title&gt; &lt;script language="JavaScript"&gt; function CheckChoice(option) { // Make a selection. switch (option) { case 1: document.getElementById("Result").innerHTML = "You chose Item A."; break; case 2: document.getElementById("Result").innerHTML = "You chose Item B."; break; case 3: document.getElementById("Result").innerHTML = "You chose Item C."; break; default: // Display an error dialog. alert("The value supplied is out of range!"); break; } } function MakeAChoice() { // Ask the user to provide input. var Selection = prompt("Type a menu option."); // Convert the string to a number. var IntSelect = parseInt(Selection); // Verify the user has provided a number. if (isNaN(IntSelect)) { // Display an error dialog. alert("Please provide numeric input!"); // Return without doing anything more. return; } // Call the selection function. CheckChoice(IntSelect); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Using the Default Clause&lt;/h1&gt; &lt;p&gt;Menu Options:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Item A&lt;/li&gt; &lt;li&gt;Item B&lt;/li&gt; &lt;li&gt;Item C&lt;/li&gt; &lt;/ol&gt; &lt;input type="button" value="Choose a Menu Item" onclick="MakeAChoice()" /&gt; &lt;p id="Result"&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<javascript><html>
2016-04-27 21:24:27
LQ_CLOSE
36,901,432
Obtain the pdf file path from a website after being execute from a Delphi application?
<p>So I am trying to figure out a way when users open a pdf file from a website then have a Delphi application to execute and show the pdf. Is it possible to somehow copy the url location where the file originated from and pass it to a string when the form is created. </p>
<delphi><pdf>
2016-04-27 21:41:01
LQ_CLOSE
36,901,997
How to print % as a character in printf
<p>I would like to use % as a normal character in printf lets say the output is a is 20% higher than b how would I be able to do that since % is used as a special character?</p>
<bash>
2016-04-27 22:22:53
LQ_CLOSE
36,904,769
I create search bar in java.But it has some error how i fixed it. Kindly help me
try { con = DriverManager.getConnection(url, username, password); String qry = "SELECT * FOME users WHERE id=?"; pst = con.prepareStatement(qry); pst.setString(1, txtSearch.getText()); rs = pst.executeQuery(); tblEmployee.setModel(DbUtils.resultSetToTableModel(rs)); } catch (Exception e) { e.printStackTrace(); //Show what is the catched error } rs = pst.executeQuery(); is not work and get like this error com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FOME users WHERE id='df'' at line 1
<java>
2016-04-28 03:32:08
LQ_EDIT
36,906,832
Whats wrong with this syntax?
Below code not working in IE. Console shows syntax error. Whats wrong with this? var text = '{"products":[' + '{"name":"IB-400","mail":"9000@mail.pl"},' + '{"name":"IB-500","mail":"8000@mail.pl"}]}'; var textObj = JSON.parse(text) var mail = textObj.products.find(itm => itm.name == c).mail $( ".komunikat" ).replaceWith( '<div class="komunikat-mail"><h1 style="text-align:center;">Contact</h1><p class="komunikat-paragraph">Lorem ipsum ' + mail +'. Lorem ipsum.</p></div>' );
<javascript><jquery><ecmascript-5>
2016-04-28 06:25:03
LQ_EDIT
36,907,604
simple_form with Devise sign In
I'm working on a simple_form with devise, and I'm having a problem with the form submissions. If a user don't give email id and password while sign in then I have to display error message to user like "Email can't be blank" but it won't show any error messages it will remain on same sign in page with no errors. What can i do? I am using devise version "3.5.6" and simple_form version "3.2.1".
<ruby-on-rails>
2016-04-28 07:07:01
LQ_EDIT
36,907,716
How to break flow of code in Swift?
<p>I am unable to break the execution of code using 'return' keyword in Swift language. Please suggest the another way around for how to break the code execution flow if need be in Swift.</p>
<ios><swift><swift2><return><break>
2016-04-28 07:11:25
LQ_CLOSE
36,908,066
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given
<p>I got this really weird problem that </p> <pre><code>Warning: mysql_fetch_row() expects parameter 1 to be resource, null given ... </code></pre> <p>however, I checked mysql_num_rows($result), and it is not 0.</p> <pre><code> echo '&lt;h3&gt;Comments&lt;/h3&gt;'; $comment_query = "select * from comments where post_id='$post_id' order by comment_timestamp desc"; $comment_result = mysql_query($comment_query) or die(mysql_error()); if (mysql_num_rows($comment_result) != 0) { while ($crow = mysql_fetch_assoc($commment_result)) { $comment_username = $crow['username']; $comment_text = $crow['comment_text']; $comment_time = $crow['comment_timestamp']; echo "&lt;b&gt;$comment_username &lt;/b&gt;&lt;b&gt;$comment_timestamp: &lt;/b&gt; &lt;br /&gt;".$comment_text."&lt;hr /&gt;&lt;br&gt;"; } } else { echo "No comments yet!"; } </code></pre> <p>Any ideas on that? I have been stuck with it for a while, really thanks for your help!</p>
<php><html>
2016-04-28 07:28:22
LQ_CLOSE
36,909,300
Looking for text editor with multiple functionalities
<p>I'm building a web app; front-end in Angular and back-end in Ruby on Rails.</p> <p>I need to achieve below functionalities. I am basically adding text editor so users can edit template letters in my service.</p> <pre><code>1) Load .doc file from the file system(or remote server) to the text editor 2) Edit the loaded .doc file and save the file as different name </code></pre> <p>Is there any recommendable free text editor which can achieve those?</p>
<javascript><ruby-on-rails><angularjs>
2016-04-28 08:31:40
LQ_CLOSE
36,909,316
Why big websites don't prefer localstorage over cookie?
<p>I'd like to ask why big players like facebook, google still uses cookies if localstorage is much better and secure for same.</p>
<javascript><html><cookies><local-storage>
2016-04-28 08:32:32
LQ_CLOSE
36,909,598
Number function in javascript
number function in javascript can be used to multiply,divide,find remainder but cannot be used for subtraction and addition. var theNumber = Number ( prompt (" Pick a number " , "") ) ; alert (" difference " + theNumber - theNumber ) ; // -> difference NaN why not 0? var theNumber = Number ( prompt (" Pick a number " , "") ) ; alert (" sum " + theNumber + theNumber ) ; // ->3 // ->33 why is concatenation occurring? why not 6? please help!
<javascript><function>
2016-04-28 08:45:36
LQ_EDIT
36,911,947
Find items, related to article by name
<p>I have an article (title, body) stored in mysql, and i have about 1M rows (name) stored in mysql and indexed with elasticsearch. How can i find rows, which names are found (100% match of name) in article title or body? Thanks for any suggetions.</p>
<php><mysql><elasticsearch>
2016-04-28 10:29:01
LQ_CLOSE
36,912,140
If an Algorithm's running time can be expressed as function F(x)=√n+(logn)^2 ,
If an Algorithm's running time can be expressed as function F(x)=√n+(logn)^2 , Then which one of the following is not a correct bound for the running time ? 1-O(n) 2-O(√n) 3-O((log)^2) 4-Omega(1)
<algorithm><time-complexity><big-o><complexity-theory>
2016-04-28 10:36:54
LQ_EDIT
36,913,002
C# enum and radiobuttons
Hello how can i tell if one radion buton is checked do something in swith? this is part of my code: this is in my class Person.cs public enum TypeTimer { Unlimited, Countdown, Limited} This is my switch where i will put the funciotns public Person(TypeTimer s1) { switch (s1) { case TypeTimer.Unlimited: (code here) break; case TypeTimer.Countdown: (code here) break; case TypeTimer.Limited: (code here) break; default: break; } } Here how do i tell if checked == true is equal to enum limited or unlimited or countdown? this is in Form.cs private void button1_Click(object sender, EventArgs e) { if (rbtnNormalTimer.Checked == true) { } else if(rbtnCountDown.Checked == true) { } else if(rbtnLimited.Checked == true) { } } CAn someone please help me?
<c#><winforms><enums>
2016-04-28 11:14:50
LQ_EDIT
36,915,081
ORACLE JOIN TABLES
<p>I have </p> <pre><code>T1: USER_ID OSX 1 Y 2 Y T2: USER_ID ANDROID 1 Y 3 Y </code></pre> <p>I want to join the tables as follows but i don't know how</p> <pre><code>T3: USER_ID ANDROID OSX 1 Y Y 2 null Y 3 Y null </code></pre>
<sql><oracle>
2016-04-28 12:43:55
LQ_CLOSE
36,915,316
nodejs,mysql The server closed the connection
I'm trying to Node.js and MySql but im receiving this error : :Error: Connection lost: The server closed the connection. my code here. var mysql = require('mysql'); var config ={ connectionLimit : 100, waitForConnections : true, queueLimit :0, debug : true, wait_timeout : 28800, connect_timeout :10, host : "localhost", user : " root ", password : " root ", database : "mydb" }; var table = 'mytable'; var connection; function handleConnection(){ connection = mysql.createConnection(config); connection.connect(function(err){ console.log("connected"); }); connection.query('select * from' + table, function(err,result,fields){ if (!err){ console.log("result :" + result); } else{ console.log("error1 :" +err); } }); } Thanks in advance.
<mysql><node.js>
2016-04-28 12:54:07
LQ_EDIT
36,915,429
error: invalid types ‘int [200][float]’ for array subscript
so I basically have a coordinate system and I want to access the array by index of coordinates.pos is Vector2f(I use sfml). int iposy=static_cast<int>(pos.y); int iposx=static_cast<int>(pos.x); if(col[iposy][iposx]==N) col[iposy][iposx]=i; else{ int vx1 = vx[i]; int vx2 = vx[(col[iposy][iposx])]; int vy1 = vy[i]; int vy2 =vy[(col[iposy][iposx])]; I get the following errors :" error: invalid types ‘int [200][float]’ for array subscript int vx2 = vx[(col[iposy][iposx])]; error: invalid types ‘int [200][float]’ for array subscript int vy2 =vy[(col[iposy][iposx])];
<c++><arrays><floating-point><integer><sfml>
2016-04-28 12:58:28
LQ_EDIT
36,915,804
REGEX notepad ++; "Http: //www.abc.jpg", "http: //www.xyz.jpg", "http: //www.123.gif" extension of Internet addresses to separate the links?
REGEX notepad ++; "Http: //www.abc.jpg", "http: //www.xyz.jpg", "http: //www.123.gif" extension of Internet addresses to separate the links !?
<html><regex><hyperlink><jpeg>
2016-04-28 13:14:23
LQ_EDIT
36,915,878
total number of records and their reason sql server
I want to write a query that get total number of records(booking) using COUNT(*) function, i have a column in DB "Type" and in the next column i want to show type of record e.g output of query be like Total Booking -> 10 Booking Type -> 3 wedding, 4 Birthday Party, 3 family Event (this will be in single cell next to total Booking) someone please help me.. Thanks
<sql><sql-server><sql-server-2008>
2016-04-28 13:16:55
LQ_EDIT
36,918,701
How to find all links to pictures from an html file
How to find all links to pictures from an html file REGEX notepad++; "Http://www.../abc.jpg", "http://www.../xyz.jpeg", "http://www.../123.gif" extension of Internet addresses to separate the links !? visual image links contained within html file I want to parse command with REGEX --- sample ; index.html file ,,,, aa bb cc html:\\www.com **http://www…/abc.jpg** abc123 **http://www…/xyz.jpeg** 123 abc **http://www…/123.gif** xxx ,,, wherein examples of desired results; as follows ;; **http: //www.../abc.jpg http: //www.../xyz.jpeg http: //www.../123.gif**
<html><regex><hyperlink><notepad++><jpeg>
2016-04-28 15:10:26
LQ_EDIT
36,919,953
Best Practise Coding for R script running in production
<p>We have a linux production server and a number of scripts we are writing that we want to run on it to collect data which then will be put into a Spark data lake.</p> <p>My background is SQL Server / Fortran and there are very specific <strong>best practices</strong> that should be followed. </p> <ul> <li>Production environments should be stable in terms of version control, both from the code point of view, but also the installed applications, operating system, etc. </li> <li>Changes to code/applications/operating system should be done either in a separate environment or in a way that is controlled and can be <em>backed out</em>.</li> <li>If a second environment exist, then the possibility of parallel execution to test system changes can be performed.</li> <li>(Largely), developers are restricted from changing the production environment</li> </ul> <p>In reviewing the R code, there are a number of things that I have questions on.</p> <ul> <li>library(), install.packages() - I would like to exclude the possibility of installing newer versions of packages each time scripts are run?</li> <li>how is it best to call R packages that are scheduled through a CRON job? There are a number of choices here.</li> <li>When using RSelenium what is the most efficient way to use a gui/web browser or virtualised web browser?</li> </ul>
<r><production-environment>
2016-04-28 16:04:59
LQ_CLOSE
36,920,505
R code - restructure data, three columns of stacked data to rows
<p>In this example data, three people sorted 10 items into a variable number of groups and provided a text label for each group. Person and label are text fields. Item var when downloaded and read into R is read as an integer. Item variable is actually categorical data and defines text for the item; an item number for a test is a good analogy. Labels, items and persons can be in any order, I typically sort the data as you see here to make visual inspection possible. Each person has 10 items in this example, in the real world there are usually 100 items. Each person has a variable number of labels. Each label has a variable number of items. All items are associated with one and only one label and all items (1-10 in this example) appear once for each person, there is no missing data.</p> <p><strong>person group item</strong></p> <p>person_1 label_A 1</p> <p>person_1 label_A 2</p> <p>person_1 label_A 3</p> <p>person_1 label_A 4</p> <p>person_1 label_B 5</p> <p>person_1 label_B 6</p> <p>person_1 label_C 7</p> <p>person_1 label_C 8</p> <p>person_1 label_C 9</p> <p>person_1 label_C 10</p> <p>person_2 label_D 1</p> <p>person_2 label_D 2</p> <p>person_2 label_D 3</p> <p>person_2 label_D 4</p> <p>... remaining lines omitted for brevity</p> <p>I need the data restructured into the format that follows. Each line is a label variable with the associated items, labels are on one and only one line. Each person is repeated for as many times as they have unique labels. I have searched stack overflow and have made multiple attempts with reshape and tidyr, the best I can produce is a rectangular binary matrix where there are ones or zeros in the data frame with a column for person and label and then 10 columns labeled 1:10 for each item value in this example. I can post-process to get what i want in excel but would rather get it all done in R, I need the actual item value in the column as shown here. Ideally, the max ncol would be one each for peson &amp; label and as many as needed to represent the sorting. Person3,label_H needed 7 col for items so there could be NA or 0 in those column or other rows. Any help would be most appreciated, I can normally find the answer I need on StackOverflow, this time I am stumped.</p> <p><strong>person group items</strong></p> <p>person_1 label_A 1 2 3 4<br> person_1 label_B 5 6<br> person_1 label_C 7 8 9 10<br> person_2 label_D 1 2 3 4<br> person_2 label_E 5 6 7<br> person_2 label_F 8 9 10<br> person_3 label_G 1 2 3<br> person_3 label_H 4 5 6 7 8 9 10</p>
<r><reshape><reshape2><tidyr>
2016-04-28 16:31:31
LQ_CLOSE
36,922,010
Scan a folder for files
<p>I am tasked with creating an app to monitor a folder for files to be processed.</p> <p>I was wondering if there is anything new an exciting that I can use or should I just spin up a good old windows service?</p>
<c#><.net>
2016-04-28 17:49:50
LQ_CLOSE
36,923,128
What does this jquery + struts construct do?
I am dealing with JQuery code as follows: function formSubmit(){ $('#myform').attr('action', "./myFilter.action"); $('#myform').submit(); } The form: <s:form name="myform" action="myAction" id="myform"> </s:form> Noticing that myFilter.action is called before myAction. But I don't understand how or why that is happening. Can someone explain? Thanks
<jquery>
2016-04-28 18:49:24
LQ_EDIT
36,923,182
R: Remove a row from all data.frames in global environment
<p>I have over 200 data.frames in my global environment. I would like to remove the first row from each data.frame, but I am not sure how. </p> <p>Any help will be appreciated please let me know if further information is needed.</p>
<r><dataframe>
2016-04-28 18:52:23
LQ_CLOSE
36,923,660
Interest rate program
<p>I am just beginning to learn C. So for practice I decided to write a interest rate calculator but for some reason my calculation always comes out as 0 and I can't figure it out. If you can please take a look.</p> <pre><code>#include &lt;stdio.h&gt; main() { int time; float principle, rate, total; printf("What is your starting amount? "); scanf(" %f", &amp;principle); printf("What is your interest rate? "); scanf(" %f", &amp;rate); printf("How long do you want to save? "); scanf(" %d", &amp;time); total = principle * rate * time; printf("You will have earned an interest amount of $%d", total); return 0; } </code></pre>
<c>
2016-04-28 19:19:00
LQ_CLOSE
36,923,738
Extract data from a string
<p>I have a data string as </p> <blockquote> <pre><code> [{"Name":"Jon","Age":"30"},{"Name":"Smith","Age":"25"}] </code></pre> </blockquote> <p>How to extract the data from it?</p> <p>Please suggest me.</p>
<c#><json>
2016-04-28 19:24:25
LQ_CLOSE
36,924,573
bash replace single quotes with double qoutes
I have a directory full of SAS label files. The label files have space, single qoute, space, single qoute in each file. Looks like, VAR1 = ' 'SOME LABEL' ' I want a bash script that will replace these single qoutes with double quotes so that I end up with, VAR1 = "SOME LABEL" Please help
<bash>
2016-04-28 20:10:21
LQ_EDIT
36,924,900
what does argument scale do actually because after running the code below the three columns (4:6) changed to decimals.
> hab <- read.csv('cov.csv') > names(hab[4:6]) > hab1 <- as.data.frame(scale(hab[4:6])) For eg. > x <- matrix(1:10, ncol = 2) > x 1 6 2 7 3 8 4 9 5 10 I applied scale argument to this matrix > y <- scale(x) > y This gets changed to -1.2649111 -1.2649111 -0.6324555 -0.6324555 0.0000000 0.0000000 0.6324555 0.6324555 1.2649111 1.2649111
<r><scale>
2016-04-28 20:29:43
LQ_EDIT
36,926,275
Why can I replace one word in a text file but not another?
<p>I'm reading through the following text file word for word a replacing the words "@name@" and "@festival@". My program works perfectly for @name@ but only changes the first @festival@, but not the second. I have no idea why. </p> <p>John Doe</p> <p>Room 213-A</p> <p>Generic Old Building</p> <p>School of Information Technology</p> <p>Programming State University</p> <p>New York NY 12345-0987</p> <p>USA</p> <p>To: @name@</p> <p>Subject: Season's greetings: @festival@</p> <p>Dear @name@,</p> <p>A very @festival@ to you and your family!</p> <p>Your sincerely,</p> <p>John</p> <pre><code>void Main::readFile() { while (v.size() != 0) { string name; name = v.at(v.size()-1); v.pop_back(); std::ofstream out(name + ".txt"); ifstream file; file.open("letter.txt"); string word; string comma; char x; word.clear(); while (!file.eof()) { x = file.get(); while (x != ' ' &amp;&amp; x != std::ifstream::traits_type::eof()) { if (word == "@name@") { word = name; } if (word == "@festival@") { word = "THISISATEST!!!!!!!!!!!!!!"; } word = word + x; x = file.get(); } out &lt;&lt; word + " "; word.clear(); } } </code></pre>
<c++>
2016-04-28 22:02:46
LQ_CLOSE
36,926,276
Change input border color if text is typed
<p>I think that Title of my question explains very well what i need. For example my code is</p> <pre><code>&lt;head&gt; &lt;style&gt; input{ border: 5px solid red;} &lt;/style&gt; &lt;/head&gt; &lt;div class="in"&gt; &lt;input class="input" type="text" name="text" method="post"&gt; &lt;/div&gt; </code></pre> <p>Now border is Red. I need to make it black if i will write text in it. Thanks</p>
<javascript><html><css>
2016-04-28 22:02:48
LQ_CLOSE
36,929,687
Android Shadow Effect on EditText Field.
<p><a href="http://i.stack.imgur.com/H6uk9.png" rel="nofollow">I need to add a shadow effect a the one shown in the image, below the blue color edit text field. How should I achieve the following. </a></p>
<android>
2016-04-29 04:40:57
LQ_CLOSE
36,929,845
Who to check if From Hour and To Hour are overlapped in java
I have a requirement where i can create 3 shifts per day. The shift timings are 1) 06:00 - 14:00 2) 14:01 - 22:00 3) 22:01 - 05:59. How can i check that shift timings are not overlapped. Your suggestions are appreciated. Please note that in the third case from hour is greater that to hour.
<java>
2016-04-29 04:56:33
LQ_EDIT
36,929,920
Pass value from JavaScript to code behind C#
I need to pass the array value from code behind asp.net C#. <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Task', 'Hours per Day'], ['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7] ]); var options = { title: 'My Daily Activities' }; var chart = new google.visualization.PieChart(document.getElementById('piechart')); chart.draw(data, options); } </script> Since the data changes dynamically I need to pass the value.
<javascript><c#><asp.net>
2016-04-29 05:02:52
LQ_EDIT
36,930,049
javascript innerhtml to print for loop
I have just started HTML and JavaScript and got stuck here.I am trying to validate form in case of empty field and print the corresponding output using for loop .Below is the jsp page and javascript code. <!-- begin snippet: js hide: false --> <!-- language: lang-js --> < script > var err = new Array(); var i = 0, flag = 0; function validateForm() { var x = document.forms["RegistrationController"]["firstname"].value; if (x == null || x == "") { err[i++] = "First name cannot be empty"; flag = 1; } var a = document.forms["RegistrationController"]["dob"].value; if (a == null || a == "") { err[i++] = "Date of birth cannot be empty"; flag = 1; } var b = document.forms["RegistrationController"]["address_line_1"].value; if (b == null || b == "") { err[i++] = "Address cannot be empty"; flag = 1; } var c = document.forms["RegistrationController"]["city"].value; if (c == null || c == "") { err[i++] = "city cannot be empty"; flag = 1; } var d = document.forms["RegistrationController"]["pincode"].value; if (d == null || d == "") { err[i++] = "pincode cannot be empty"; flag = 1; } var e = document.forms["RegistrationController"]["mobile_no"].value; if (e == null || e == "") { err[i++] = "mobile no cannot be empty"; flag = 1; } var f = document.forms["RegistrationController"]["email"].value; if (f == null || f == "") { err[i++] = "email cannot be empty"; flag = 1; } if (flag == 1) { var string = ""; for (j = 0; j < err.length; j++) { document.getElementById("error").innerHTML = err[i]; return false; } } } < /script> <!-- language: lang-html --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Registration</title> </head> <body> <div class="error" id="error"></div> <h1>Registration Form</h1> <div class="ex"> <form name="RegistrationController" method="post" onsubmit="return validateForm()"> <table style="with: 50%"> <tr> <td>First name</td> <td> <input type="text" name="firstname" /> </td> </tr> <tr> <td>Last name</td> <td> <input type="text" name="lastname" /> </td> </tr> <tr> <td>Date of Birth</td> <td> <input type="text" name="dob" /> </td> </tr> <tr> <td>Address Line 1</td> <td> <input type="text" name="address_line_1" /> </td> </tr> <tr> <td>Address Line 2</td> <td> <input type="text" name="address_line_2" /> </td> </tr> <tr> <td>state</td> <td> <input type="text" name="state" /> </td> </tr> <tr> <td>city</td> <td> <input type="text" name="city" /> </td> </tr> <tr> <td>pincode</td> <td> <input type="text" name="pincode" /> </td> </tr> <tr> <td>Mobile no</td> <td> <input type="text" name="mobile_no" /> </td> </tr> <tr> <td>email</td> <td> <input type="text" name="email" /> </td> </tr> <tr> <td>gender</td> <td> <input type="radio" name="gender" />Male</td> <td> <input type="radio" name="gender" />Female</td> </tr> </table> <input type="submit" value="register" /> </form> </div> </body> </html> <!-- end snippet -->
<javascript><html><jsp>
2016-04-29 05:13:19
LQ_EDIT
36,930,141
How to extract and display field in android
<p>Please fins Main.java code below</p> <pre><code>public class Main extends Activity implements OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); findViewById(R.id.my_button).setOnClickListener(this); } @Override public void onClick(View arg0) { Button b = (Button)findViewById(R.id.my_button); b.setClickable(false); new LongRunningGetIO().execute(); } private class LongRunningGetIO extends AsyncTask &lt;Void, Void, String&gt; { protected String getASCIIContentFromEntity(HttpEntity entity) throws IllegalStateException, IOException { InputStream in = entity.getContent(); StringBuffer out = new StringBuffer(); int n = 1; while (n&gt;0) { byte[] b = new byte[4096]; n = in.read(b); if (n&gt;0) out.append(new String(b, 0, n)); } return out.toString(); } @Override protected String doInBackground(Void... params) { HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpGet = new HttpGet("http://191.166.1.88:2000"); String text = null; try { HttpResponse response = httpClient.execute(httpGet, localContext); HttpEntity entity = response.getEntity(); text = getASCIIContentFromEntity(entity); } catch (Exception e) { return e.getLocalizedMessage(); } return text; } protected void onPostExecute(String results) { if (results!=null) { EditText et = (EditText)findViewById(R.id.my_edit); et.setText(results); } Button b = (Button)findViewById(R.id.my_button); b.setClickable(true); } } } </code></pre> <p>I am getting the JSON data from REST API, it is as shown below</p> <pre><code> {"Tm":{"Time": "Mon Nov 20 12:45:59 IST 2015"},"Name": {"Host": "u1", "IP": "190.166.169.137"},"Speed":{"cpu": 2494.259033203125}} </code></pre> <p>How to extract only Nama of Host that is "u1" and display in text box in android. I am new to it please help</p>
<javascript><java><android><node.js><rest>
2016-04-29 05:21:49
LQ_CLOSE
36,931,631
how do I create android app using wordpress database?
<p>I had completed my website in wordpress,so can I use my wordpress database to connect android app? how? give me perfect references.</p>
<android><android-studio><wordpress><wordpress-theming>
2016-04-29 07:01:45
LQ_CLOSE
36,933,082
jenkins authentication fails with gitlab
Before to say my problem, i installed my **gitlab**(omnibus settting) and gitlab is connected external **nginx** server. And than now i am setting jenkins. While i am making new jenkins item, when i select "Git" in "Source code management" i receive following message in the picture.[git selecting screen][1] So i checked "error.log" in my external nginx. And then i found following error code. **`[error] 20979#0: OCSP_basic_verify() failed (SSL: error:27069076:OCSP routines:OCSP_basic_verify:signer certificate not found) while requesting certificate status, responder: ocsp.int-x1.letsencrypt.org`** I also searched it on google and anywhere i know, but i still don't know how to solve this problem. thank you advance for your help. [1]: http://i.stack.imgur.com/JGU72.png
<ssl><nginx><jenkins><gitlab>
2016-04-29 08:14:41
LQ_EDIT
36,933,653
[JAVA]how to get a value from another java file
first java file public class Swordsman extends Beginner { public String attFunc; public String attSkill; private String nickname; private int power; private int result; public void setnickname(String nickname){ this.nickname=nickname; } public void setpower(int power){ this.power=power; } public Swordsman(int p,String nm){ setnickname(nm); setpower(p); /*nickname=nm; *power=p; */ } public String nickname(){ return nickname; } public int power(){ return power; } public int result(){ if(power>=bpower){ result=1; }else if(power<bpower){ result=0; } } } secong java file public class Boss { public int bpower(){ return bpower; } } compile error .\Swordsman.java:32: error: cannot find symbol }else if(power<bpower){ As you see,the bpower in first java file,and how can i get the bpower from secong java file ? As you see,the bpower in first java file,and how can i get the bpower from secong java file ?As you see,the bpower in first java file,and how can i get the bpower from secong java file As you see,the bpower in first java file,and how can i get the bpower from secong java file ?
<java><oop>
2016-04-29 08:44:11
LQ_EDIT
36,933,993
Using ':' in ID atribute
I know it's a weird question bu If I had to use the **id= cu:w** , how could I select it with jquery? <script type="text/javaScript"> $(function() { $('#cu:w').on('change', function() { $(this).hide(); }); }); </script> <fieldset> <legend>Check Here<input id='cu:w' type="checkbox"></legend> <span class="myClass"> <p>This is the text.</p> </span> </fieldset> Demo: http://jsfiddle.net/cEAnM/227/
<jquery>
2016-04-29 09:00:30
LQ_EDIT
36,935,116
infoWindow in google maps on multiple markers
<p>i've created a google maps, which retrieve data from a csv file. This seem to work fine, however when i loop through all the objects the infoWindow does not seem to work. i guess this is due to the fact that the <code>marker</code> variable is inside a for loop. i've tried to move the code to inside the loop, however this result in the infoWindow placed randomly on the map instead above the clicked marker. How can i achieve the infoWindow to work with multiple markers?</p> <p><strong>db.csv example</strong></p> <pre><code>40.740;-74.18;test;haha; 40.740;-74.20;test;haha; </code></pre> <p><strong>html &amp; java</strong></p> <pre><code>&lt;head&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;link rel="stylesheet" href="normalize.css"&gt; &lt;meta http-equiv="Content-Type" content="text/html;charset=UTF-8"&gt; &lt;script src="https://maps.googleapis.com/maps/api/js"&gt;&lt;/script&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="mapContainer"&gt; &lt;div id="map"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id="abc"&gt; &lt;div id="popupContact"&gt; &lt;section class="register"&gt; &lt;h1&gt;CAMP INFORMATIONER:&lt;/h1&gt; &lt;form method="post" action="index.html"&gt; &lt;div class="reg_section personal_info"&gt; &lt;input type="text" name="username" value="" placeholder="Campnavn"&gt; &lt;textarea name="textarea" id="description" placeholder="Beskrivelse"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div&gt; &lt;span class="submit" style="text-align: left; padding: 0 10px;"&gt;&lt;input TYPE="button"name="commit" value="Tilføj" onclick="placeMarker(currentMarker, document.getElementById('description'));"&gt;&lt;/span&gt; &lt;span class="submit" style="text-align: right; padding: 0 10px;"&gt;&lt;input TYPE="button" name="commit" value="Fortryd" onclick="div_hide();"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/form&gt; &lt;/section&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script&gt; var mapCanvas; var currentMarker; function initialize() { var myOptions = { center: {lat: 40.740, lng: -74.18}, zoom : 15, mapTypeId: google.maps.MapTypeId.ROADMAP }; mapCanvas = new google.maps.Map(document.getElementById("mapContainer"), myOptions); var returnValue = ""; var request = new XMLHttpRequest(); // Read the lat/long info for markers request.open("GET", "db.csv", false); request.send(null); returnValue = request.responseText; // Convert our data from the CVS file to a usable array var data = CSVToArray(returnValue); for (var i = 0; i &lt; data.length; i++) { // Create a lat/long object readable by Google var myLatlng = new google.maps.LatLng(parseFloat(data[i][0]), parseFloat(data[i][1])); // Generate a marker from the lat/long object and add it to the map var marker = new google.maps.Marker({ position: myLatlng, map: mapCanvas, title: data[i][2], description: data[i][3] }); } var imageBounds = { north: 40.773941, south: 40.712216, east: -74.12544, west: -74.22655 }; historicalOverlay = new google.maps.GroundOverlay( 'http://i.stack.imgur.com/0mgx2.jpg', imageBounds); historicalOverlay.setMap(mapCanvas); // This event listener calls addMarker() when the map is clicked. google.maps.event.addListener(historicalOverlay, 'click', function(e) { console.log("clicked'"); currentMarker = e.latLng; infowindow.close(); div_show(); }); //Changes zoom levels when the projection is available. google.maps.event.addListenerOnce(mapCanvas, "projection_changed", function(){ mapCanvas.setMapTypeId(google.maps.MapTypeId.HYBRID); //Changes the MapTypeId in short time. setZoomLimit(mapCanvas, google.maps.MapTypeId.ROADMAP); setZoomLimit(mapCanvas, google.maps.MapTypeId.HYBRID); setZoomLimit(mapCanvas, google.maps.MapTypeId.SATELLITE); setZoomLimit(mapCanvas, google.maps.MapTypeId.TERRAIN); mapCanvas.setMapTypeId(google.maps.MapTypeId.ROADMAP); //Sets the MapTypeId to original. }); // InfoWindow content var content = '&lt;div id="iw-container"&gt;' + '&lt;div class="iw-title"&gt;title&lt;/div&gt;' + '&lt;div class="iw-content"&gt;' + '&lt;p&gt;Founded in 1824, the Porcelain Factory of Vista Alegre was the first industrial unit dedicated to porcelain production in Portugal. For the foundation and success of this risky industrial development was crucial the spirit of persistence of its founder, José Ferreira Pinto Basto. Leading figure in Portuguese society of the nineteenth century farm owner, daring dealer, wisely incorporated the liberal ideas of the century, having become "the first example of free enterprise" in Portugal.&lt;/p&gt;' + '&lt;/div&gt;' + '&lt;div class="iw-bottom-gradient"&gt;&lt;/div&gt;' + '&lt;/div&gt;'; // A new Info Window is created and set content var infowindow = new google.maps.InfoWindow({ content: content, // Assign a maximum value for the width of the infowindow allows // greater control over the various content elements maxWidth: 350 }); google.maps.event.addListener(marker, 'click', function() { infowindow.open(mapCanvas, marker); //title document.getElementById("iw-title").innerHTML = marker.title; //description document.getElementById("iw-content p").innerHTML = marker.description; }); // Event that closes the Info Window with a click on the map google.maps.event.addListener(mapCanvas, 'click', function() { infowindow.close(); }); google.maps.event.addListener(infowindow, 'domready', function() { // Reference to the DIV that wraps the bottom of infowindow var iwOuter = $('.gm-style-iw'); /* Since this div is in a position prior to .gm-div style-iw. * We use jQuery and create a iwBackground variable, * and took advantage of the existing reference .gm-style-iw for the previous div with .prev(). */ var iwBackground = iwOuter.prev(); // Removes background shadow DIV iwBackground.children(':nth-child(2)').css({'display' : 'none'}); // Removes white background DIV iwBackground.children(':nth-child(4)').css({'display' : 'none'}); // Moves the infowindow 115px to the right. iwOuter.parent().parent().css({left: '115px'}); // Moves the shadow of the arrow 76px to the left margin. iwBackground.children(':nth-child(1)').attr('style', function(i,s){ return s + 'left: 76px !important;'}); // Moves the arrow 76px to the left margin. iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 76px !important;'}); // Changes the desired tail shadow color. iwBackground.children(':nth-child(3)').find('div').children().css({'z-index' : '1'}); // Reference to the div that groups the close button elements. var iwCloseBtn = iwOuter.next(); // Apply the desired effect to the close button iwCloseBtn.css({opacity: '1', right: '38px', top: '3px', border: '7px solid #fff', 'border-radius': '13px', 'box-shadow': '0 0 5px #7D0F33'}); // If the content of infowindow not exceed the set maximum height, then the gradient is removed. if($('.iw-content').height() &lt; 140){ $('.iw-bottom-gradient').css({display: 'none'}); } // The API automatically applies 0.7 opacity to the button after the mouseout event. This function reverses this event to the desired value. iwCloseBtn.mouseout(function(){ $(this).css({opacity: '1'}); }); }); } function div_show() { $('#abc').fadeIn(400); } //Function to Hide Popup function div_hide(){ $('#abc').fadeOut(400); } function placeMarker(location, label) { var marker = new google.maps.Marker({ position: location, map: mapCanvas, labelContent : label }); div_hide(); } function setZoomLimit(map, mapTypeId){ //Gets MapTypeRegistry var mapTypeRegistry = map.mapTypes; //Gets the specified MapType var mapType = mapTypeRegistry.get(mapTypeId); //Sets limits to MapType mapType.maxZoom = 15; //It doesn't work with SATELLITE and HYBRID maptypes. mapType.minZoom = 15; } function CSVToArray(strData, strDelimiter ){ // Check to see if the delimiter is defined. If not, // then default to comma. strDelimiter = (strDelimiter || ";"); // Create a regular expression to parse the CSV values. var objPattern = new RegExp( ( // Delimiters. "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" + // Quoted fields. "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" + // Standard fields. "([^\"\\" + strDelimiter + "\\r\\n]*))" ), "gi"); // Create an array to hold our data. Give the array // a default empty first row. var arrData = [[]]; // Create an array to hold our individual pattern // matching groups. var arrMatches = null; // Keep looping over the regular expression matches // until we can no longer find a match. while (arrMatches = objPattern.exec( strData )) { // Get the delimiter that was found. var strMatchedDelimiter = arrMatches[ 1 ]; // Check to see if the given delimiter has a length // (is not the start of string) and if it matches // field delimiter. If id does not, then we know // that this delimiter is a row delimiter. if (strMatchedDelimiter.length &amp;&amp; (strMatchedDelimiter != strDelimiter)) { // Since we have reached a new row of data, // add an empty row to our data array. arrData.push( [] ); } // Now that we have our delimiter out of the way, // let's check to see which kind of value we // captured (quoted or unquoted). if (arrMatches[ 2 ]){ // We found a quoted value. When we capture // this value, unescape any double quotes. var strMatchedValue = arrMatches[ 2 ].replace( new RegExp( "\"\"", "g" ), "\"" ); } else { // We found a non-quoted value. var strMatchedValue = arrMatches[ 3 ]; } // Now that we have our value string, let's add // it to the data array. arrData[ arrData.length - 1 ].push( strMatchedValue ); } // Return the parsed data. return( arrData ); } google.maps.event.addDomListener(window, "load", initialize); &lt;/script&gt; &lt;body&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>/* Author : iMomen Website: www.iMomen.com E-mail : Coder@iMomen.com */ #mapContainer { height: 100%; width: 100%; margin-left: 0px; margin-right: 0px; margin-bottom: 0px; margin-top: 0px; position: relative; } #map { height: 100%; } .gm-style-mtc { display: none; } .gmnoprint { display: none; } #abc { width:100%; height:100%; top:0; left:0; display:none; position:fixed; background-color: rgba(0,0,0, .5); overflow:auto; } div#popupContact { width: 350px; /*can be in percentage also.*/ margin: 0; margin: 0; position: absolute; top: 50%; left: 50%; margin-right: -50%; transform: translate(-50%, -50%); background-color: #ffffff; } div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } html, body { height:100%; width: 100%; margin-left: 0px; margin-right: 0px; margin-bottom: 0px; margin-top: 0px; overflow:hidden; } article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; } a { color:#FF3679; text-decoration: none; } a:hover { text-decoration: underline; } .container { width: 350px; margin-left: auto; margin-right: auto; } .reg_section { padding:0; margin: 10px 0; border-bottom: 1px dotted #eee; } .reg_section h3 { font-size: 13px; margin: 5px 0; color: #C4A2A2; } /* Form */ .register { text-align: center; position: relative; padding: 20px 20px 20px 20px; background: #fff; border-radius: 3px; } .register:before { content: ''; position: absolute; top: -8px; right: -8px; bottom: -8px; left: -8px; z-index: -1; background:rgba(255, 173, 200, 0.08); border-radius:7px; -webkit-border-radius: 7px; } .register h1 { margin: -20px -20px 0; line-height: 40px; font-size: 15px; font-weight: bold; color:#694551; text-align: center; border-bottom:1px solid #EDEDED; border-radius: 3px 3px 0 0; -webkit-box-shadow: 0 1px #f5f5f5; -moz-box-shadow: 0 1px #f5f5f5; box-shadow: 0 1px #f5f5f5; } .register input[type=text], .register input[type=password] ,.register select,.register textarea { width: 278px; } .register p.terms { float: left; line-height: 31px; } .register p.terms label { font-size: 12px; color: #777; cursor: pointer; } .register p.terms input { position: relative; bottom: 1px; margin-right: 4px; vertical-align: middle; } .register-help { margin: 20px 0; font-size: 11px; text-align: center; color:#FFFFFF; } .register-help a { color:#FF3679; text-shadow:0 1px #1E0E13; } :-moz-placeholder { color: #404040 !important; font-size: 13px; } ::-webkit-input-placeholder { color: #ccc; font-size: 13px; } input { font-family:"Trebuchet MS",tahoma; font-size: 14px; } input[type=text], input[type=password] ,.register select,.register textarea { margin: 5px; padding: 0 10px; height: 34px; color: #404040; background: #fff; border-width: 1px; border-style: solid; border-color: #c4c4c4 #d1d1d1 #d4d4d4; border-radius:3px; --webkit-border-radius: 5px; outline:3px solid rgba(200, 105, 137, 0.09); -moz-outline-radius:7px; -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12); -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12); margin:10px 0; } input[type=text]:focus, input[type=password]:focus{ border-color:#FFF7F9; outline-color:rgba(254, 225, 235, 0.7); outline-offset: 0; } input[type=button] { padding:0 0px; height: 29px; width: 100px; font-size: 12px; font-weight: bold; color:#FFFFFF; text-shadow:0 1px #4D1124; border-width: 1px; border-style: solid; border-color:#693647; outline: none; -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box; background-color: #7D0F33; } input[type=button]:active { background: #7D0F33; -webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.2); -moz-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.2); box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.2); } .lt-ie9 input[type=text], .lt-ie9 input[type=password] { line-height: 34px; } .register select { padding:6px 10px; width: 300px; color: #777777; } .register textarea { height: 50px; padding: 10px; color: #404040; } /* About */ .about { margin:10px auto; width: 300px; text-align: center; color:#EEA5BD; font-size: 12px; } .about a { padding: 1px 3px; margin: 0 -1px; color: #fff; text-decoration: none; text-shadow: 0 -1px rgba(0, 0, 0, 0.2); border-radius: 2px; } .about a:hover { color:#2F0916; text-shadow: none; background: #E83671; } .links { zoom: 1; } .links:before, .links:after { content: ""; display: table; } .links:after { clear: both; } .links a { padding: 6px 0; float: left; width: 50%; font-size: 14px; } .gm-style-iw { width: 350px !important; top: 15px !important; left: 0px !important; background-color: #fff; border-radius: 2px 2px 10px 10px; } #iw-container { margin-bottom: 10px; } #iw-container .iw-title { font-family: 'Open Sans Condensed', sans-serif; font-size: 22px; font-weight: 400; padding: 10px; background-color: #7D0F33; color: white; margin: 0; border-radius: 2px 2px 0 0; } #iw-container .iw-content { font-size: 13px; line-height: 18px; font-weight: 400; margin-right: 1px; padding: 15px 5px 20px 15px; max-height: 140px; overflow-y: auto; overflow-x: hidden; } .iw-subTitle { font-size: 16px; font-weight: 700; padding: 5px 0; } .iw-bottom-gradient { position: absolute; width: 326px; height: 25px; bottom: 10px; right: 18px; background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%); background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%); background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%); background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%); } </code></pre>
<javascript><html><google-maps><csv>
2016-04-29 09:51:48
LQ_CLOSE
36,935,828
SQL transaction rollback and commit
<p>I have the below 3 inserts wrapped in a transaction. If any of the inserts fail for any reason I would like the entire transaction rolled back. and if all 3 are successful I would like it commited.</p> <pre><code>BEGIN TRANSACTION INSERT INTO myTable (myColumns ...) VALUES (myValues ...); INSERT INTO myTable (myColumns ...) VALUES (myValues ...); INSERT INTO myTable (myColumns ...) VALUES (myValues ...); COMMIT TRAN </code></pre>
<sql-server><transactions><rollback>
2016-04-29 10:24:02
LQ_CLOSE
36,936,291
PHP single & double quotes in CLI argument
I've write a simple php script file that must execute in CLI and it needs 2 arguments. /usr/local/bin/php myscipt.php arg1 arg2 it works well, but IF I put something like /usr/local/bin/php myscipt.php ar"g1 arg2 or /usr/local/bin/php myscipt.php ar"g1 ar'g2 it do no treat argument like I want. please is there any way to solve this. I've tried all possible functions : strstr, strpos, ... and even loops. Thanks
<shell>
2016-04-29 10:45:41
LQ_EDIT
36,938,509
Angularjs 2 Quickstart
I have tried the angular2 5 Min quickstart from https://angular.io/docs/ts/latest/quickstart.html. All Files were created by copy & past because i am lazy and because of possible faults. I preferred the typescript version. At the end, i must compile and start with "nmp start". i do this as admin. my os is windows 10. After start i get some errors. this is the npm-debug.log: 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe', 1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'start' ] 2 info using npm@2.9.1 3 info using node@v0.12.3 4 verbose node symlink C:\Program Files\nodejs\\node.exe 5 verbose run-script [ 'prestart', 'start', 'poststart' ] 6 info prestart angular2-quickstart@1.0.0 7 info start angular2-quickstart@1.0.0 8 verbose unsafe-perm in lifecycle true 9 info angular2-quickstart@1.0.0 Failed to exec start script 10 verbose stack Error: angular2-quickstart@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" ` 10 verbose stack Exit status 2 10 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:213:16) 10 verbose stack at EventEmitter.emit (events.js:110:17) 10 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14) 10 verbose stack at ChildProcess.emit (events.js:110:17) 10 verbose stack at maybeClose (child_process.js:1015:16) 10 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1087:5) 11 verbose pkgid angular2-quickstart@1.0.0 12 verbose cwd C:\web\angular2-quickstart 13 error Windows_NT 6.3.9600 14 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" 15 error node v0.12.3 16 error npm v2.9.1 17 error code ELIFECYCLE 18 error angular2-quickstart@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" ` 18 error Exit status 2 19 error Failed at the angular2-quickstart@1.0.0 start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '. 19 error This is most likely a problem with the angular2-quickstart package, 19 error not with npm itself. 19 error Tell the author that this fails on your system: 19 error tsc && concurrently "npm run tsc:w" "npm run lite" 19 error You can get their info via: 19 error npm owner ls angular2-quickstart 19 error There is likely additional logging output above. 20 verbose exit [ 1, true ] Can anybody helps me that the quickstart app starts? I also tried to start the index.html in Firefox ( because the .ts files are all translate in .js files ) but nothing happens.
<javascript><angularjs><node.js>
2016-04-29 12:35:40
LQ_EDIT
36,944,611
PHP How to add plus (+) character before double quotes and words without double quotes in string
<p>I have below string :</p> <pre><code>'this is a "text field" need "to replace"' </code></pre> <p>And I want to add plus (+) character before every un-double quotes words and double quotes like below:</p> <pre><code>'+this +is +"text field" +need +"to replace"' </code></pre> <p>is there any way to perform such action? I tried with str_replace and regex but cant figure out how to do it. </p> <p>Thanks in advanced.</p>
<php><regex><preg-replace><preg-match><str-replace>
2016-04-29 17:50:39
LQ_CLOSE
36,946,229
How to remove bootstrap menu from my website?
<p>URL of my website.. <a href="http://www.moonli8photgrphy.move.pk/" rel="nofollow">http://www.moonli8photgrphy.move.pk/</a></p> <p>I'd downloaded bootstrap theme, and this menu of bootstrap is somewhere in the stylesheets, but i can't configure it out. I've edited almost website, but unable to disable this bootstrap menu. So i want to remove it and upload my proper website as soon as i can.</p>
<javascript><jquery><html>
2016-04-29 19:37:09
LQ_CLOSE
36,946,565
What is wrong with this DB Diagram?
<p>Can someone tell me what is wrong with this database diagram?</p> <p><a href="https://i.stack.imgur.com/xJoOu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xJoOu.png" alt="DB Diagram"></a></p>
<sql><sql-server>
2016-04-29 20:00:59
LQ_CLOSE
36,946,724
PHP: How to constantly add to a database
<p>I'll be constantly adding stock prices into a database, But what "settings/variables" do I put into the database to allow it to accept multiple values for a field? So later I can echo the SQL Database out?</p>
<php>
2016-04-29 20:13:27
LQ_CLOSE
36,946,755
Xamarin studio can not start mac osx 10.11.5 beta
I installed Xamarin Studio on my mac. After installation complete (everything seems correct) Xamarin studio does not start :S I click xamarin application and nothing happens. My opration system version is El Capitan 10.11.5 Beta What is that problem? Thanks
<macos><xamarin>
2016-04-29 20:16:04
LQ_EDIT
36,948,311
Complex SQL Query or querries
I looked at other examples, but I don't know enough about SQL to adapt it to my needs. I have a table that looks like this: ID Month NAME COUNT First LAST TOTAL 1 JAN2013 fred 4 2 MAR2013 fred 5 3 APR2014 fred 1 4 JAN2013 Tom 6 5 MAR2014 Tom 1 6 APR2014 Tom 1 This could be in separate queries, but I need 'First' to equal the first month that a particular name is used, so every row with fred would have JAN2013 in the first field for example. I need the 'Last" column to equal the month of the last record of each name, and finally i need the 'total' column to be the sum of all the counts for each name, so in each row that had fred the total would be 10 in this sample data. This is over my head. Can one of you assist?
<sql><ms-access>
2016-04-29 22:18:33
LQ_EDIT
36,948,336
How to use arrays in VBA functions?
<p>I need to do public function that takes values from certain array and computes f(x) function for every x, where f(x) = x^3 + 1/5x +2. <a href="http://i.stack.imgur.com/k8yrC.jpg" rel="nofollow">this is what I am doing but doesnt work</a> </p>
<arrays><vba><function>
2016-04-29 22:21:08
LQ_CLOSE
36,949,214
How to split 4113.52318N in two parts in php
<p>I want to split 4113.52318N in two parts like 41 and 13.52318N And after that I want to remove N from the second value.</p> <p>any help please?</p>
<php><string><split>
2016-04-29 23:59:37
LQ_CLOSE
36,950,044
insert data in a std::map
<p>I have the following container:</p> <pre><code>map&lt;int,string,string&gt; data; </code></pre> <p>I have been trying to store information in that map using the following codes(one at a time) but none of them works.</p> <pre><code>data.insert( m, f, l ); data.insert( map&lt;int,string,string&gt;(m, f, l) ); data.insert( pair&lt;int,string,string&gt;(m, f, l) ); </code></pre> <p>Anyone has any idea how to store data in a std::map? </p> <p>Thank you</p>
<c++><stdmap>
2016-04-30 02:30:19
LQ_CLOSE
36,951,177
how to fix the two button center and right side? im expecting the best answer without using "dp".please guide me
I'm creating login form and i would like to give back button as center and red button at right side. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/back" android:textColor="@color/white" android:id="@+id/button4" android:onClick="onBackClick" android:background="@color/l_green"/> <View android:layout_width="@dimen/activity_horizontal_margin" android:layout_height="match_parent"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/reg" android:textColor="@color/white" android:minWidth="130dp" android:id="@+id/button3" android:onClick="onSigninClick" android:background="@color/l_blue"/>
<android><layout>
2016-04-30 05:34:21
LQ_EDIT
36,951,424
Find position where the member of two lists differs
<p>I have the following two lists of strings with the same size:</p> <pre><code>l1 = ['foo', 'foo','bar','cho'] l2 = ['foo', 'qux','bar','cxx'] * * </code></pre> <p>What I want to do is to find the position where the members differs, yielding:</p> <pre><code>1, 3 </code></pre> <p>How can we do that?</p>
<python>
2016-04-30 06:07:05
LQ_CLOSE
36,951,948
Add User in my andiod app
Hi I Implemented an android app. 1. A Splash screen 2. Then MainActivity - GetSharedPerf - if(sharedpref == empty or null) { * Open activity --> Login Activity - } 3. else { Stay on MainActivity } My Question is After Successful login i need to add new user --> add new user User Id in Shared pref & Switch between Users in MainActivity Note: Simply I need gmail app model for add multiple user ac and switch between users inbox...
<android><login><sharedpreferences>
2016-04-30 07:11:45
LQ_EDIT
36,952,429
How to crawl an ajax generate web page?
<p>i have try to crawl <a href="https://world.taobao.com/search/search.htm?cat=50008090&amp;_ksTS=1461999216322_20&amp;spm=a21bp.7806943.banner_XX_cat.13.UxfRzO&amp;_input_charset=utf-8&amp;navigator=all&amp;json=on&amp;callback=__jsonp_cb&amp;cna=CKNtDjuNxTgCAdIGQMzvfvwH&amp;abtest=_AB-LR517-LR854-LR895-PR517-PR854-PV895_2462" rel="nofollow">https://world.taobao.com/search/search.htm?cat=50008090&amp;_ksTS=1461999216322_20&amp;spm=a21bp.7806943.banner_XX_cat.13.UxfRzO&amp;_input_charset=utf-8&amp;navigator=all&amp;json=on&amp;callback=__jsonp_cb&amp;cna=CKNtDjuNxTgCAdIGQMzvfvwH&amp;abtest=_AB-LR517-LR854-LR895-PR517-PR854-PV895_2462</a></p> <p>but not success, the reponse page source not match the view page,any one know how to do?Thanks</p>
<php><python><web-crawler>
2016-04-30 08:03:46
LQ_CLOSE
36,953,408
Prolog recursive logic
I'm trying to implement a method to work as follows foo(5) = 5^4 + 4^3 + 3^2 + 2^1 + 1^0 = 701 using recursion. I've been trying to follow the logic but I keep getting errors. can someone guide me? (define (foo n) ; size-n problem ( cond ( (= (- n 1) 0 ) ; stopping condition 0 ); return value (else (+ ( expt n (- n 1) ) ( foo (- n 1) ) ) ))) ; size-m problems
<recursion><prolog>
2016-04-30 09:57:25
LQ_EDIT
36,954,135
Python - Code keeps returning an unwanted "None" statement
<p>My code below is returning an unwanted "None" statement. I have searched other questions in hopes to find a solution but I cant seem to figure it out. Any help would be appreciated.</p> <pre><code>def int_mult(no1,no2): try: no3 = int(no1) no3 = int(no2) except ValueError: return print("Error: Invalid Argument Type") no1 = int(round(no1)) no2 = int(round(no2)) return (no1 * no2) print (int_mult(4.49,"apple")) </code></pre>
<python>
2016-04-30 11:13:03
LQ_CLOSE
36,954,187
PHP - Entering data into a database
<p>I've recently trying to add data into a database, (New to php), I've looked over to see where I've gone wrong, but can't find anything. The error is:</p> <pre><code>Unknown column 'FUMUKU' in 'field list' </code></pre> <p>Code:</p> <pre><code>$dbhost = 'localhost'; $dbuser = 'evocityi_admin'; $dbpass = 'password'; $database = 'evocityi_stocks'; $conn = mysql_connect($dbhost, $dbuser, $dbpass, $database); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $Dtime = "30/04/16"; $StockName = "FUMUKU"; $FUMUKUPrice = 1000; $sql = "INSERT INTO stocks". "(Stock,Price, TimeD) ". "VALUES ". "('$StockName,$FUMUKUPrice, $DTime')"; mysql_select_db('evocityi_stocks'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not enter data: ' . mysql_error()); } echo "Entered data successfully\n"; mysql_close($conn); ?&gt; </code></pre> <p>SQL Database: <a href="https://gyazo.com/fc97b686cfea79ea773d1796e912551e" rel="nofollow">https://gyazo.com/fc97b686cfea79ea773d1796e912551e</a></p>
<php><mysql>
2016-04-30 11:18:10
LQ_CLOSE
36,955,251
RCPP - temporary variable
i wanna ask about temporary variable, in this code i want to replace the k-th row of Ynew1 by zero, and in every iteration the value of Ynew1 is updated by X (first value). but in my code not only row of Ynew1 are replace by 0, but the X too. and, unfortunately the result is Ynew1 is matrix all zero (i expected the result just last row has zero value). this is the code : cppFunction(' NumericMatrix cobo(NumericMatrix X){ int n = X.nrow(); NumericMatrix Ynew1(n,1); for (int k=0;k<n;k++){ Ynew1 = X; for(int i=0;i<n;i++){ Ynew1(k,i)=0; } } return(Ynew1); } ')
<c++><r><rcpp>
2016-04-30 13:03:31
LQ_EDIT
36,955,368
How to add hyperlink in this code?
This is a code to show blinking text on webpages. I want to add a hyperlink to the blinking text. How to do that? <script type="text/javascript"> function blinker() { if(document.getElementById("blink")) { var d = document.getElementById("blink") ; d.style.color= (d.style.color=='red'?'white':'red'); setTimeout('blinker()', 500); } } </script> <body onload="blinker();"> <div id="blink">GOOGLE</div> </body> I want to add www.google.com to that GOOGLE . When a user click on that GOOGLE, google.com should open. How to add a hperlink to the above code? Thanks in advance.
<javascript><blogger>
2016-04-30 13:13:20
LQ_EDIT
36,956,395
public DbObject(Context context) { dbHelper = new DictionaryDatabase(context); this.db = dbHelper.getReadableDatabase();
Please Explain the given code , what does it means and how it works. Here "DictionaryDatabse" is class name in which DataBase Name and Version is defined. Ill be thankful to you cordly. public DbObject(Context context) { dbHelper = new DictionaryDatabase(context); this.db = dbHelper.getReadableDatabase();}
<android>
2016-04-30 14:56:26
LQ_EDIT
36,956,830
Error in windows forms
<p>First of all, sorry for my bad english,</p> <p>My teacher gave me some homeworks to do, he told me to make a program with 'windows forms' to order fruits from home, but i have these two errors in the code. These two errors are coming from the rows with three slashes. I hope somebody can help me with this. Thank you.</p> <pre><code> this.tex_shbanane.Location = new System.Drawing.Point(316, 242); this.tex_shbanane.Name = "tex_shbanane"; this.tex_shbanane.ReadOnly = true; this.tex_shbanane.Size = new System.Drawing.Size(70, 20); this.tex_shbanane.TabIndex = 22; /// this.tex_shbanane.TextChanged += new System.EventHandler(this.tex_shbanane_TextChanged); // // tex_shgjithsej // this.tex_shgjithsej.Location = new System.Drawing.Point(316, 268); this.tex_shgjithsej.Name = "tex_shgjithsej"; this.tex_shgjithsej.ReadOnly = true; this.tex_shgjithsej.Size = new System.Drawing.Size(70, 20); this.tex_shgjithsej.TabIndex = 23; this.tex_shgjithsej.TextChanged += new System.EventHandler(this.tex_shgjithsej_TextChanged); // // tex_shtaksa // this.tex_shtaksa.Location = new System.Drawing.Point(316, 294); this.tex_shtaksa.Name = "tex_shtaksa"; this.tex_shtaksa.ReadOnly = true; this.tex_shtaksa.Size = new System.Drawing.Size(70, 20); this.tex_shtaksa.TabIndex = 24; this.tex_shtaksa.TextChanged += new System.EventHandler(this.tex_shtaksa_TextChanged); // // tex_shtransporti // this.tex_shtransporti.Location = new System.Drawing.Point(316, 318); this.tex_shtransporti.Name = "tex_shtransporti"; this.tex_shtransporti.ReadOnly = true; this.tex_shtransporti.Size = new System.Drawing.Size(70, 20); this.tex_shtransporti.TabIndex = 25; /// this.tex_shtransporti.TextChanged += new System.EventHandler(this.tex_shtransporti_TextChanged); </code></pre>
<c#>
2016-04-30 15:36:36
LQ_CLOSE
36,957,088
need to move a variable folder based on date -VBScript
this is what i have. stSourceFolder = "C:\Users\HIRENS\Admin\" & Replace(CStr(Date()),"/",".") stTargetFolder = "C:\Users\HIRENS\Admin\HIRENS\Admin\backup\"& Replace(CStr(),"DDMMYY") Set objFSO = CreateObject("Scripting.FileSystemObject") Set fso = CreateObject("Scripting.FileSystemObject") ' The script will error out if it tries to create a directory that already exist ' so it is better to check for it first and only attempt to create it if it does ' not exist. if not fso.FolderExists(strDirectory) then ' If it gets here then the folder for the current date does not yet exist and ' therefore is created. Set objFolder = fso.CreateFolder(stTargetFolder) end if ' This copies the files and overwrites them if they exist. fso.CopyFolder stSourceFolder, destinationDir, OverwriteExisting ' If you entend to automate this script you should remove or rem out this next line. wscript.echo "Done" 'If the target-folder does not exist then it will be created. objFSO.CopyFolder stSourceFolder, stTargetFolder MsgBox "Folder copied" Set fsoObj = Nothing
<vbscript><directory>
2016-04-30 16:00:56
LQ_EDIT
36,957,630
Wordpress functions.php has a parse error
<p>Hi I ran into a prob while setting up the functions.php file for Wordpress. My localhost server is showing this error: Parse error: syntax error, unexpected 'if' (T_IF) in /Applications/MAMP/htdocs/wdnomads-wp/wp-content/themes/womendigitalnomads/functions.php on line 3</p> <p>I've tried googling and pasting Wordpress' own code, but the error still exists. Not sure what I'm doing wrong.</p> <pre><code>&lt;? php if ( ! isset( $content_width ) ) { $content_width = 660; } </code></pre>
<php><wordpress>
2016-04-30 16:55:37
LQ_CLOSE
36,957,967
CSS elements covering on hover
<p><a href="https://i.stack.imgur.com/LjiSz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LjiSz.png" alt="enter image description here"></a></p> <p>I have some problems with CSS, I want this image cover item below on hover. How can I make this? </p>
<css>
2016-04-30 17:25:37
LQ_CLOSE
36,958,234
How to merge lines split with "\" at the very end with Python?
<p>I am now parsing some text. Some lines are very long such that they are splitted into several sub-lines with a "\" at the very end.</p> <p>I try to use regular expression to merge these sub-lines. However the escaped character "\n" and "\" make me confusing.</p> <p>Can someone show me how to accomplish this task with Python?</p>
<python><regex><string><split>
2016-04-30 17:50:32
LQ_CLOSE
36,958,484
(c#) How would you go about removing whitespace from a string without the use of methods such as .trim or .replace?
I'm also not allowed to use lists. My initial thought process for this was to take the initial string then to turn that into a char array. Then after copy everything that is not a space to a second char array. Then convert that char array back to a string. So quickly it would look something like this; char[] firstArray; char[] secondArray; string someString; for (int i = 0; i < someString.Length; i++) { firstArray = someString.ToCharArray(); secondArray = new char[someString.Length]; for (int j = 0; j < firstArray.Length; j++) { if (firstArray[j] != ' ') { secondArray[j] = firstArray[j]; } } someString = secondArray.ToString(); } But when I initialise the second char array it would contain an extra char with no value if there was a space in it initially, since it was initialised to the same size as the first char array. Would I have to do a similar loop before just to count the amount of non-spaces then initialise secondArray based off that or is there a much simpler way than all of this that I am missing? (Without the use of .trim, .replace(or anything like them) or lists) Any help would be appreciated.
<c#><whitespace>
2016-04-30 18:16:24
LQ_EDIT
36,958,873
crm 2015 unsupported line of code - HTML Resource
I just did an upgrade from CRM 2011 to CRM 2015. I was just wondering if the below line of code is supported in CRM 2015. This piece of code is in a HTML resource. document.getElementById('crmGrid').parentElement.innerHTML=document.frames['grid'].document.getElementById('crmGrid').parentElement.innerHTML; Thanks in advance. Sam
<html><dynamics-crm-2015>
2016-04-30 18:51:21
LQ_EDIT
36,959,007
Distant work for designer
<p><br> I have django project with some additional libs (like geo and etc.) on my pc, and git. And I've a friend, who don't know nothing about programming and development. <br> And my question is: <strong> How can she make design for my project on distant? </strong> <br> She will be a distant designer, and I don't know how to manage her work.</p>
<django><git><design-patterns><development-environment>
2016-04-30 19:04:40
LQ_CLOSE
36,959,304
Can you please look into screenshots (Excel sheets)
[![enter image description here][1]][1] [1]: http://i.stack.imgur.com/ElFlO.png Hi, I don't why my excel workbooks have total 4 sheets but vba shows total 5 sheets in same workbook.
<excel><vba>
2016-04-30 19:32:28
LQ_EDIT
36,959,865
How to write output compiler in java?
<p>Is there a way to make a quine in java, then have some sort of program recognize the output as a program, then run that and give an output, and keep on doing so infinitely? I'm trying to write a self-replicating code and get it to infinitely reproduce itself, thereby technically creating life. I have a superiority complex, I suppose</p>
<java><quine>
2016-04-30 20:24:26
LQ_CLOSE
36,960,115
Regex to remove spaces within square brackets (Java)
<p>I need a regex to remove spaces within square brackets. For example: </p> <ul> <li>add eax [ebp + 8]</li> <li>add eax [esp + 12]</li> </ul> <p>will become </p> <ul> <li>add eax [ebp+8]</li> <li>add eax [esp+12]</li> </ul> <p>Thanks for your assistance.</p>
<java><regex>
2016-04-30 20:51:20
LQ_CLOSE
36,960,395
Pass a URL as a get parameter in php
<pre><code> http://example.com/geturl.php?url=http://example.org/index.php?parafile=1698%3A1562%3A0%3A0&amp;para_action=print_ticket&amp;parafile=dance://here.kodas/print&amp;token=3ec2b0d3e6e0ca152bc024cc3f30f16c </code></pre> <p>So i want each of this parameters in a different varaible in the geturl.php file. I am using the regular get url </p>
<php><url><get>
2016-04-30 21:23:33
LQ_CLOSE
36,961,156
How to embed GoogleMaps into mobile application for real-time navigation?
<p>Take Uber as an example. How can I get that real-time navigation functionality?</p> <p><strong>Thoughts</strong></p> <ol> <li><p>Get list of latitude/longitude waypoints from WayPoints API: <a href="https://developers.google.com/maps/documentation/directions/intro#Waypoints" rel="nofollow">https://developers.google.com/maps/documentation/directions/intro#Waypoints</a> </p></li> <li><p>Use the coordinates from step #1 to draw a polyline: <a href="https://developers.google.com/maps/documentation/android-api/shapes#code_samples" rel="nofollow">https://developers.google.com/maps/documentation/android-api/shapes#code_samples</a></p></li> </ol> <p>However, this would be essentially re-implementing the GoogleMaps app. I would have to adjust the polyline if the user left the path, etc. </p> <p>Is it possible to just embed real-time directions? </p>
<android><ios><google-maps><navigation>
2016-04-30 22:58:20
LQ_CLOSE
36,962,037
What is the regex for checking format of a string
What is the regex for finding if user input is properly formatted? Format should follow: `AAAA-123` or `AAAA123` Where the first 4 characters are letters in the range A-M and the following 3 characters are numbers with a max of 299
<java><regex>
2016-05-01 01:20:44
LQ_EDIT
36,962,372
Read input file until certain line c++
<p>I'm new to programming, so I was wondering...</p> <p>If I have an input file consisting of 100 lines, how do I read only up to line 50 and print out each line?</p> <p>Thanks.</p>
<c++>
2016-05-01 02:19:51
LQ_CLOSE
36,962,469
(Python) Idk what to do
<p>So I was learning how to make a tic tac toe game from a website and when I finished, I couldn't play it because I keep getting the same error, I checked my work and every thing was fine, here's the code</p> <pre><code>import random from time import sleep print "To play this game, you use your 1-9 keys" print "This is layout of each number representing a square" print "7|8|9" print "4|5|6" print "1|2|3" print " " def drawboard(board): #Draws the board print "Board" print '' + board[7] + '|' + board[8] + '|' + board[9] print '' + board[4] + '|' + board[5] + '|' + board[6] print '' + board[1] + '|' + board[2] + '|' + board[3] def inputplayerletter(): #Asks player if they want to be X or O letter = '' while not letter == 'X' or letter == 'O': print "Do you want to be X or O?" letter = raw_input(" ").upper() if letter == 'X': return ['X', 'O'] else: return ['O', 'X'] def whogoesfirst(): #This determines who goes first if random.randint(0,1) == '0': return 'computer' else: return 'player' def playagain(): #Asks player if it wants to play again print "Do you want to play again?(Y/N)" return raw_input("").lower().startswith('y') def makemove(board, letter, move): #When someone makes a move we execute this function board[move] = letter def winner(bo,le): #Determines whose the winner return ((bo[7] == le and bo[8] == le and bo[9] == le) or (bo[4] == le and bo[5] == le and bo[6] == le) or (bo[1] == le and bo[2] == le and bo[3] == le) or (bo[7] == le and bo[4] == le and bo[1] == le) or (bo[8] == le and bo[5] == le and bo[2] == le) or (bo[9] == le and bo[6] == le and bo[3] == le) or (bo[7] == le and bo[5] == le and bo[3] == le) or (bo[9] == le and bo[5] == le and bo[1] == le) def getboardcopy(board): #Creates a copy of the board for the computer AI dupeboard = [] for i in dupeboard: dupeboard.append(i) return dupeboard def isspacefree(board, move): #Checks if space is free. return board[move] == '' def playermove(board): #Where the player inputs his/her move move = '' while move not in '1 2 3 4 5 6 7 8 9'.split() or not isspacefree(board, int(move)): print "your move (Pick from 1-9)" move = raw_input("") return int(move) def choosemovefromlist(board, movelist): #chooses possible moves from list possiblemoves = [] for i in moveslist: if isspacefree(board, i): possiblemoves.append(i) if len(possiblemoves) != 0: return random.choice(possiblemove) else: return None def computerai(board, computerletter): #Computer AI if computerletter == 'X': playerletter = 'O' else: playerletter = 'X' for i in range(1,10): dupe = getboardcopy(board) if isspacefree(copy, i): makemove(board, computerletter, i) if winner(copy, computerletter): return i for i in range(1,10): dupe = getboardcp[y(board) if isspacefree(copy, i): makemove(board, playerletter, i) if winner(copy, playerletter): return i move = choosemovefromlist(board, [1, 3, 7, 9]) if move != None: return move if isspacefree(board, 5): return 5 return choosemovefromlist(board[2,4,6,8]) def isboardfull(board): for i in range(1,10): if isspacefree(board, i): return False return True print "Welcome to Tic Tac Toe!" while True: theboard = [''] * 10 print "Flipping the coin..." sleep(2) turn = whogoesfirst() print "The " + turn + " goes first." gameinprogress = True while gameinprogress: if turn == 'player': drawboard(theboard) move = getplayermove(theboard) makemove = (theboard, playerletter, move) if winner(theboard, playerletter): drawboard(theboard) print "The player wins the game! Congratulations!" gameinprogress = False else: if isboardfull(theboard): drawboard(theboard) print "Tie game! No one wins!" break else: turn = 'computer' else: move = computerai(theboard, computerletter) makemove(theboard, computerletter, move) if winner(theboard, computerletter): drawboard(theboard) print "The computer has beaten the player!" break else: turn = 'player' if not playagain(): break </code></pre> <p>I keep getting an error here:</p> <pre><code>def getboardcopy(board): #Creates a copy of the board for the computer AI dupeboard = [] for i in dupeboard: dupeboard.append(i) return dupeboard def isspacefree(board, move): #Checks if space is free. return board[move] == '' def playermove(board): #Where the player inputs his/her move move = '' while move not in '1 2 3 4 5 6 7 8 9'.split() or not isspacefree(board, int(move)): print "your move (Pick from 1-9)" move = raw_input("") return int(move) def choosemovefromlist(board, movelist): #chooses possible moves from list possiblemoves = [] for i in moveslist: if isspacefree(board, i): possiblemoves.append(i) if len(possiblemoves) != 0: return random.choice(possiblemove) else: return None def computerai(board, computerletter): #Computer AI if computerletter == 'X': playerletter = 'O' else: playerletter = 'X' for i in range(1,10): dupe = getboardcopy(board) if isspacefree(copy, i): makemove(board, computerletter, i) if winner(copy, computerletter): return i for i in range(1,10): dupe = getboardcp[y(board) if isspacefree(copy, i): makemove(board, playerletter, i) if winner(copy, playerletter): return i move = choosemovefromlist(board, [1, 3, 7, 9]) if move != None: return move if isspacefree(board, 5): return 5 return choosemovefromlist(board[2,4,6,8]) def isboardfull(board): for i in range(1,10): if isspacefree(board, i): return False return True print "Welcome to Tic Tac Toe!" </code></pre> <p>even if I remove a defined function here, another error appears. </p> <p>So when I ran the code normally, this is the error I get</p> <pre><code>Traceback (most recent call last): File "python", line 49 def getboardcopy(board): #Creates a copy of the board for the computer AI ^ SyntaxError: invalid syntax </code></pre> <p>So when I remove that defined function from my code, I get this error:</p> <pre><code>Traceback (most recent call last): File "python", line 50 def isspacefree(board, move): #Checks if space is free. ^ SyntaxError: invalid syntax </code></pre> <p>Even if I remove that function too, the same error happens to the function after this function, and then if I remove every single function starting from def getboardcopy, I get an error at my print statement. Then when I remove that I get another error from the while loop. I'm using Python 2.7.2</p>
<python>
2016-05-01 02:39:13
LQ_CLOSE
36,963,121
Using Pattern in java
<p>I'm practicing with Pattern class in java, and, for example, given a String:</p> <pre><code>String text = "1234bbbbAAAAb2222 /*1231232132131221*/ [11] }"; </code></pre> <p>The output should be:</p> <pre><code>Number: 1234 String: bbbbAAAAb Number: 2222 Commment: /*1231232132131221*/ Symbol: [ Number: 11 Symbol: ] Symbol: } </code></pre> <p>How could I do this with Pattern using regex, so everything is printed according to the order in the original text ?</p> <p>My output is not doing in order:</p> <pre><code>Number: 1234 Number: 2222 Number: 11 String: bbbbAAAAb Commment: /*1231232132131221*/ Symbol: [ Symbol: ] Symbol: } </code></pre>
<java><regex><match>
2016-05-01 04:39:55
LQ_CLOSE
36,963,844
Difference between .. and ... in Ruby
<p>What is the difference between .. and ... in a ruby for loop.</p> <pre><code>for num in 1..5 puts num end </code></pre> <p>vs</p> <pre><code>for num in 1...5 puts num end </code></pre> <p>How are those two loops different.</p>
<ruby>
2016-05-01 06:40:10
LQ_CLOSE
36,965,334
Measure voltage using transistor with strange behaviour
<p>I'm facing a problem that is completely strange for me. This is simple, I build a small electronics device and in that one I just set up a voltage bridge devider to obtain battery voltage to be able to indicate what is the level of the battery.</p> <p><strong>Problem description</strong></p> <p><strong>Behaviour</strong>: It works quite fine, means that when battery voltage is decreasing, it decreases on the input ADC on the MCU. The main problem, is that it discharges the battery same when the circuit is turned off.</p> <p><strong>What we tryed</strong>: Ok, we have to find a system that permits to turn off the bridge divider when I turn off the circuit. That's why I simply added a transistor which is driven by the 3.3v regulator of the circuit:</p> <ul> <li>When circuit is ON, 3.3v from the regulator drives a transistor <strong>BC547A (just for test)</strong> on the Base with a 10k resistor.</li> <li>The transistor becomes "passing" (sorry for my english), and provide battery voltage to the bridge divider.</li> <li>We read VBAT2 on the MCU, when system is powered</li> </ul> <p><strong>Strange behaviour</strong>: But... this is not working, we observe that the transistor is acting like a regulator because it seems to be not "passing" enough to provide the voltage variation from the battery. This is the circuit that we are trying.</p> <p><strong>Schematic:</strong> <a href="http://i.stack.imgur.com/xdqLF.jpg" rel="nofollow">Schematic tested using transitor</a></p> <p>And when we measure variation at the input of the MCU, the transistor seems acting like a regulator O_o. It meens that when battery voltage decreases slowly, voltage on the MCU input stay completely constant and stable.</p> <p>Here are the measure that i've done: <a href="http://i.stack.imgur.com/fHhVb.jpg" rel="nofollow">Measure of voltage</a> The blue line is VBAT2 (the one that goes to the MCU), and the red one is the probe that is on the battery +.</p> <p>The battery is a standard single cell lithium ion polymer, whith battery voltage that move from 4.15v (full charge) and 3.1v (discharded).</p> <p>Does someone can help me to solve this problem or explain to me why I observe this behaviour?</p> <p>Thanks for your help.</p>
<electronics>
2016-05-01 09:57:26
LQ_CLOSE
36,965,408
Can it improve performance when I query specified partition table using parallel,thanks in advance
SELECT /*+ PARALLEL(A,5)*/ A.USER_ID, A.RES_TYPE, A.RES_ID, A.LIMIT_TAG, A.FEEPOLICY_INS_ID, A.FEEPOLICY_ID, TO_NUMBER(TO_CHAR(A.START_DATE, 'YYYYMMDDHH24MISS')) AS START_DATE, TO_NUMBER(TO_CHAR(A.END_DATE, 'YYYYMMDDHH24MISS')) AS END_DATE FROM TF_B_USER_FREECDR_HASH PARTITION(PAR_TF_B_USER_FREECDR_0) A ORDER BY A.USER_ID
<oracle><performance><parallel-processing><query-optimization><partition>
2016-05-01 10:06:43
LQ_EDIT
36,966,262
ls and ls -la not displaying a file that I am trying to compile (Java)
<p><a href="http://i.stack.imgur.com/QgqND.png" rel="nofollow">ls and ls -la commands are not displaying files that I want to compile. Why are my files not showing up? </a></p>
<java><terminal><ls>
2016-05-01 11:43:21
LQ_CLOSE
36,966,727
INLINE JAVASCRIPT ENABLE/DISABLE SELECT AND TEXT BOX ON CLICK RADIO BUTTON
> Hello i am trying inline script to enable disable with radio button > but it is not working how to do that? <form> <select id="mySelect"> <option>Apple</option> <option>Pear</option> <option>Banana</option> <option>Orange</option> </select> <br><br> <input type="radio" name="ph" onclick=" document.getElementById("mySelect").disabled=true;" value="Disable list">DISABLE <input type="radio" name="ph" onclick="enable()" value="Enable list">ENABLE </form>
<javascript><jquery><html>
2016-05-01 12:38:15
LQ_EDIT
36,967,200
I cant figure out my error :/
Okay so, this is probably one of those mistakes that is so simple that its mindblowing. Im not sure what the problem is but the program is meant to receive a number, 1 digit at a time, use that digit as an index for the array to check if its true, if so then break out of the loop and if not, set it to true and continue scanning the other digits til it reaches the last. Its only supposed to tell if a digit was repeated or not at this point. I have this code so far but i cant seem to get it working. Can anyone help me? i noticed while doing my own troubleshooting by testing the value of the variables after execution that sometimes the other digits aren't even read, only the first entered and i dont know why Heres the code: #include <stdio.h> #define true 1 #define false 0 typedef int bool; int main(void) { // Variables to contain the seen digits bool seendig[10] = { false }; long entered; int container; printf("This Program Is Designed To Determine If Any Digits Has Been Repeated!\nPlease Enter a Number: "); scanf_s("%1d", &entered); while (entered > 0) { container = entered; if (seendig[container]) { break; } seendig[container] = true; entered /= 10; } if (entered > 0) // then digit is repeated printf("\nThe Digit Was Repeated\n\n"); else { printf("The Digit Was Not Repeated\n\n"); } system("pause"); return 0; }
<c><syntax-error>
2016-05-01 13:26:40
LQ_EDIT
36,969,446
Why is my C++ program not working?
<p>I am trying to build a program that reads numbers from "bac.txt" and returns the 2 digit number/numbers (10,11,12,...,99) that appear most frequently. For example if the file "bac.txt" contains 393 17775787 72194942 12121774 it will return 77 and 21. I have managed to build a working function <code>counter(int n)</code> that can count how many times <code>n</code> is found in the file and returns <code>i</code> which is the number of times <code>n</code> has been found. Now I can't seem to find a way to print to the screen the number/numbers that are found most often. I tried to use some kind of for loop but it doesn't work. Here is my code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; using namespace std; int counter(int n){ int i=0,j=0; char x1=n/10+'0'; char x2=n%10+'0'; char a; char b=NULL; fstream fisier("bac.txt", fstream::in); while (fisier &gt;&gt; noskipws &gt;&gt; a) { if(b==x1&amp;&amp;a==x2) i++; b=a; } return i; } int main() { int v[90]; int v1[90]; int i,maxim=0,nr; for(i=10;i&lt;100;i++) { v[i]=counter(i); if(v[i]&gt;maxim)maxim=v[i]; } for(i=10;i&lt;100;i++) if(v[i]==maxim) cout&lt;&lt;i; } </code></pre>
<c++>
2016-05-01 17:10:12
LQ_CLOSE
36,970,707
How give a app NAME instzead of "sudo sails lift"???!!! own app Name or commandline??? Please!!!``
How give a app NAME instzead of "sudo sails lift"???!!! own app Name or commandline??? Please!!!`` how can i create a own app name instead of this "sails lift" and with out the boat (grafic) there, when do you lift the app?... how to create a own commandline for sails app? liek app name etc.? i get this everytime.. but i want change it to a own grafic with out the boat and sails lift...? how doing that and where ? please help! info: Starting app... info: info: .-..-. info: info: Sails <| .-..-. info: v0.11.5 |\ info: /|.\ info: / || \ info: ,' |' \ info: .-'.-==|/_--' info: `--'-------' info: __---___--___---___--___---___--___ info: ____---___--___---___--___---___--___-__ info: info: Server lifted in `/Users/cyberspace/Documents/Apps/www.project.com/project/myapp` info: To see your app, visit http://localhost info: To shut down Sails, press <CTRL> + C at any time.
<sails.js>
2016-05-01 19:00:41
LQ_EDIT
36,972,469
Two similar programs both have errors on final line
<p>I have written two similar programs for my programming class. I have shared the code for both programs due to them being similar in nature and both have compiler issues on the final line with return0; For the first string of code the error I receive is "expected a declaration" and "syntax error: 'return'". For the second code I receive the errors "return value type does not match the function type" and " 'display': 'void' function returning a value. I have deleted and added {} at different parts of both codes and tried to rearrange the code. Thanks for help in advance.</p> <p>Code 1</p> <pre><code>#include "stdafx.h" #define nums 7 void display(int *); int main() { int channels[nums] = { 2,4,5,7,9,11,14 }; printf("Channels: "); display(channels); } void display(int *channels) { int i; for (i = 0; i &lt; nums; i++); { printf("%d", *(channels + i)); } } return 0; </code></pre> <p>code 2 </p> <pre><code>#include "stdafx.h" #define nums 7 void display(int *); int main() { int channels[nums] = { 2,4,5,7,9,11,13 }; printf("channels: "); display(channels); } void display(int *channels) { int i; for (i = 0; i &lt; nums; i++) { printf("%d", *channels); *channels++; } return 0; } </code></pre>
<c>
2016-05-01 22:02:07
LQ_CLOSE
36,973,620
C++ how to handle class types when writing a scripting language
<p>I've been stumped by this for some time although I believe it may be quite simple. I am writing a simple programming language in c++ and I can't figure out the best way to handle variable types withing my language.</p> <p>For example I may have eight different variable types including string, number, bool, table, etc! I need to know the best way to store these within c++ because they are all different types, which means all different classes! I will have many more than eight types though. The code is line based with a compiler. Please help!</p>
<c++>
2016-05-02 00:46:55
LQ_CLOSE
36,974,315
Transitioning from sqlalchemy to postgres database
I've been using Flask with sqlalchemy but I've transitioned to setting up my own postgres databases and using psycopg2 to insert and return values from my databases. I was wondering how the classes in my Model.py should change now that I'm no longer using the databases set up by sqlalchemy and whether I need to set up a db object at all anymore. Setting up a db object: app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'data.sqlite') app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True db.SQLALCHEMY(app) A sample of a class in my Model file: class User(UserMixin, db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(64), unique=True, index=True) username = db.Column(db.String(64), unique=True, index=True) role_id = db.Column(db.Integer, db.ForeignKey('roles.id')) zipAddress = db.Column(db.String(64))
<postgresql><flask><flask-sqlalchemy><psycopg2>
2016-05-02 02:45:13
LQ_EDIT