Daily Archives

Articles indexed Thursday March 22 2012

Page 8/18 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • How come $(this) is undefined after ajax call

    - by JohnnyQ
    I am doing an ajax request when an anchor tag is clicked with an ID set to href. Btw, this anchor tag is dynamically created. <a href="983" class="commentDeleteLink">delete</a> When the anchor tag is clicked the following code is executed: $('.commentDeleteLink').live('click', function(event) { event.preventDefault(); var result = confirm('Proceed?'); if ( result ) { $.ajax({ url: window.config.AJAX_REQUEST, type: "POST", data: { action : 'DELCOMMENT', comment : $('#commentText').val(), comment_id : $(this).attr('href') }, success: function(result) { alert($(this).attr('href')); //$(this).fadeOut(slow); } }); } }); When I tried to display $(this).attr('href') it says it's "undefined". What I really want to do is fadeOut the anchor tag but when I investigated the value of $(this) it is "undefined". What could be wrong with the snippet above?

    Read the article

  • using araxis merge for folder comparison on git branches (OSX)

    - by memo
    I know how to setup araxis merge to be my git diff / merge tool, so if I do git difftool it automatically launches araxis merge. However if I do git difftool upstream/master (to see all the differences between current branch and upstream/master), it launches the app one by one for every single file that is different. Is there a way of setting it up so I can get a folder comparison type view, and then go down and view each file diff as I choose? i.e. similar to this http://www.araxis.com/merge_mac/overview2.html The only way I've found to do this is to clone my repo into a new folder, switch to the branch there, and then do a normal araxis merge folder comparison.

    Read the article

  • Symfony2 Include in html in Twig

    - by Haritz
    I am developing an application usin Symfony2 and twig for templates. I am using a 3 level structure for templates. Base.html.twig, layout.html.twig and childtemplate.html.twig. The problem is I am trying to include one example.html (common html file) in the next child template by using include but it doesnt work properly. Where can the problem be? {# src/Anotatzailea/AnotatzaileaBundle/Resources/views/Page/testuaanotatu.html.twig #} {% extends 'AnotatzaileaAnotatzaileaBundle::layout.html.twig' %} {% block title %}Testua anotatu{% endblock%} {% block body %} {% include "var/www/Symfony/web/example.html" %} {% endblock %}

    Read the article

  • Regex issue with comma's telling me there are 6 args, instead of intended 4

    - by Azher
    I have a scenario outline table that looks like the following: Scenario Outline: Verify Full ad details Given I am on the xxx classified home page And I have entered <headline> in the search field & clicked on search When I click on full details Then I should see <headline> <year> <mileage> <price> displaying correctly and successfully Examples: |headline |year |mileage |price | |alfa romeo 166 |2005 |73,000 |6,990 | When I run my scenario it spits out that I have 6 args. But what I thought, I should only have 4 args: headline, year, mileage and price. I am thinking that it is taking the comma's and what is before and after it as two seperate args. Is there any way that I can make cucumber think that there are only 4 args with the example below? I have looked at messing around with regex but I dont seem to be getting anywhere. Any help would be greatly appreciated.

    Read the article

  • Silverlight performance with many loaded controls

    - by gius
    I have a SL application with many DataGrids (from Silverlight Toolkit), each on its own view. If several DataGrids are opened, changing between views (TabItems, for example) takes a long time (few seconds) and it freezes the whole application (UI thread). The more DataGrids are loaded, the longer the change takes. These DataGrids that slow the UI chanage might be on other places in the app and not even visible at that moment. But once they are opened (and loaded with data), they slow showing other DataGrids. Note that DataGrids are NOT disposed and then recreated again, they still remain in memory, only their parent control is being hidden and visible again. I have profiled the application. It shows that agcore.dll's SetValue function is the bottleneck. Unfortunately, debug symbols are not available for this Silverlight native library responsible for drawing. The problem is not in the DataGrid control - I tried to replace it with XCeed's grid and the performance when changing views is even worse. Do you have any idea how to solve this problem? Why more opened controls slow down other controls? I have created a sample that shows this issue: http://cenud.cz/PerfTest.zip UPDATE: Using VS11 profiler on the sample provided suggests that the problem could be in MeasureOverride being called many times (for each DataGridCell, I guess). But still, why is it slower as more controls are loaded elsewhere? Is there a way to improve the performance?

    Read the article

  • Constantly getting ...DeviceMonitor] Failed to start monitoring

    - by makar
    I find that after running or debugging my application a few times using eclipse, that I get the above output in my console (in red) and I get no feedback from Dalvik as to the connection status to my phone is going. My application will still debug etc. I just get nothing useful in my Console. Any ideas how to fix this? It appears intermittent. It starts doing it after a few minutes, continues to do it for quite a while and occasionally goes away again. This has happened on my last laptop and now on my new laptop with a completely fresh install etc.

    Read the article

  • SOAPUI Extract data from SOAP Response and use in REST request

    - by Adrian
    I have been looking at the answer to this question: Pulling details from response to new request SoapUI which is similar to what I am looking for but I can't get it to work. I have a small SOAPUI testsuite and I need to extract a value from the response of a SOAP request and then use this value in a subsequent REST request. The response to my SOAP request is: <ns0:session xmlns:ns0="http://www.someurl.com/la/la/v1_0"> <token>AQIC5wM2xAAIwMg==#</token> </ns0:session> so I need the token to use in my REST request. I know it involves using Property Transfer and some XPath / XQuery but I just can't get it right. At the moment my property transfer window points to Source: SOAP test Property: Response and has data(/session/token/text()) in the text box. In target it has Target: REST testcase Property: newProp and I have Use XQuery checked. Any help greatly appreciated. Thanks, Adrian

    Read the article

  • File Segmentation when trying to write in a file

    - by user1286390
    I am trying in C language to use the method of bisection to find the roots of some equation, however when I try to write every step of this process in a file I get the problem "Segmentation fault". This might be an idiot fault that I did, however I have been trying to solve this for a long time. I am compiling using gcc and that is the code: #include <stdio.h> #include <stdlib.h> #include <math.h> #define R 1.0 #define h 1.0 double function(double a); void attractor(double *a1, double *a2, double *epsilon); void attractor(double *a1, double *a2, double *epsilon) { FILE* bisection; double a2_copia, a3, fa1, fa2; bisection = fopen("bisection-part1.txt", "w"); fa1 = function(*a1); fa2 = function(*a2); if(function(*a1) - function(*a2) > 0.0) *epsilon = function(*a1) - function(*a2); else *epsilon = function(*a2) - function(*a1); fprintf(bisection, "a1 a2 fa1 fa2 epsilon\n"); a2_copia = 0.0; if(function(*a1) * function(*a2) < 0.0 && *epsilon >= 0.00001) { a3 = *a2 - (*a2 - *a1); a2_copia = *a2; *a2 = a3; if(function(*a1) - function(*a2) > 0.0) *epsilon = function(*a1) - function(*a2); else *epsilon = function(*a2) - function(*a1); if(function(*a1) * function(*a2) < 0.0 && *epsilon >= 0.00001) { fprintf(bisection, "%.4f %.4f %.4f %.4f %.4f\n", *a1, *a2, function(*a1), function(*a1), *epsilon); attractor(a1, a2, epsilon); } else { *a2 = a2_copia; *a1 = a3; if(function(*a1) - function(*a2) > 0) *epsilon = function(*a1) - function(*a2); else *epsilon = function(*a2) - function(*a1); if(function(*a1) * function(*a2) < 0.0 && *epsilon >= 0.00001) { fprintf(bisection, "%.4f %.4f %.4f %.4f %.4f\n", *a1, *a2, function(*a1), function(*a1), *epsilon); attractor(a1, a2, epsilon); } } } fa1 = function(*a1); fa2 = function(*a2); if(function(*a1) - function(*a2) > 0.0) *epsilon = function(*a1) - function(*a2); else *epsilon = function(*a2) - function(*a1); fprintf(bisection, "%.4f %.4f %.4f %.4f %.4f\n", a1, a2, fa1, fa2, epsilon); } double function(double a) { double fa; fa = (a * cosh(h / (2 * a))) - R; return fa; } int main() { double a1, a2, fa1, fa2, epsilon; a1 = 0.1; a2 = 0.5; fa1 = function(a1); fa2 = function(a2); if(fa1 - fa2 > 0.0) epsilon = fa1 - fa2; else epsilon = fa2 - fa1; if(epsilon >= 0.00001) { fa1 = function(a1); fa2 = function(a2); attractor(&a1, &a2, &epsilon); fa1 = function(a1); fa2 = function(a2); if(fa1 - fa2 > 0.0) epsilon = fa1 - fa2; else epsilon = fa2 - fa1; } if(epsilon < 0.0001) printf("Vanish at %f", a2); else printf("ERROR"); return 0; } Thanks anyway and sorry if this question is not suitable.

    Read the article

  • WebClient on WP7 - Throw "A request with this method cannot have a request body"

    - by Peter Hansen
    If I execute this code in a Consoleapp it works fine: string uriString = "http://url.com/api/v1.0/d/" + Username + "/some?amount=3&offset=0"; WebClient wc = new WebClient(); wc.Headers["Content-Type"] = "application/json"; wc.Headers["Authorization"] = AuthString.Replace("\\", ""); string responseArrayKvitteringer = wc.DownloadString(uriString); Console.WriteLine(responseArrayKvitteringer); But if I move the code to my WP7 project like this: string uriString = "http://url.com/api/v1.0/d/" + Username + "/some?amount=3&offset=0"; WebClient wc = new WebClient(); wc.Headers["Content-Type"] = "application/json"; wc.Headers["Authorization"] = AuthString.Replace("\\", ""); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); wc.DownloadStringAsync(new Uri(uriString)); void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { MessageBox.Show(e.Result); } I got the exception: A request with this method cannot have a request body. Why? The solution is to remove the Content-type: string uriString = "http://url.com/api/v1.0/d/" + Username + "/some?amount=3&offset=0"; WebClient wc = new WebClient(); //wc.Headers["Content-Type"] = "application/json"; wc.Headers["Authorization"] = AuthString.Replace("\\", ""); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); wc.DownloadStringAsync(new Uri(uriString)); void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { MessageBox.Show(e.Result); }

    Read the article

  • Binary Search Tree - Postorder logic

    - by daveb
    I am looking at implementing code to work out binary search tree. Before I do this I was wanting to verify my input data in postorder and preorder. I am having trouble working out what the following numbers would be in postorder and preorder I have the following numbers 4, 3, 14 ,8 ,1, 15, 9, 5, 13, 10, 2, 7, 6, 12, 11, that I am intending to put into an empty binary tree in that order. The order I arrived at for the numbers in POSTORDER is 2, 1, 6, 3, 7, 11, 12, 10, 9, 8, 13, 15, 14, 4. Have I got this right? I was wondering if anyone here would be able to kindly verify if the postorder sequence I came up with is indeed the correct sequence for my input i.e doing left subtree, right subtree and then root. The order I got for pre order (Visit root, do left subtree, do right subtree) is 4, 3, 1, 2, 5, 6, 14 , 8, 7, 9, 10, 12, 11, 15, 13. I can't be certain I got this right. Very grateful for any verification. Many Thanks

    Read the article

  • wpftoolkit DataGridTemplateColumn Template binding

    - by Guillaume
    I want my datagrid columns to share a cell/celledit template. I have the solution do that (thanks to WPF DataGridTemplateColumn shared template?). Now what I would love to is improving the readability by avoiding all the node nesting. My current view looks like that: <wpftk:DataGrid ItemsSource="{Binding Tests}" AutoGenerateColumns="False"> <wpftk:DataGrid.Resources> <DataTemplate x:Key="CustomCellTemplate"> <TextBlock Text="{TemplateBinding Content}"/> </DataTemplate> <DataTemplate x:Key="CustomCellEditingTemplate"> <TextBox Text="{TemplateBinding Content}"></TextBox> </DataTemplate> </wpftk:DataGrid.Resources> <wpftk:DataGrid.Columns> <wpftk:DataGridTemplateColumn Header="Start Date"> <wpftk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <ContentPresenter ContentTemplate="{StaticResource CustomCellTemplate}" Content="{Binding StartDate}"/> </DataTemplate> </wpftk:DataGridTemplateColumn.CellTemplate> <wpftk:DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <ContentPresenter ContentTemplate="{StaticResource CustomCellEditingTemplate}" Content="{Binding StartDate}"/> </DataTemplate> </wpftk:DataGridTemplateColumn.CellEditingTemplate> </wpftk:DataGridTemplateColumn> <!--and again the whole block above for each columns...--> </wpftk:DataGrid.Columns> </wpftk:DataGrid> What I would like to achieve is to bind the value at the DataGridTemplateColumn level and propagate it to the template level. Anyone know how to do that? What I tried to do is something like that: <wpftk:DataGrid ItemsSource="{Binding Tests}" AutoGenerateColumns="False"> <wpftk:DataGrid.Resources> <DataTemplate x:Key="CustomCellTemplate"> <TextBlock Text="{Binding}"/> </DataTemplate> <DataTemplate x:Key="CustomCellEditingTemplate"> <TextBox Text="{Binding}"></TextBox> </DataTemplate> </wpftk:DataGrid.Resources> <wpftk:DataGrid.Columns> <wpftk:DataGridTemplateColumn Header="Start Date" Binding="{Binding StartDate}" CellTemplate="{StaticResource CustomCellTemplate}" CellEditingTemplate="{StaticResource CustomCellEditingTemplate}"/> <wpftk:DataGridTemplateColumn Header="End Date" Binding="{Binding EndDate}" CellTemplate="{StaticResource CustomCellTemplate}" CellEditingTemplate="{StaticResource CustomCellEditingTemplate}"/> </wpftk:DataGrid.Columns> </wpftk:DataGrid> Obviously the binding porperty is not a valid property of the DataGridTemplateColumn but maybe by playing with the datacontext and some relative source could do the trick but frankly I can't find a way to implement that. Not sure if what I want is possible and i'm willing to accept a "no way you can do that" as an answer NOTE: The TextBlock/TextBox in the template is just for test (the real template is much more complex) DataGridTextColumn will not do the trick Thanks in advance

    Read the article

  • How to open a pdf on the iPad from an AIR for iOS app

    - by Dennis Flood
    I am making an AIR for iOS app that can download pdfs. I do not want to display the pdf in the app itself but want the default pdf-viewer (iBooks) to launch and show the pdf. How can this be done. I am aware that navigateToURL can be used to open a file with the uri scheme of iBooks. But i dont know how to tell iBooks to look in the app-directory of my app. (Or is there some secret directory to place the file in from within the app - where iBooks can find it) Any pointers or help would be greatly appreciated as this is somewhat of a show stopper.

    Read the article

  • Android Alert Dialog Extract User Choice Radio Button?

    - by kel196
    Apologies for any coding ignorance, I am a beginner and am still learning! I am creating a quiz app which reads questions off a SQL database and plots them as points on a google map. As the user clicks each point, an alert dialog appears with radio buttons to answer some question. My radiobuttons are in CustomItemizedOverlay file and when I click submit, I want to be able to send the user choice back to the database, save it and return to the user if their answer is correct. My question is this, how do I pass the user choice out once the submit button has been clicked? I tried making a global variable to read what was selected to no avail. Any suggestions would be appreciated! If I need to post any other code, please ask and I will do so ASAP! package uk.ac.ucl.cege.cegeg077.uceskkw; import java.util.ArrayList; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.drawable.Drawable; import android.widget.Toast; import com.google.android.maps.ItemizedOverlay; import com.google.android.maps.OverlayItem; public class CustomItemizedOverlay2 extends ItemizedOverlay<OverlayItem> { private ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>(); private Context context; public CustomItemizedOverlay2(Drawable defaultMarker) { super(boundCenterBottom(defaultMarker)); } public CustomItemizedOverlay2(Drawable defaultMarker, Context context) { this(defaultMarker); this.context = context; } @Override protected OverlayItem createItem(int i) { return mapOverlays.get(i); } @Override public int size() { return mapOverlays.size(); } @Override protected boolean onTap(int index) { OverlayItem item = mapOverlays.get(index); // gets the snippet from ParseKMLAndDisplayOnMap and splits it back into // a string. final CharSequence allanswers[] = item.getSnippet().split("::"); AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.setIcon(R.drawable.easterbunnyegg); dialog.setTitle(item.getTitle()); dialog.setSingleChoiceItems(allanswers, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Toast.makeText(context, "You have selected " + allanswers[whichButton], Toast.LENGTH_SHORT).show(); } }); dialog.setPositiveButton(R.string.button_submit, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); // int selectedPosition = ((AlertDialog) // dialog).getListView().getCheckedItemPosition(); Toast.makeText(context, "hi!", Toast.LENGTH_SHORT) .show(); } }); dialog.setNegativeButton(R.string.button_close, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); // on cancel button action } }); AlertDialog question = dialog.create(); question.show(); return true; } public void addOverlay(OverlayItem overlay) { mapOverlays.add(overlay); this.populate(); } }

    Read the article

  • why am i getting a null pointer when converting string to int array?

    - by Sackling
    My main method: public static void main(String[] args) { Scanner input = new Scanner(System.in); String string1; string1 = input.next(); LargeInteger firstInt = new LargeInteger(string1); System.out.printf("First integer: %s \n", firstInt.display()); } LargeInteger class: public class LargeInteger { private int[] intArray; //convert the strings to array public LargeInteger(String s) { for (int i = 0; i < s.length(); i++) { intArray[i] = Character.digit(s.charAt(i), 10); // in base 10 } } //display the strings public String display() { String result = ""; for (int i = 0; i < intArray.length; i++) { result += intArray[i]; } return result.toString(); } }

    Read the article

  • How can I write a unit test to determine whether an object can be garbage collected?

    - by driis
    In relation to my previous question, I need to check whether a component that will be instantiated by Castle Windsor, can be garbage collected after my code has finished using it. I have tried the suggestion in the answers from the previous question, but it does not seem to work as expected, at least for my code. So I would like to write a unit test that tests whether a specific object instance can be garbage collected after some of my code has run. Is that possible to do in a reliable way ? EDIT I currently have the following test based on Paul Stovell's answer, which succeeds: [TestMethod] public void ReleaseTest() { WindsorContainer container = new WindsorContainer(); container.Kernel.ReleasePolicy = new NoTrackingReleasePolicy(); container.AddComponentWithLifestyle<ReleaseTester>(LifestyleType.Transient); Assert.AreEqual(0, ReleaseTester.refCount); var weakRef = new WeakReference(container.Resolve<ReleaseTester>()); Assert.AreEqual(1, ReleaseTester.refCount); GC.Collect(); GC.WaitForPendingFinalizers(); Assert.AreEqual(0, ReleaseTester.refCount, "Component not released"); } private class ReleaseTester { public static int refCount = 0; public ReleaseTester() { refCount++; } ~ReleaseTester() { refCount--; } } Am I right assuming that, based on the test above, I can conclude that Windsor will not leak memory when using the NoTrackingReleasePolicy ?

    Read the article

  • java.lang.NoClassDefFoundError: com/google/appengine/tools/enhancer/Enhance

    - by user1204337
    I am new to GAE, I follow the instructions on http://code.google.com/eclipse/docs/install-eclipse-3.7.html. I got the installation and registration done pretty fast. But when I tried to build the helloWorld project in Eclipse, before I can do anything, Eclipse gives me an error says "java.lang.NoClassDefFoundError: com/google/appengine/tools/enhancer/Enhance" and it is very weird. Because when you expand the app engine sdk, you can easily find the Enhance class under related jar file. I also tried Enhance e = null; and it is working. It seems that my eclipse just cannot find it. I don't know why it is not working, I am using JDK1.6, I reinstall my eclipse and the google plugins, I even disabled my firewall. Please help!!!

    Read the article

  • Finding users near other user

    - by Bunny Rabbit
    what algorithms should I explore to implement a feature which lets a user find other user located near him , the latitude and the longitudes of all the user are known in advance and are fixed [not dynamic]. Also i believe that there should be a better way to store such data then simply storing the lat , long of the user against his user id in a database.What are the efficient ways to handle this ?

    Read the article

  • MAAttachedWindow hide

    - by Montecorte
    I had the same problem that The-Kenny at this post but I fixed it adding the windowDidResignKey: method on the MAAttachedWindow.m, but now my problem is that when I click outside the StatusBar item keeps blue background and when I click another time on the status item it goes normally and I have to click a second time on it to show the window. I tried to add a method in the CustomView (the view of the status item) that do the same thing that te mouseDown method: - (void)mouseDown:(NSEvent *)event { NSRect frame = [[self window] frame]; NSPoint pt = NSMakePoint(NSMidX(frame), NSMidY(frame)); NSLog(@"%g,%g",pt.x,pt.y); clicked = !clicked; [controller toggleAttachedWindowAtPoint:pt]; [self setNeedsDisplay:YES];} my method is: - (void)windowDidResignKey { NSLog(@"Resigned"); NSRect frame = [[self window] frame]; NSPoint pt = NSMakePoint(NSMidX(frame), NSMidY(frame)); NSLog(@"%g,%g",pt.x,pt.y); clicked = !clicked; [controller toggleAttachedWindowAtPoint:pt]; [self setNeedsDisplay:YES];} I call this method in the windowDidResignKey that I have defined on MAAttachedWindow.m, but this method dont call correctly the toggleAttachedWindowAtPoint method, I dont know exactly why, it's only called when I click another time over the status item If anybody knows how to do that any help would be fine. Thank you so much :)

    Read the article

  • Generating an array of functions?

    - by Wordpressor
    I have a few PHP files filled with multiple functions. Let's call them functions1.php, functions2.php, functions3.php: function function_something( $atts ) { extract( something_atts( array( 'foo' => 'bar', 'bar' => 'foo, ), $atts ) ); return 'something'; } I'm loading these files within all_functions.php like this: require_once('functions1.php'); require_once('functions2.php'); require_once('functions3.php'); I'm wondering if it's possible to create an array of all these functions and their attributes? I'm thinking about something like: function my_functions() { require_once('functions1.php'); require_once('functions2.php'); require_once('functions3.php'); } And then some foreach loop, but I'm not sure how should it look like after all. I know this probably looks tricky, but I'm just curious if I'm able to list all my WordPress shortcodes without PHP's Reflection API :)

    Read the article

  • Populate struct values with function argument

    - by adohertyd
    I am working on a program and part of it requires me to create a struct called DETAILS with the fields name, age, and height. I want to populate the record with data using a function argument. When I run my code I get compiler errors. I have put the errors in comment form beside the lines it is returned for but I can't fix them. Really could do with some help here guys thanks so much. Here is my code: #include <cstdlib> #include <iostream> #include <iomanip> using namespace std; const int LEN=100; struct DETAILS { char name[LEN]; int age; double height; }; person fillperson(struct DETAILS, char[LEN], int, double); int main() { struct person David; fillperson(David, "David Greene", 38, 180.0); //deprecated conversion from string constant to char * [-Wwrite-Strings] } person fillperson(struct DETAILS, char[LEN] name, int age, double height) //expected , or ... before 'name' { cin>>David.name>>name; cin>>David.age>>age; cin>>David.height>>height; cout<<"Done"<<endl; }

    Read the article

  • How to convert a url to a browser like url? ( ...%20... )

    - by Kaoukkos
    I want to get data using CURL but I have a problem. When I set the url like this $url = "https://graph.facebook.com/fql?q=SELECT name FROM page"; // continues I do not have anything returned. When I copy the browser url, this is $url = "https://graph.facebook.com/fql?q=SELECT%20name%20FROM%20page"; I get the results through CURL. I tried htmlentities and htmlspecialchars without luck. What am I missing here? $ch = curl_init($url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $content = curl_exec($ch);

    Read the article

  • How do I read from a file consists of city names and coordinates/Populations and create functions to get the coordinates and population?

    - by Braybray
    I'm using Python, and I have a file which has city names and information such as names, coordinates of the city and population of the city: Youngstown, OH[4110,8065]115436 Yankton, SD[4288,9739]12011 966 Yakima, WA[4660,12051]49826 1513 2410 Worcester, MA[4227,7180]161799 2964 1520 604 Wisconsin Dells, WI[4363,8977]2521 1149 1817 481 595 How can I create a function to take the city name and return a list containing the latitude and longitude of the given city? fin = open ("miles.dat","r") def getCoordinates cities = [] for line in fin: cities.append(line.rstrip()) for word in line: print line.split() That's what I tried now; how could I get the coordinates of the city by calling the names of the city and how can I return the word of each line but not letters? Any help will be much appreciated, thanks all.

    Read the article

  • python len calculation

    - by n00bz0r
    I'm currently trying to build a RDP client in python and I came across the following issue with a len check; From: http://msdn.microsoft.com/en-us/library/cc240836%28v=prot.10%29.aspx "81 2a - ConnectData::connectPDU length = 298 bytes Since the most significant bit of the first byte (0x81) is set to 1 and the following bit is set to 0, the length is given by the low six bits of the first byte and the second byte. Hence, the value is 0x12a, which is 298 bytes." This sounds weird. For normal len checks, I'm simply using : struct.pack("h",len(str(PacketLen))) but in this case, I really don't see how I can calculate the len as described above. Any help on this would be greatly appreciated !

    Read the article

  • Why is my element variable always null in this foreach loop?

    - by ZeroDivide
    Here is the code: public IEnumerable<UserSummary> getUserSummaryList() { var db = new entityContext(); List<UserSummary> model = new List<UserSummary>(); List<aspnet_Users> users = (from user in db.aspnet_Users select user).ToList<aspnet_Users>(); foreach (aspnet_Users u in users) //u is always null while users is a list that contains 4 objects { model.Add(new UserSummary() { UserName = u.UserName, Email = u.aspnet_Membership.Email, Role = Roles.GetRolesForUser(u.UserName).First(), AdCompany = u.AD_COMPANIES.ad_company_name != null ? u.AD_COMPANIES.ad_company_name : "Not an Advertiser", EmployeeName = u.EMPLOYEE.emp_name != null ? u.EMPLOYEE.emp_name : "Not an Employee" }); } return model; } For some reason the u variable in the foreach loop is always null. I've stepped through the code and the users collection is always populated. The table entity for db.aspnet_Users is the users table that comes with asp.net membership services. I've only added a couple associations to it. edit : image of debugger

    Read the article

  • Debugging Node.js applications for Windows Azure

    - by cibrax
    In case you are developing a new web application with Node.js for Windows Azure, you might notice there is no easy way to debug the application unless you are developing in an integrated IDE like Cloud9. For those that develop applications locally using a text editor (or WebMatrix) and Windows Azure Powershell for Node.js, it requires some steps not documented anywhere for the moment. I spent a few hours on this the other day I practically got nowhere until I received some help from Tomek and the rest of them. The IISNode version that currently ships with the Windows Azure for Node.js SDK does not support debugging by default, so you need to install the IISNode full version available in the github repository.  Once you have installed the full version, you need to enable debugging for the web application by modifying the web.config file <iisnode debuggingEnabled="true" loggingEnabled="true" devErrorsEnabled="true" /> The xml above needs to be inserted within the existing “<system.webServer/>” section. The last step is to open a WebKit browser (e.g. Chrome) and navigate to the URL where your application is hosted but adding the segment “/debug” to  the end. The full URL to the node.js application must be used, for example, http://localhost:81/myserver.js/debug That should open a new instance of Node inspector on the browser, so you can debug the application from there. Enjoy!!

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >