Search Results

Search found 421 results on 17 pages for 'luis yang'.

Page 10/17 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Android: Unable to make httprequest behind firewall

    - by Yang
    The standard getUrlContent works welll when there is no firewall. But I got exceptions when I try to do it behind a firewall. I've tried to set "http proxy server" in AVD manager, but it didn't work. Any idea how to correctly set it up? protected static synchronized String getUrlContent(String url) throws ApiException { if(url.equals("try")){ return "thanks"; } if (sUserAgent == null) { throw new ApiException("User-Agent string must be prepared"); } // Create client and set our specific user-agent string HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(url); request.setHeader("User-Agent", sUserAgent); try { HttpResponse response = client.execute(request); // Check if server response is valid StatusLine status = response.getStatusLine(); if (status.getStatusCode() != HTTP_STATUS_OK) { throw new ApiException("Invalid response from server: " + status.toString()); } // Pull content stream from response HttpEntity entity = response.getEntity(); InputStream inputStream = entity.getContent(); ByteArrayOutputStream content = new ByteArrayOutputStream(); // Read response into a buffered stream int readBytes = 0; while ((readBytes = inputStream.read(sBuffer)) != -1) { content.write(sBuffer, 0, readBytes); } // Return result from buffered stream return new String(content.toByteArray()); } catch (IOException e) { throw new ApiException("Problem communicating with API", e); } }

    Read the article

  • Confusion about MVC Routes

    - by yang
    What is the problem below? routes.MapRoute( "Default2", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "test" } // Parameter defaults ); routes.MapRoute( "Default1", // Route name "{controller}/{action}/{name}", // URL with parameters new { controller = "Home", action = "Report", name = "" } // Parameter defaults ); When I navigate to /home/index "id" parameter takes the default value of "test" but when I navigate to home/report the name parameter is null. In short, if the route definition is the first in the route table, then the parameter takes its default value. But the others below don't.

    Read the article

  • log4net: log information into different log files

    - by Daoming Yang
    I have the following configurations in my web.config file, but how can I log the information into data.txt and general.txt separately in C#? Could anyone provide some sample code for me? <appender name="GeneralLog" type="log4net.Appender.RollingFileAppender"> <file value="App_Data/Logs/general.txt" /> <appendToFile value="true" /> <maximumFileSize value="2MB" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="5" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%d{HH:mm:ss.fff} [%t] %-5p %c - %m%n" /> </layout> </appender> <appender name="DataLog" type="log4net.Appender.RollingFileAppender"> <file value="App_Data/Logs/data.txt" /> <appendToFile value="true" /> <maximumFileSize value="2MB" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="5" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%d{HH:mm:ss.fff} [%t] %-5p %c - %m%n" /> </layout> </appender>

    Read the article

  • Looking for a visualization and charting package

    - by Jeff Meatball Yang
    I have some specific requirements, with the most important at the top: Can plot line and stacked bar charts Can customize mouse events (hover, click) on chart data Compatible and performant with IE7/8 (likely will use excanvas.js) Can optionally control label formats, legends, colors Open source preferred, or at least can purchase the source Can be hosted locally I have seen a couple potentially good ones: Google's interactive charts (But code must be accessed via Google servers) EJSChart Flot Does anyone have experience with these, or others, and can make a recommendation?

    Read the article

  • mysql partitioning

    - by Yang
    just want to verify that database partition is implemented only at the database level, when we query a partitioned table, we still do our normal query, nothing special with our queries, the optimization is performed automatically when parsing the query, is that correct? e.g. we have a table called 'address' with a column called 'country_code' and 'city'. so if i want to get all the addresses in New York, US, normally i wound do something like this: select * from address where country_code = 'US' and city = 'New York' if now the table is partitioned by 'country_code', and i know that now the query will only be executed on the partition which contains country_code = US. My question is do I need to explicitly specify the partition to query in my sql statement? or i still use the previous statement and the db server will optimize it automatically? Thanks in advance!

    Read the article

  • How to use Linq to group DateTime by month and days calculation

    - by Daoming Yang
    Hi all, I have two questions: First one: I have a order list and want to group them by the created month for the reports. Each order's created datetime will be like "2010-03-13 11:17:16.000" How can I make them only group by date like "2010-03"? Note: the DateCreated is the DateTime tpye The following code is not correct. var items = orderList.GroupBy(t => t.DateCreated.Month) .Select(g => new Order() { DateCreated = g.Key }) .OrderByDescending(x => x.OrderID).ToList(); Second one: Output the full months between two dates in C# If an user choose 2010-04-08 and 2010-06-04, I want to output the 2010-04-01 and 2010-06-30. I can always get the first day and last day of the months, but I want to find out some other options Many thanks. Many thanks.

    Read the article

  • android: having two listviews in two listactivities didn't work

    - by Yang
    I guess my previous question wasn't clear enough (http://stackoverflow.com/questions/2549585/android-failed-to-setcontentview-when-switching-to-listactivity), so I explain as follows. In my app I have two listactivities which uses two different listviews: public class Activity1 extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { try{ super.onCreate(savedInstanceState); setContentView(R.layout.listview1); } public class Activity2 extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { try{ super.onCreate(savedInstanceState); setContentView(R.layout.listview2); } } As required by android, listview must have an ID which is exactly "@android:id/list". If I set the listview in both listview1 and listview2 with the same ID, then they will end up using the same format of listview, which is not what I want. But if I set one of the IDs to be sth like "@+id/listview2", android gave me the error: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' How do I handle this dilema?

    Read the article

  • android: how to specify multipe listivews

    - by Yang
    It seems that android has enforced that a listview must have the name android:id="@android:id/list", is there anyway to create multiple listview then? I have two activities which are both listview but have to control different format of Lists, one with image+text the other is just text.

    Read the article

  • reload an iFrame with the scrollbar set to a specific coordinate.

    - by Luis Armando
    I was wondering how could I reload any website using javascript and set it in a way that when it reloads the scrollbar is looking scrolled down to a certain position. I'm unsure as to how to look for this in Google honestly so I haven't digged up much =/. I think it has to be somewhere in the instruction to reload it and so far I have: document.getElementById('life').contentWindow.scroll(0,0); //doesn't work document.getElementById('life').contentWindow.location.reload(); although the first one gets me: Permission denied to get property Window.scroll of http://www.google.com.

    Read the article

  • Simple java regular expression replace question.

    - by Yang
    I have a simple xml file and I want to remove everything before the first tag. ..... item1 .... The following java code is not working: String cleanxml = rawxml.replace("^[\\s\\S]+<item>", ""); What is the correct way to do this? And how do I address the non-greedy issue? Sorry I'm a C# programmer.

    Read the article

  • Error while installing dependencies for PyGTK on Mac OS 10.6.3

    - by Winston C. Yang
    I tried to install the following dependencies for PyGTK 2.16.0 (the Python GIMP Tool Kit) on Mac OS 10.6.3: glib 2.25.5 gettext-0.18 libiconv-1.13.1 When I tried to install glib, I got the following error message: gconvert.c:55:2: error: #error GNU libiconv not in use but included iconv.h is from libiconv The libiconv web page talks about a circular dependency between gettext and libiconv---build one, then build the other, then build the first again. I tried to do this, though possibly incorrectly. (Will the following work: make distclean; ./configure; make; sudo make install?) The author of a posting had the same problem, and he solved it by installing libiconv-1.13.1. Could anyone explain the error in more detail, and how to correct it?

    Read the article

  • FxCop giving a warning on private constructor CA1823 and CA1053

    - by Luis Sánchez
    I have a class that looks like the following: Public Class Utilities Public Shared Function blah(userCode As String) As String 'doing some stuff End Function End Class I'm running FxCop 10 on it and it says: "Because type 'Utilities' contains only 'static' ( 'Shared' in Visual Basic) members, add a default private constructor to prevent the compiler from adding a default public constructor." Ok, you're right Mr. FxCop, I'll add a private constructor: Private Utilities() Now I'm having: "It appears that field 'Utilities.Utilities' is never used or is only ever assigned to. Use this field or remove it." Any ideas of what should I do to get rid of both warnings?

    Read the article

  • Validating class and superclass on RoR

    - by Luís Guilherme
    In ruby, you have an attribute called "type" which is the class of the object. Rails stores this at the database in a column called type. So, if I have several blog "types", I can do something like this def create @blog = Blog.new(params[:blog]) @blog[:type] = params[:blog][:type] # ... end If I add someone like this, and then load it, and ask its class (for instance, at the console), I have the right class name answered back. However, when I save it afterwards, rails will run only the superclass validators, not the ones I defined in the subclass. How should I make rails run the subclass validators?

    Read the article

  • Comparing images using SIFT

    - by Luís Fernando
    I'm trying to compare 2 images that are taken from a digital camera. Since there may be movement on the camera, I want to first make the pictures "match" and then compare (using some distant function). To match them, I'm thinking about cropping the second picture and using SIFT to find it inside the first picture... it will probably have a small difference on scale/translation/rotation so then I'd need to find the transformation matrix that converts image 1 to image 2 (based on points found by SIFT) any ideas on how to do that (or I guess that's a common problem that may have some opensource implementation?)? thanks

    Read the article

  • How to get accuracy memory usage on iphone device.

    - by Favo Yang
    I want to output accuracy memory usage on iphone device, the method I used was taking from, http://landonf.bikemonkey.org/code/iphone/Determining%5FAvailable%5FMemory.20081203.html natural_t mem_used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pagesize; natural_t mem_free = vm_stat.free_count * pagesize; natural_t mem_total = mem_used + mem_free; The issue is that the total value is always changed after testing on device! used: 60200.0KB free: 2740.0KB total: 62940.0KB used: 53156.0KB free: 2524.0KB total: 55680.0KB used: 52500.0KB free: 2544.0KB total: 55044.0KB Have a look for the function implementation, it already sum active, inactive, wire and free pages, is there anything I missing here?

    Read the article

  • random generator to obtain data from array not displaying

    - by Yang Jie Domodomo
    I know theres a better solution using arc4random (it's on my to-try-out-function list), but I wanted to try out using the rand() and stand(time(NULL)) function first. I've created a NSMutableArray and chuck it with 5 data. Testing out how many number it has was fine. But when I tried to use the button function to load the object it return me with object <sampleData: 0x9a2f0e0> - (IBAction)generateNumber:(id)sender { srand(time(NULL)); NSInteger number =rand()% ds.count ; label.text = [NSString stringWithFormat:@"object %@", [ds objectAtIndex:number] ]; NSLog(@"%@",label.text); } While I feel the main cause is the method itself, I've paste the rest of the code below just incase i made any error somewhere. ViewController.h #import <UIKit/UIKit.h> #import "sampleData.h" #import "sampleDataDAO.h" @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UILabel *label; @property (weak, nonatomic) IBOutlet UIButton *onHitMePressed; - (IBAction)generateNumber:(id)sender; @property(nonatomic, strong) sampleDataDAO *daoDS; @property(nonatomic, strong) NSMutableArray *ds; @end ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize label; @synthesize onHitMePressed; @synthesize daoDS,ds; - (void)viewDidLoad { [super viewDidLoad]; daoDS = [[sampleDataDAO alloc] init]; self.ds = daoDS.PopulateDataSource; // Do any additional setup after loading the view, typically from a nib. } - (void)viewDidUnload { [self setLabel:nil]; [self setOnHitMePressed:nil]; [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } - (IBAction)generateNumber:(id)sender { srand(time(NULL)); NSInteger number =rand()% ds.count ; label.text = [NSString stringWithFormat:@"object %@", [ds objectAtIndex:number] ]; NSLog(@"%@",label.text); } @end sampleData.h #import <Foundation/Foundation.h> @interface sampleData : NSObject @property (strong,nonatomic) NSString * object; @end sampleData.m #import "sampleData.h" @implementation sampleData @synthesize object; @end sampleDataDAO.h #import <Foundation/Foundation.h> #import "sampleData.h" @interface sampleDataDAO : NSObject @property(strong,nonatomic)NSMutableArray*someDataArray; -(NSMutableArray *)PopulateDataSource; @end sampleDataDAO.m #import "sampleDataDAO.h" @implementation sampleDataDAO @synthesize someDataArray; -(NSMutableArray *)PopulateDataSource { someDataArray = [[NSMutableArray alloc]init]; sampleData * myData = [[sampleData alloc]init]; myData.object= @"object 1"; [someDataArray addObject:myData]; myData=nil; myData = [[sampleData alloc] init]; myData.object= @"object 2"; [someDataArray addObject:myData]; myData=nil; myData = [[sampleData alloc] init]; myData.object= @"object 3"; [someDataArray addObject:myData]; myData=nil; myData = [[sampleData alloc] init]; myData.object= @"object 4"; [someDataArray addObject:myData]; myData=nil; myData = [[sampleData alloc] init]; myData.object= @"object 5"; [someDataArray addObject:myData]; myData=nil; return someDataArray; } @end

    Read the article

  • Better way to clean this messy bool method

    - by Luís Custódio
    I'm reading Fowler Clean Code book and I think that my code is a little messy, I want some suggestions: I have a simple business requirement that is return the date of new execution of my Thread. I've two class fields: _hour and _day. If actual day is higher than my _day field I must return true, so I'll add a month to "executionDate" If the day is the same, but the actual hour is higher than _hour I should return true too. So I did this simple method: private bool ScheduledDateGreaterThanCurrentDate (DateTime dataAtual) { if (dateActual.Day > _day) { return true; } if (dateActual.Day == _day && dateActual.Hour > _hour) { return true; } if (dateActual.Day == _day && dateActual.Hour == _hour) if (dateActual.Minute>0 || dateActual.Second>0) return true; return false; } I'm programming with TDD, so I know that the return is correct, but this is bad maintain code right?

    Read the article

  • what is a data serialization system?

    - by Yang
    according to Apache AVRO project, "Avro is a serialization system". By saying data serialization system, does it mean that avro is a product or api? also, I am not quit sure about what a data serialization system is? for now, my understanding is that it is a protocol that defines how data object is passed over the network. Can anyone help explain it in an intuitive way that it is easier for people with limited distributed computing background to understand? Thanks in advance!

    Read the article

  • Redirect Desktop Internal Pages to Correct Mobile Internal Pages with Htaccess

    - by Luis Alejandro Ramrez Gallardo
    I have built a Mobile site in a sub-domain. I have successfully implemented the redirect 302 from: www.domain.com to m.domain.com in htaccess. What I'm looking to achieve now it to redirect users from: www.domain.com/internal-page/ > 302 > m.domain.com/internal-page.html Notice that URL name for desktop and mobile is not the same. The code I'm using looks like this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress # Mobile Redirect # Verify Desktop Version Parameter RewriteCond %{QUERY_STRING} (^|&)ViewFullSite=true(&|$) # Set cookie and expiration RewriteRule ^ - [CO=mredir:0:www.domain.com:60] # Prevent looping RewriteCond %{HTTP_HOST} !^m.domain.com$ # Define Mobile agents RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR] RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR] RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR] RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC] # Verify if not already in Mobile site RewriteCond %{HTTP_HOST} !^m\. # We need to read and write at the same time to set cookie RewriteCond %{QUERY_STRING} !(^|&)ViewFullSite=true(&|$) # Verify that we previously haven't set the cookie RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC] # Now redirect the users to the Mobile Homepage RewriteRule ^$ http://m.domain.com [R] RewriteRule $/internal-page/ http://m.domain.com/internal-page.html [R,L]

    Read the article

  • What is `objc_msgSend_fixup`, exactly?

    - by Luis Antonio Botelho O. Leite
    I'm messing around with the Objective-C runtime, trying to compile objective-c code without linking it against libobjc, and I'm having some segmentation fault problems with a program, so I generated an assembly file from it. I think it's not necessary to show the whole assembly file. At some point of my main function, I've got the following line (which, by the way, is the line after which I get the seg fault): callq *l_objc_msgSend_fixup_alloc and here is the definition for l_objc_msgSend_fixup_alloc: .hidden l_objc_msgSend_fixup_alloc # @"\01l_objc_msgSend_fixup_alloc" .type l_objc_msgSend_fixup_alloc,@object .section "__DATA, __objc_msgrefs, coalesced","aw",@progbits .weak l_objc_msgSend_fixup_alloc .align 16 l_objc_msgSend_fixup_alloc: .quad objc_msgSend_fixup .quad L_OBJC_METH_VAR_NAME_ .size l_objc_msgSend_fixup_alloc, 16 I've reimplemented objc_msgSend_fixup as a function (id objc_msgSend_fixup(id self, SEL op, ...)) which returns nil (just to see what happens), but this function isn't even being called (the program crashes before calling it). So, my question is, what is callq *l_objc_msgSend_fixup_alloc supposed to do and what is objc_msgSend_fixup (after l_objc_msgSend_fixup_alloc:) supposed to be (a function or an object)? Edit To better explain, I'm not linking my source file against the objc library. What I'm trying to do is implement some parts of the libray, just to see how it works. Here is an approach of what I've done: #include <stdio.h> #include <objc/runtime.h> @interface MyClass { } +(id) alloc; @end @implementation MyClass +(id) alloc { // alloc the object return nil; } @end id objc_msgSend_fixup(id self, SEL op, ...) { printf("Calling objc_msgSend_fixup()...\n"); // looks for the method implementation for SEL in self's vtable return nil; // Since this is just a test, this function doesn't need to do that } int main(int argc, char *argv[]) { MyClass *m; m = [MyClass alloc]; // At this point, according to the assembly code generated // objc_msgSend_fixup should be called. So, the program should, at least, print // "Calling objc_msgSend_fixup()..." on the screen, but it crashes before // objc_msgSend_fixup() is called... return 0; } If the runtime needs to access the object's vtable to find the correct method to call, what is the function which actually does this? I think it is objc_msgSend_fixup, in this case. So, when objc_msgSend_fixup is called, it receives an object as one of its parameters, and, if this object hasn't been initialized, the function fails. So, I've implemented my own version of objc_msgSend_fixup. According to the assembly source above, it should be called. It doesn't matter if the function is actually looking for the implementation of the selector passed as parameter. I just want objc_msgSend_lookup to be called. But, it's not being called, that is, the function that looks for the object's data is not even being called, instead of being called and cause a fault (because it returns a nil (which, by the way, doesn't matter)). The program seg fails before objc_msgSend_lookup is called...

    Read the article

  • mysql result set joining existing table

    - by Yang
    is there any way to avoid using tmp table? I am using a query with aggregate function (sum) to generate the sum of each product: the result looks like this: product_name | sum(qty) product_1 | 100 product_2 | 200 product_5 | 300 now i want to join the above result to another table called products. so that i will have a summary like this: product_name | sum(qty) product_1 | 100 product_2 | 200 product_3 | 0 product_4 | 0 product_5 | 300 i know 1 way of doing this is the dump the 1st query result to a temp table then join it with products table. is there a better way?

    Read the article

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