Search Results

Search found 415 results on 17 pages for 'wei ma'.

Page 4/17 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Splitting assemblies - finding the balance (avoiding overkill)

    - by M.A. Hanin
    I'm writing a wide component infrastructure, to be used in my projects. Since not all projects will require every component created, I've been thinking of splitting the component into discrete assemblies, so that every application developed will only be deployed with the required assemblies. I assume that creating an assembly has some storage overhead (the assembly's code, wrapping whatever is inside). Therefore, there must be some limit to the advantage gained by splitting an assembly - a certain point where splitting the assembly is worse than keeping it united (storage-wise and performance-wise). Now, here is the question: how do I know when splitting an assembly is an overkill? P.S I guess there are other overheads to assembly splitting, aside from the storage overhead. If anyone can point out these overheads, it would be much appreciated.

    Read the article

  • [mercurial] Prevent "hg status" from showing everything under untracked directories

    - by Wei Hu
    I find the output of hg status too verbose for untracked directories. Suppose I have an empty repository that's managed by both git and hg. So there would be two directories, .git and .hg. The output of git status is: # Untracked files: # (use "git add <file>..." to include in what will be committed) # # .hg/ The output of hg status is: ? .git/HEAD ? .git/config ? .git/description ? .git/hooks/applypatch-msg.sample ? .git/hooks/commit-msg.sample ? .git/hooks/post-commit.sample ? .git/hooks/post-receive.sample ? .git/hooks/post-update.sample ? .git/hooks/pre-applypatch.sample ? .git/hooks/pre-commit.sample ? .git/hooks/pre-rebase.sample ? .git/hooks/prepare-commit-msg.sample ? .git/hooks/update.sample ? .git/info/exclude Is there a way to reduce its output to something like the following line? ? .git/

    Read the article

  • Android: GPS location updates when the cellphone is in sleep?

    - by wei
    I need to update the location through GPS in the background even when the phone is in sleep. I am thinking to use AlarmManager to broadcast an Intent and then a receiver will call requestLocationUpdates() on LocationManager. But I am not sure whether it's guaranteed that the GPS location will be updated when the phone is in sleep and an intent will be broadcasted if I registered a PendingIntent when call requestLocationUpdates()? thanks,

    Read the article

  • .net mvc pass dictionary data from view to controller

    - by Wei Ma
    A while ago, I was trying to pass a dictionary data from my view to my controller. And I was able to do so after googling on the net(remember it was one of scott hanselman's posts). The solution I had was something like <%for(int index=0; index<Model.Count(); index++){ var property= Model.ElementAt(index);%> <input type="hidden" name="<%="properties["+index+"].Key"%>"/> <input type="hidden" name="<%="properties["+index+"].Value"%>"/> <%}%> public ActionResult Process(IDictionary<string,string> properties) { doSomething(); return View(); } The code worked for awhile and then I did some refactoring and got rid of this chunk of code. Today, I ran into a situation in which I would like to pass a dictionary again. But no matter how hard I try, the properties parameter received by the action was always null. I tried the above code and <%for(int index=0; index<Model.Count(); index++){ var property= Model.ElementAt(index);%> <input type="hidden" name="<%="properties.Keys["+index+"]"%>"/> <input type="hidden" name="<%="properties.Values["+index+"]"%>"/> <%}%> Neither code worked. I googled again but couldn't find the post that helped me before. Can someone point out what I did wrong? thanks a million.

    Read the article

  • Delegates and ParamArray - Workaround Suggestions?

    - by M.A. Hanin
    Some predefined methods contain a ParamArray in their signature. Delegates, however, cannot contain a ParamArray in their signature. Main question: Assume you wish to create a delegation mechanism for a specific method which requires a ParamArray. How would you work around this constraint? "Bonus" question: Assume you wish to create a generalized delegation mechanism for all methods which require ParamArray, how would you do that?

    Read the article

  • Android: handle unexpected internet disconnect while downloading data

    - by M.A. Cape
    Hi, I have here a function that downloads data from a remote server to file. I am still not confident with my code. My question is, what if while reading the stream and saving the data to a file and suddenly I was disconnected in the internet, will these catch exceptions below can really catch that kind of incident? If not, can you suggest how to handle this kind of incident? Note: I call this function in a thread so that the UI won't be blocked. public static boolean getFromRemote(String link, String fileName, Context context){ boolean dataReceived = false; ConnectivityManager connec = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); if (connec.getNetworkInfo(0).isConnected() || connec.getNetworkInfo(1).isConnected()){ try { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(link); HttpParams params = httpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, 30000); HttpConnectionParams.setSoTimeout(params, 30000); HttpResponse response; response = httpClient.execute(httpGet); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == 200){ HttpEntity entity = response.getEntity(); InputStream in = null; OutputStream output = null; try{ in = entity.getContent(); String secondLevelCacheDir = context.getCacheDir() + fileName; File imageFile = new File(secondLevelCacheDir); output= new FileOutputStream(imageFile); IOUtilities.copy(in, output); output.flush(); } catch (IOException e) { Log.e("SAVING", "Could not load xml", e); } finally { IOUtilities.closeStream(in); IOUtilities.closeStream(output); dataReceived = true; } } }catch (SocketTimeoutException e){ //Handle not connecting to client !!!! Log.d("SocketTimeoutException Thrown", e.toString()); dataReceived = false; } catch (ClientProtocolException e) { //Handle not connecting to client !!!! Log.d("ClientProtocolException Thrown", e.toString()); dataReceived = false; }catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); dataReceived = false; Log.d("MalformedURLException Thrown", e.toString()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); dataReceived = false; Log.d("IOException Thrown", e.toString()); } } return dataReceived; }

    Read the article

  • About Data Objects and DAO Design when using Hibernate

    - by X. Ma
    I'm hesitating between two designs of a database project using Hibernate. Design #1. (1) Create a general data provider interface, including a set of DAO interfaces and general data container classes. It hides the underneath implementation. A data provider implementation could access data in database, or an XML file, or a service, or something else. The user of a data provider does not to know about it. (2) Create a database library with Hibernate. This library implements the data provider interface in (1). The bad thing about Design #1 is that in order to hide the implementation details, I need to create two sets of data container classes. One in the general data provider interface - let's call them DPI-Objects, the other set is used in the database library, exclusively for entity/attribute mapping in Hibernate - let's call them H-Objects. In the DAO implementation, I need to read data from database to create H-Objects (via Hibernate) and then convert H-Objects into DPI-Objects. Design #2. Do not create a general data provider interface. Expose H-Objects directly to components that use the database lib. So the user of the database library needs to be aware of Hibernate. I like design #1 more, but I don't want to create two sets of data container classes. Is that the right way to hide H-Objects and other Hibernate implementation details from the user who uses the database-based data provider? Are there any drawbacks of Design #2? I will not implement other data provider in the new future, so should I just forget about the data provider interface and use Design #2? What do you think about this? Thanks for your time!

    Read the article

  • Why does Git.pm on cygwin complain about 'Out of memory during "large" request?

    - by Charles Ma
    Hi, I'm getting this error while doing a git svn rebase in cygwin Out of memory during "large" request for 268439552 bytes, total sbrk() is 140652544 bytes at /usr/lib/perl5/site_perl/Git.pm line 898, <GEN1> line 3. 268439552 is 256MB. Cygwin's maxium memory size is set to 1024MB so I'm guessing that it has a different maximum memory size for perl? How can I increase the maximum memory size that perl programs can use? update: This is where the error occurs (in Git.pm): while (1) { my $bytesLeft = $size - $bytesRead; last unless $bytesLeft; my $bytesToRead = $bytesLeft < 1024 ? $bytesLeft : 1024; my $read = read($in, $blob, $bytesToRead, $bytesRead); //line 898 unless (defined($read)) { $self->_close_cat_blob(); throw Error::Simple("in pipe went bad"); } $bytesRead += $read; } I've added a print before line 898 to print out $bytesToRead and $bytesRead and the result was 1024 for $bytesToRead, and 134220800 for $bytesRead, so it's reading 1024 bytes at a time and it has already read 128MB. Perl's 'read' function must be out of memory and is trying to request for double it's memory size...is there a way to specify how much memory to request? or is that implementation dependent? UPDATE2: While testing memory allocation in cygwin: This C program's output was 1536MB int main() { unsigned int bit=0x40000000, sum=0; char *x; while (bit > 4096) { x = malloc(bit); if (x) sum += bit; bit >>= 1; } printf("%08x bytes (%.1fMb)\n", sum, sum/1024.0/1024.0); return 0; } While this perl program crashed if the file size is greater than 384MB (but succeeded if the file size was less). open(F, "<400") or die("can't read\n"); $size = -s "400"; $read = read(F, $s, $size); The error is similar Out of memory during "large" request for 536875008 bytes, total sbrk() is 217088 bytes at mem.pl line 6.

    Read the article

  • How to merge duplicates in 2D python arrays

    - by Wei Lou
    Hi, I have a set of data similar to this: No Start Time End Time CallType Info 1 13:14:37.236 13:14:53.700 Ping1 RTT(Avr):160ms 2 13:14:58.955 13:15:29.984 Ping2 RTT(Avr):40ms 3 13:19:12.754 13:19:14.757 Ping3_1 RTT(Avr):620ms 3 13:19:12.754 Ping3_2 RTT(Avr):210ms 4 13:14:58.955 13:15:29.984 Ping4 RTT(Avr):360ms 5 13:19:12.754 13:19:14.757 Ping1 RTT(Avr):40ms 6 13:19:59.862 13:20:01.522 Ping2 RTT(Avr):163ms ... when i parse through it, i need merge the results of Ping3_1 and Ping3_2. Then take average of those two row export as one row. So the end of result would be like this: No Start Time End Time CallType Info 1 13:14:37.236 13:14:53.700 Ping1 RTT(Avr):160ms 2 13:14:58.955 13:15:29.984 Ping2 RTT(Avr):40ms 3 13:19:12.754 13:19:14.757 Ping3 RTT(Avr):415ms 4 13:14:58.955 13:15:29.984 Ping4 RTT(Avr):360ms 5 13:19:12.754 13:19:14.757 Ping1 RTT(Avr):40ms 6 13:19:59.862 13:20:01.522 Ping2 RTT(Avr):163ms currently i am concatenating column 0 and 1 to make a unique key, find duplication there then doing rest of special treatment for those parallel Pings. It is not elegant at all. Just wonder what is the better way to do it. Thanks!

    Read the article

  • Prevent "hg status" from showing everything under untracked directories

    - by Wei Hu
    I find the output of hg status too verbose for untracked directories. Suppose I have an empty repository that's managed by both git and hg. So there would be two directories, .git and .hg. The output of git status is: # Untracked files: # (use "git add <file>..." to include in what will be committed) # # .hg/ The output of hg status is: ? .git/HEAD ? .git/config ? .git/description ? .git/hooks/applypatch-msg.sample ? .git/hooks/commit-msg.sample ? .git/hooks/post-commit.sample ? .git/hooks/post-receive.sample ? .git/hooks/post-update.sample ? .git/hooks/pre-applypatch.sample ? .git/hooks/pre-commit.sample ? .git/hooks/pre-rebase.sample ? .git/hooks/prepare-commit-msg.sample ? .git/hooks/update.sample ? .git/info/exclude Is there a way to reduce its output to something like the following line? ? .git/

    Read the article

  • Authlogic auto login fails on registration with STI User model

    - by Wei Gan
    Authlogin by default is supposed to auto login when the user's persistence token changes. It seems to fail in my Rails app. I set up the following single table inheritance user model hierarchy: class BaseUser < ActiveRecord::Base end class User < BaseUser acts_as_authentic end create_table "base_users", :force => true do |t| t.string "email" t.string "crypted_password" t.string "persistence_token" t.string "first_name" t.string "last_name" t.datetime "created_at" t.datetime "updated_at" t.string "type" end To get auto login to work, I need to explicitly log users in in my UsersController: def create @user = User.new(params[:user]) if @user.save UserSession.create(@user) # EXPLICITLY LOG USER IN BY CREATING SESSION flash[:notice] = "Welcome to Askapade!" redirect_to_target_or_default root_url else render :action => :new end end I was wondering if it's anything to do with STI, or that the table is named "base_users" and not "users". I set it up before without STI and it worked so I'm wondering why once I put in place this hierarchy, it fails. Thanks!

    Read the article

  • Preserve data in .net mvc

    - by Wei Ma
    I am implementing a search module with result page support paging. The example provided by NerdDinner passes pagenumber as a parameter for the Index action, and the action uses the pagenumber to perform a query each time the user hit a different page number. My problem is that my search take many more criteria such as price, material, model number etc. than just simple pagenumber. Therefore, I would like to preserve the criteria after users' first submission, so that I only have to pass the pagenumber back and forth. Using ViewData is not possible because ViewData get cleared once it is sent to the View. Is there any good way to preserve the criteria data as I wish?

    Read the article

  • 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

  • Limit size of cache directory.

    - by M.A. Cape
    I have some questions about the cache directory in android. Does anyone knows the limit for each app's cache directory? Also what will happen if there is not enough disk space to cache data? All I know is when the device runs low on storage, the files here (cache directory)will be the ones that get deleted first and each app has its own cache directory. Now, are the files of other app's cache directory will be cleared to accommodate my app's request to add files in the cache dir when there is not enough storage?

    Read the article

  • C# Multi-Comparisons possible?

    - by Iggy Ma
    is it possible in some way to compare multiple variables to one constant in a if statement? It would be very helpful if instead of if ( col.Name != "Organization" && col.Name != "Contacts" && col.Name != "Orders" ) { } I could just say if ( col.Name != "Organization" || "Contacts" || "Orders" ) { } And I know I could use a list but in some instances I dont want to... Thanks!

    Read the article

  • Should non-English member names be changed to English?

    - by M.A. Hanin
    Situation: Automatically generated memebers, such as MenuStrip items, have their (automatically generated) names based on the text entered when the item was created. My most common situation is creating a menu-strip and adding menu-items by entering their text (using the graphical designer). Since my GUI is in Hebrew, all these members have a name which contains a Hebrew string. Something like "(hebrew-text)ToolStripItem". When I create event handlers, the event handlers "inherit" the hebrew text: "(hebrew-text)ToolStripMenuItem_Click". This actually works well, IntelliSense has no problem with Hebrew text, and so does the compiler. The question is: should I change these names (or prevent them from being created in the first place)? What are the possible consequences of keeping those names?

    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

  • 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

  • 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

  • Appengine JDO dataclasses to python model

    - by M.A. Cape
    Does anyone have tried to implement an app in GAE having both java and python? I have an existing app and my front end is in java. Now I want to use the existing datastore to be interfaced by python. My problem is i don't know how to define the relationships and model that would be equivalent to the one in java. I have tried the one-to-many relationship in python but when stored in the datastore, the fields are different than the one-to-many of java. My data classes are as follows. //one-to-many owned Parent Class public class Parent{ @PrimaryKey @Persistent private String unitID; //some other fields... @Persistent @Order(extensions = @Extension(vendorName="datanucleus", key="list-ordering", value="dateCreated desc")) private List <Child> child; //methods & constructors were omitted } Child public class Child{ @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key uId; @Persistent private String name; /* etc... */ }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >