Search Results

Search found 163 results on 7 pages for 'wei hu'.

Page 3/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • How to check if JavaScript object is JSON

    - by Wei Hao
    I have a nested JSON object that I need to loop through, and the value of each key could be a String, JSON array or another JSON object. Depending on the type of object, I need to carry out different operations. Is there any way I can check the type of the object to see if it is a String, JSON object or JSON array? I tried using typeof and instanceof but both didn't seem to work, as typeof will return an object for both JSON object and array, and instanceof gives an error when I do obj instanceof JSON. To be more specific, after parsing the JSON into a JS object, is there any way I can check if it is a normal string, or an object with keys and values (from a JSON object), or an array (from a JSON array)? For example: JSON var data = {"hi": {"hello": ["hi1","hi2"] }, "hey":"words" } JavaScript var jsonObj = JSON.parse(data); var level1 = jsonObj.hi; var text = jsonObj.hey; var arr = level1.hello; //how to check if level1 was formerly a JSON object? //how to check if arr was formerly a JSON array? //how to check if text is a string?

    Read the article

  • Android: making a custom ListView independent of adapters ?

    - by wei
    I am adding a local database as a cache to a remote web service in my android application to answer queries. I used ArrayAdapters before for list views to display the results from the web service. Now with a database cache, the result could be either a Cursor(from database) or a List(from web), which means the adapter can be CursorAdapter or ArrayAdapter too. Creating two adapters for one query doesn't seem to be a good idea. So I am wondering what would be the best way to refactor my current code to add this database feature? Thanks,

    Read the article

  • Android: stack management for views in a tab?

    - by wei
    I see some answers here prefer views over activities as contents of tabs. Correct me if I am wrong. My understanding is that by switching out views, it's possible to keep the navigation flow inside a tab (more user friendly, I think). But I wonder how to manage the view stack then in case of the back button events. Also this could cause one giant Activity with large amount of views, which might not be good. So I wish to know why exactly views as contents is preferred before I change my current application to this. Thanks,

    Read the article

  • UITableView Reload Data

    - by william-hu
    Hi, i used UITableView to show the info which was get for server. - (void)viewWillAppear:(BOOL)animated { //Create connection } Then i put the received data into array : NSSArray *dataFromServer: Then i want to show the data on each cell (some NSString object). As the connection was release, i call [self.tableView reloadData] , but cant work. So i'd like to know, how to make this? It means cellForRowAtIndexPath: has nothing at beginning, but after few seconds, shows something. Thank you so much!

    Read the article

  • Android: various questions about GPS

    - by wei
    I'm writing my first location based android app, but got confused about some of the GPS service api. Here are some questions I have: 1) To get my current location, I called requestLocationUpdates() with a listener in the onCreate() method of one activity. But what happens when another activity starts and the current activity goes invisible? Is the GPS location update going to stop? If so, how do I keep it on after the activity is switched? 2) how accurate is the Location.getSpeed()? How is it computed? Can it tell the difference between on bicycle and on foot? 3) not really a question about android. How to calculate the coordinates of a location, say, 100m away from my current location? 4) To stop the GPS, I only need to remove all the listeners that have been registered to locationmanager? Thanks a lot!

    Read the article

  • Picker in UINavigationController

    - by william-hu
    Hi , i use a UIPickerView in my root view of UINavigationController . And i used one button, when i pressed it, pass the data(shows in picker) to the next level view of navigation controller. How should i do this? Thank you!

    Read the article

  • How do common web frameworks (Django, Rails, Symfony, etc) handle multiple instances of the same plu

    - by Steven Wei
    Do any of the popular web frameworks solve this problem well? Here's an example: suppose you're running one of these web frameworks and you want to install a blog plugin. Except instead of a single blog, you need to run two separate instances of the blog plugin, and you want to keep them segregated. Or say you want to install multiple instances of a user authentication plugin, because you want to segregate your administrative users from your customer user accounts. Or say you want to install multiple instances of a wiki plugin for different parts of your site, or multiple instances of a comments plugin, or whatever else. It seems to me that at the basic level, each instance of plugin would need to be able to configured with a different set of database tables, and would need to be 'installed' at a different URL path. My experience is mostly with Django and Symfony, and I haven't seen a clean solution to this problem in either of them. They both tend to assume that each plugin (or app, in Django's case) is only ever going to be installed once. I'm curious if the Rails folks have figured out a clean solution to this problem, or any other framework authors (in any language). And if you were going to design a solution to this problem, what would it look like?

    Read the article

  • Question regarding two dimensional array

    - by Sherwood Hu
    I have some problems using two dimensional array in the code and need some help. static const int PATTERNS[20][4]; static void init_PATTERN() { // problem #1 int (&patterns)[20][4] = const_cast<int[20][4]>(PATTERNS); ... } extern void UsePattern(int a, const int** patterns, int patterns_size); // problem #2 UsePattern(10, PATTERNS, sizeof(PATTERNS)/sizeof(PATTERNS[0])); in the first statement, I need to cast the const off the two dimensional array PATTERNS. The reason for this is that the init function is called only once, and in the remaining code, PATTERNS is strictly read-only. In the second statement, I need to pass PATTERNS array to the int** argument. Direct passing resulted a compile error. Thanks!

    Read the article

  • Get information from WebPage.

    - by william-hu
    I want to set up an app which can get the information from a particular web page. Then i display the value which got from that page to the iPhone user. Detail:In the webpage on server ,there is the schedule for bus time. If the user input origin and terminus then show the user the time information(list on webpage) in a label. That's all. What i have finished is : Open the iphone app, input two value(origin and terminus) to UITextField. Send the URL to server. Get the page, and show in UIWebView. What my problem next is how should i get the information form that page into another two labels to give the user about the bus time. I have store data in my Array receiveData: self.receivedData = data; I am not clear the data i received is XML or what? And how should i pick-up the value i want. (should i save the value to property list and the read the value?) Thank you so much!

    Read the article

  • Chain of Responsibility Pattern: is it a good practice to have interdependent handlers?

    - by wei
    I have this scenario: I have a chain of query handlers, the first is to query the cache, if the cache can't answer it or the answer is stale, then hit a database, if it can't find the answer or the answer is stale again, then query a remote web service. But I am not sure if this is the right way to use this pattern, since the work flow is pretty much fixed, and the cache and database handlers depend on the next step's return result to refresh its records.

    Read the article

  • Then files in my project folder used for what?

    - by william-hu
    I finished one project. But others want me give them the non-Compiled code.what's that? My project folder include: Classes:of course, the source code. build: I don't understand clearly. imagesrc: I added, include the images of my project. The others are the nib file. Give me the explanation in detail,thank you so much.

    Read the article

  • Django ModelForm Imagefield Upload

    - by Wei Xu
    I am pretty new to Django and I met a problem in handling image upload using ModelForm. My model is as following: class Project(models.Model): name = models.CharField(max_length=100) description = models.CharField(max_length=2000) startDate = models.DateField(auto_now_add=True) photo = models.ImageField(upload_to="projectimg/", null=True, blank=True) And the modelform is as following: class AddProjectForm(ModelForm): class Meta: model = Project widgets = { 'description': Textarea(attrs={'cols': 80, 'rows': 50}), } fields = ['name', 'description', 'photo'] And the View function is: def addProject(request, template_name): if request.method == 'POST': addprojectform = AddProjectForm(request.POST,request.FILES) print addprojectform if addprojectform.is_valid(): newproject = addprojectform.save(commit=False) print newproject print request.FILES newproject.photo = request.FILES['photo'] newproject.save() print newproject.photo else: addprojectform = AddProjectForm() newProposalNum = projectProposal.objects.filter(solved=False).count() return render(request, template_name, {'addprojectform':addprojectform, 'newProposalNum':newProposalNum}) the template is: <form class="bs-example form-horizontal" method="post" action="">{% csrf_token %} <h2>Project Name</h2><br> {{ addprojectform.name }}<br> <h2>Project Description</h2> {{ addprojectform.description }}<br> <h2>Image Upload</h2><br> {{ addprojectform.photo }}<br> <input type="submit" class="btn btn-success" value="Add Project"> </form> Can anyone help me or could you give an example of image uploading? Thank you!

    Read the article

  • Android: how to get the walking distance between two geo coordinats?

    - by wei
    I used this query URL http://maps.google.com/maps?q=from+A+to+B&output=kml ,which is given in the answer to this question. But after I tried it, it doesn't work with coordinates. It works with address names tho. I guess I could use google's geocoding to get the addresses first. But I wonder if there is another way to get the walking distance between two coordinates?

    Read the article

  • Nhibernate generate plain sql query instead of execution statement

    - by Wei Ma
    Using SQL profiler, I was able to find the query generated from Nhibernate was executed in the EXEC sp_executesql N'select ...' fashion. I am wondering if there is any way to force Nhibernate to generate the plain Select ... statement instead. The reason I want this is because apparently SQL Server generated different execution plans for them, and in my scenario, the plain "select ..." runs MUCH faster.

    Read the article

  • REST destroy link generate problem

    - by Wei
    I am using rails beta 3 and I have a erb page named index.html.erb for discussions controller. In that page, I have a link as following: <%= link_to 'Delete', {:action='destroy', :id=@discussion}, :confirm="Are you sure", :method='post' % Which is supposed to generate a link to delete a discussion, however, the generated html is Delete which always routes to the show action. I think the href should be /discussions/destroy/1. But for some reason it is not. Any ideas? Thanks in advance.

    Read the article

  • How to draw multiple line text to uiimageview iphone?

    - by Hu?nh Phong
    I have UITextView for text, after user press DONE, I convert text to UIImageView and show it. It works with one line of text very good, and Screenshot 1 . But if user types two lines, or more: the result is still one line??? Screenshot 2 I want to display two or more lines in UIimageView Can anybody help me! Thank you very much! Here is my code: -(UIImage *)convertTextToImage : (ObjectText *) objT; { UIGraphicsBeginImageContext(CGSizeMake(([objT.content sizeWithFont:objT.font].width+10), ([objT.content sizeWithFont:objT.font].height+10))); [[objT getcolor] set]; [objT.content drawAtPoint:CGPointMake(5, 5) withFont:objT.font]; UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return result; }

    Read the article

  • Removing malware of a particular kind

    - by Cyclone
    I need to remove some malware from my computer. It is a trojan, and very annoying. It blocks access to Google and search sites. The trojan, with its name spelled out on each line cause it seems to block sites when i reference it in a url, is a r t (some text to mess it up) e m (more text i s First off, what is it, what does it do? Second, why can't I access google or yahoo or any other search sites at all? Third, can it be removed via McAffee? It says it quarantined it when I scanned I found a suspicious process "c"s"r"s"s".exe and it will not let me terminate it, and this is what Mcaffee says it is. Why on earth isn't Mcaffee getting rid of it? I even blocked internet access for this program. Thanks so much, I get kinda freaked out with things like this... Here is my entire Hosts file: 127.0.0.1 go.mail.ru 127.0.0.1 nova.rambler.ru 127.0.0.1 google.ad 127.0.0.1 www.google.ad 127.0.0.1 google.ae 127.0.0.1 www.google.ae 127.0.0.1 google.am 127.0.0.1 www.google.am 127.0.0.1 google.com.ar 127.0.0.1 www.google.com.ar 127.0.0.1 google.as 127.0.0.1 www.google.as 127.0.0.1 google.at 127.0.0.1 www.google.at 127.0.0.1 google.com.au 127.0.0.1 www.google.com.au 127.0.0.1 google.az 127.0.0.1 www.google.az 127.0.0.1 google.ba 127.0.0.1 www.google.ba 127.0.0.1 google.be 127.0.0.1 www.google.be 127.0.0.1 google.bg 127.0.0.1 www.google.bg 127.0.0.1 google.bs 127.0.0.1 www.google.bs 127.0.0.1 google.com.by 127.0.0.1 www.google.com.by 127.0.0.1 google.ca 127.0.0.1 www.google.ca 127.0.0.1 google.ch 127.0.0.1 www.google.ch 127.0.0.1 google.cn 127.0.0.1 www.google.cn 127.0.0.1 google.cz 127.0.0.1 www.google.cz 127.0.0.1 google.de 127.0.0.1 www.google.de 127.0.0.1 google.dk 127.0.0.1 www.google.dk 127.0.0.1 google.ee 127.0.0.1 www.google.ee 127.0.0.1 google.es 127.0.0.1 www.google.es 127.0.0.1 google.fi 127.0.0.1 www.google.fi 127.0.0.1 google.fr 127.0.0.1 www.google.fr 127.0.0.1 google.gr 127.0.0.1 www.google.gr 127.0.0.1 google.com.hk 127.0.0.1 www.google.com.hk 127.0.0.1 google.hr 127.0.0.1 www.google.hr 127.0.0.1 google.hu 127.0.0.1 www.google.hu 127.0.0.1 google.ie 127.0.0.1 www.google.ie 127.0.0.1 google.co.il 127.0.0.1 www.google.co.il 127.0.0.1 google.co.in 127.0.0.1 www.google.co.in 127.0.0.1 google.is 127.0.0.1 www.google.is 127.0.0.1 google.it 127.0.0.1 www.google.it 127.0.0.1 google.co.jp 127.0.0.1 www.google.co.jp 127.0.0.1 google.kg 127.0.0.1 www.google.kg 127.0.0.1 google.co.kr 127.0.0.1 www.google.co.kr 127.0.0.1 google.li 127.0.0.1 www.google.li 127.0.0.1 google.lt 127.0.0.1 www.google.lt 127.0.0.1 google.lu 127.0.0.1 www.google.lu 127.0.0.1 google.lv 127.0.0.1 www.google.lv 127.0.0.1 google.md 127.0.0.1 www.google.md 127.0.0.1 google.com.mx 127.0.0.1 www.google.com.mx 127.0.0.1 google.nl 127.0.0.1 www.google.nl 127.0.0.1 google.no 127.0.0.1 www.google.no 127.0.0.1 google.co.nz 127.0.0.1 www.google.co.nz 127.0.0.1 google.com.pe 127.0.0.1 www.google.com.pe 127.0.0.1 google.com.ph 127.0.0.1 www.google.com.ph 127.0.0.1 google.pl 127.0.0.1 www.google.pl 127.0.0.1 google.pt 127.0.0.1 www.google.pt 127.0.0.1 google.ro 127.0.0.1 www.google.ro 127.0.0.1 google.ru 127.0.0.1 www.google.ru 127.0.0.1 google.com.ru 127.0.0.1 www.google.com.ru 127.0.0.1 google.com.sa 127.0.0.1 www.google.com.sa 127.0.0.1 google.se 127.0.0.1 www.google.se 127.0.0.1 google.com.sg 127.0.0.1 www.google.com.sg 127.0.0.1 google.si 127.0.0.1 www.google.si 127.0.0.1 google.sk 127.0.0.1 www.google.sk 127.0.0.1 google.co.th 127.0.0.1 www.google.co.th 127.0.0.1 google.com.tj 127.0.0.1 www.google.com.tj 127.0.0.1 google.tm 127.0.0.1 www.google.tm 127.0.0.1 google.com.tr 127.0.0.1 www.google.com.tr 127.0.0.1 google.com.tw 127.0.0.1 www.google.com.tw 127.0.0.1 google.com.ua 127.0.0.1 www.google.com.ua 127.0.0.1 google.co.uk 127.0.0.1 www.google.co.uk 127.0.0.1 google.co.vi 127.0.0.1 www.google.co.vi 127.0.0.1 google.com 127.0.0.1 www.google.com 127.0.0.1 google.us 127.0.0.1 www.google.us 127.0.0.1 google.com.pl 127.0.0.1 www.google.com.pl 127.0.0.1 google.co.hu 127.0.0.1 www.google.co.hu 127.0.0.1 google.ge 127.0.0.1 www.google.ge 127.0.0.1 google.kz 127.0.0.1 www.google.kz 127.0.0.1 google.co.uz 127.0.0.1 www.google.co.uz 127.0.0.1 bing.com 127.0.0.1 www.bing.com 127.0.0.1 search.yahoo.com 127.0.0.1 ca.search.yahoo.com 127.0.0.1 ar.search.yahoo.com 127.0.0.1 cl.search.yahoo.com 127.0.0.1 co.search.yahoo.com 127.0.0.1 mx.search.yahoo.com 127.0.0.1 espanol.search.yahoo.com 127.0.0.1 qc.search.yahoo.com 127.0.0.1 ve.search.yahoo.com 127.0.0.1 pe.search.yahoo.com 127.0.0.1 at.search.yahoo.com 127.0.0.1 ct.search.yahoo.com 127.0.0.1 dk.search.yahoo.com 127.0.0.1 fi.search.yahoo.com 127.0.0.1 fr.search.yahoo.com 127.0.0.1 de.search.yahoo.com 127.0.0.1 it.search.yahoo.com 127.0.0.1 nl.search.yahoo.com 127.0.0.1 no.search.yahoo.com 127.0.0.1 ru.search.yahoo.com 127.0.0.1 es.search.yahoo.com 127.0.0.1 se.search.yahoo.com 127.0.0.1 ch.search.yahoo.com 127.0.0.1 uk.search.yahoo.com 127.0.0.1 asia.search.yahoo.com 127.0.0.1 au.search.yahoo.com 127.0.0.1 one.cn.yahoo.com 127.0.0.1 hk.search.yahoo.com 127.0.0.1 in.search.yahoo.com 127.0.0.1 id.search.yahoo.com 127.0.0.1 search.yahoo.co.jp 127.0.0.1 kr.search.yahoo.com 127.0.0.1 malaysia.search.yahoo.com 127.0.0.1 nz.search.yahoo.com 127.0.0.1 ph.search.yahoo.com 127.0.0.1 sg.search.yahoo.com 127.0.0.1 tw.search.yahoo.com 127.0.0.1 th.search.yahoo.com 127.0.0.1 vn.search.yahoo.com 127.0.0.1 images.google.com 127.0.0.1 images.google.ca 127.0.0.1 images.google.co.uk 127.0.0.1 news.google.com 127.0.0.1 news.google.ca 127.0.0.1 news.google.co.uk 127.0.0.1 video.google.com 127.0.0.1 video.google.ca 127.0.0.1 video.google.co.uk 127.0.0.1 blogsearch.google.com 127.0.0.1 blogsearch.google.ca 127.0.0.1 blogsearch.google.co.uk 127.0.0.1 searchservice.myspace.com 127.0.0.1 ask.com 127.0.0.1 www.ask.com 127.0.0.1 search.aol.com 127.0.0.1 search.netscape.com 127.0.0.1 yandex.ru 127.0.0.1 www.yandex.ru 127.0.0.1 yandex.ua 127.0.0.1 www.yandex.ua 127.0.0.1 search.about.com 127.0.0.1 www.verizon.net 127.0.0.1 verizon.net

    Read the article

  • client side application not working as intended while using AsyncSocket

    - by Miraaj
    Hi All, I am using AsyncSocket class in a simple client-server application. As a first step I want that - as soon as connection is established between client and server, client transmit a welcome message - "connected to xyz server" to server and server displays it in textview. //The code in ClientController class is: -(void)awakeFromNib{ NSError *error = nil; if (![connectSocket connectToHost:@"192.168.0.32" onPort:25242 error:&error]) { NSLog(@"Error starting client: %@", error); return; } NSLog(@"xyz chat client started on port %hu",[connectSocket localPort]); } - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port{ [sock writeData:[@"connected to xyz server" dataUsingEncoding:NSUTF8StringEncoding] withTimeout:30.0 tag:0]; } - (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag{ // some relevant code goes here } - (void)onSocket:(AsyncSocket *)sock didWriteDataWithTag:(long)tag{ NSLog(@"within didWriteDataWithTag:"); // getting this message, means it should have written something to remote socket but // delegate- onSocket:didReadData:withTag: at server side is not getting invoked } // The code in ServerController class is: - (IBAction)startStop:(id)sender{ NSLog(@"startStopAction"); if(!isRunning) { NSError *error = nil; if(![listenSocket acceptOnPort:INPUT_PORT error:&error]) { NSLog(@"Error starting server: %@", error); return; } NSLog(@"Echo server started on port %hu",[listenSocket localPort]); isRunning = YES; [sender setTitle:@"Stop"]; } else { // Stop accepting connections [listenSocket disconnect]; // Stop any client connections int i; for(i = 0; i < [connectedSockets count]; i++) { // Call disconnect on the socket, // which will invoke the onSocketDidDisconnect: method, // which will remove the socket from the list. [[connectedSockets objectAtIndex:i] disconnect]; } NSLog(@"Stopped Echo server"); isRunning = false; [sender setTitle:@"Start"]; } } - (void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket{ [connectedSockets addObject:newSocket]; } - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port{ NSLog(@"Accepted client %@:%hu", host, port); // it is getting displayed [sock readDataToData:[AsyncSocket CRLFData] withTimeout:READ_TIMEOUT tag:0]; } - (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag{ NSString *msgReceived = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; NSLog(@"msgReceived in didReadData- %@",msgReceived); // it is not getting displayed [outputView insertText:msgReceived]; [sock readDataToData:[AsyncSocket CRLFData] withTimeout:READ_TIMEOUT tag:0]; } Can anyone suggest me where I may be wrong?? Thanks in advance...... Miraaj

    Read the article

  • Letölthetoek a HOUG 2010 Konferencia eloadásai

    - by Fekete Zoltán
    2010. március 22-24. között zajlott le a HOUG Konferencia 2010. Már letölthetoek az eloadás anyagok a http://www.houg.hu/ oldalról az Archívum-ra, majd a HOUG 2010-re kattintva. A konferencián készült fényképek még nem kerültek fel, de reménykedjünk, hogy kisvártatva elénk tárulnak. :) Az Üzleti intelligencia és adattárház szekció (Business Intelligence & Data Warehouse) eloadásai itt érheto el. Jó mazsolázást kívánok!

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >