Search Results

Search found 301 results on 13 pages for 'horace ho'.

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

  • How to fix "failed codesign verification" of an iPhone project?

    - by Horace Ho
    Last night, the iPhone project was built perfectly. This morning, I installed XCode 3.2.3 in a separate folder. When I open the same project in the old XCode 3.2.2 and re-built the project. I got this warning: Application failed codesign verification. The signature was invalid, or it was not signed with an Apple submission certificate. (-19011) How can I fix it? Thanks!

    Read the article

  • WCF ChannelFactory vs generating proxy

    - by Allen Ho
    Hi, Just wondering under what circumstances would you prefer to generate a proxy from a WCF service when you can just invoke calls using the ChannelFactory? This way you wont have to generate a proxy and worry about regenerating a proxy whne the server is updated? Thanks

    Read the article

  • Speed up bitstring/bit operations in Python?

    - by Xavier Ho
    I wrote a prime number generator using Sieve of Eratosthenes and Python 3.1. The code runs correctly and gracefully at 0.32 seconds on ideone.com to generate prime numbers up to 1,000,000. # from bitstring import BitString def prime_numbers(limit=1000000): '''Prime number generator. Yields the series 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ... using Sieve of Eratosthenes. ''' yield 2 sub_limit = int(limit**0.5) flags = [False, False] + [True] * (limit - 2) # flags = BitString(limit) # Step through all the odd numbers for i in range(3, limit, 2): if flags[i] is False: # if flags[i] is True: continue yield i # Exclude further multiples of the current prime number if i <= sub_limit: for j in range(i*3, limit, i<<1): flags[j] = False # flags[j] = True The problem is, I run out of memory when I try to generate numbers up to 1,000,000,000. flags = [False, False] + [True] * (limit - 2) MemoryError As you can imagine, allocating 1 billion boolean values (1 byte 4 or 8 bytes (see comment) each in Python) is really not feasible, so I looked into bitstring. I figured, using 1 bit for each flag would be much more memory-efficient. However, the program's performance dropped drastically - 24 seconds runtime, for prime number up to 1,000,000. This is probably due to the internal implementation of bitstring. You can comment/uncomment the three lines to see what I changed to use BitString, as the code snippet above. My question is, is there a way to speed up my program, with or without bitstring?

    Read the article

  • ruby eval('\1') of gsub possible?

    - by Horace Ho
    I try to replace a sub-str by the content of a valiable where its name matches the sub-str by: >> str = "Hello **name**" => "Hello **name**" >> name = "John" => "John" str.gsub(/\*\*(.*)\*\*/, eval('\1')) # => error! the last line in the code above is a syntax error. and: >> str.gsub(/\*\*(.*)\*\*/, '\1') => "Hello name" >> str.gsub(/\*\*(.*)\*\*/, eval("name")) => "Hello John" what I want is the result of: str.gsub(/\*\*(.*)\*\*/, eval("name")) # => "Hello John" any help will be appreciated. thx!

    Read the article

  • render_to_string from a rake task

    - by Horace Loeb
    I want to use a Rake task to cache my sitemap so that requests for sitemap.xml won't take forever. Here's what I have so far: @posts = Post.all sitemap = render_to_string :template => 'sitemap/sitemap', :locals => {:posts => @posts}, :layout => false Rails.cache.write('sitemap', sitemap) But when I try to run this, I get an error: undefined local variable or method `headers' for #<Object:0x100177298> How can I render a template to a string from within Rake?

    Read the article

  • WPF: Setting toolbar button sizes using a Style

    - by Allen Ho
    I have buttons on a toolbar in WPF. When I do the XAML: <ToolBar.Resources> <Style TargetType="{x:Type Button}"> <Setter Property="Width" Value="21"></Setter> <Setter Property="Height" Value="21"></Setter> </Style> </ToolBar.Resources> None of the buttons on the toolbar set their sizes accordingly. I have to go to each button and manually set their widths and heights to the desired values. Any idea why the Style on the toolbar does not work?

    Read the article

  • Get Mechanize to handle cookies from an arbitrary POST (to log into a website programmatically)

    - by Horace Loeb
    I want to log into https://www.t-mobile.com/ programmatically. My first idea was to use Mechanize to submit the login form: However, it turns out that this isn't even a real form. Instead, when you click "Log in" some javascript grabs the values of the fields, creates a new form dynamically, and submits it. "Log in" button HTML: <button onclick="handleLogin(); return false;" class="btnBlue" id="myTMobile-login"><span>Log in</span></button> The handleLogin() function: function handleLogin() { if (ValidateMsisdnPassword()) { // client-side form validation logic var a = document.createElement("FORM"); a.name = "form1"; a.method = "POST"; a.action = mytmoUrl; // defined elsewhere as https://my.t-mobile.com/Login/LoginController.aspx var c = document.createElement("INPUT"); c.type = "HIDDEN"; c.value = document.getElementById("myTMobile-phone").value; // the value of the phone number input field c.name = "txtMSISDN"; a.appendChild(c); var b = document.createElement("INPUT"); b.type = "HIDDEN"; b.value = document.getElementById("myTMobile-password").value; // the value of the password input field b.name = "txtPassword"; a.appendChild(b); document.body.appendChild(a); a.submit(); return true } else { return false } } I could simulate this form submission by POSTing the form data to https://my.t-mobile.com/Login/LoginController.aspx with Net::HTTP#post_form, but I don't know how to get the resultant cookie into Mechanize so I can continue to scrape the UI available when I'm logged in. Any ideas?

    Read the article

  • VisualStateManager for WPF and Silverlight

    - by Allen Ho
    When you do code like VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal); I believe this code will only work for Silverlight apps. will this affect the way a WPF app works... Trying to incorportae controls that can be shared between both silverlight and WPF apps and was just wondering what were the main pitfalls were...

    Read the article

  • Add objects in relationship not work using MagicalRecord saveWithBlock

    - by yong ho
    The code to perform a save block: [MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) { for (NSDictionary *stockDict in objects) { NSString *name = stockDict[@"name"]; Stock *stock = [Stock MR_createInContext:localContext]; stock.name = name; NSArray *categories = stockDict[@"categories"]; if ([categories count] > 0) { for (NSDictionary *categoryObject in categories) { NSString *categoryId = categoryObject[@"_id"]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"categoryId == %@", categoryId]; NSArray *matches = [StockCategory MR_findAllWithPredicate:predicate inContext:localContext]; NSLog(@"%@", matches); if ([matches count] > 0) { StockCategory *cat = [matches objectAtIndex:0]; [stock addCategoriesObject:cat]; } } } } } completion:^(BOOL success, NSError *error) { }]; The Stock Model: @class StockCategory; @interface Stock : NSManagedObject @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSSet *categories; @end @interface Stock (CoreDataGeneratedAccessors) - (void)addCategoriesObject:(StockCategory *)value; - (void)removeCategoriesObject:(StockCategory *)value; - (void)addCategories:(NSSet *)values; - (void)removeCategories:(NSSet *)values; @end The json look like this: [ { "name": "iPad mini ", "categories": [ { "name": "iPad", "_id": "538c655fae9b3e1502fc5c9e", "__v": 0, "createdDate": "2014-06-02T11:51:59.433Z" } ], }, { "name": "iPad Air ", "categories": [ { "name": "iPad", "_id": "538c655fae9b3e1502fc5c9e", "__v": 0, "createdDate": "2014-06-02T11:51:59.433Z" } ], } ] Open the core data pro, You can see only stock with the name of "iPad air" has it's categories saved. I just can't figure out why. You can see in the saveWithBlock part, I first find in the context for the same _id as in json, and then add the category object in the relationship. It's working, but not all of them. Why is that?

    Read the article

  • Mechanize Javascript ...

    - by Horace Ho
    I try to submit a form by Mechanize, however, I am not sure how to add necessary form valuables which are done by some Javascript. Since Mechanize does not support Javascript yet, and so I try to add the variables manually. The form source: <form name="aspnetForm" method="post" action="list.aspx" language="javascript" onkeypress="javascript:return WebForm_FireDefaultButton(event, '_ctl0_ContentPlaceHolder1_cmdSearch')" id="aspnetForm"> <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /> <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /> <input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" /> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/..." /> <script type="text/javascript"> <!-- var theForm = document.forms['aspnetForm']; if (!theForm) { theForm = document.aspnetForm; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } // --> </script> <script language="javascript"> <!-- var _linkpostbackhit = 0; function _linkedClicked(id, key, str, a, b) { if (!b || !_linkpostbackhit) { if (!a) { __doPostBack(key, id); _linkpostbackhit = 1; } else { if (window.confirm(str)) { __doPostBack(key, id); _linkpostbackhit = 1; } } } return void(0); } // --> </script> ... <a href="JavaScript:_linkedClicked('123456','_ctl0:ContentPlaceHolder1:Link', '',0,1);">123456</a> ... </form> I tried to add the 2 variables: page.forms.first['__EVENTTARGET'] = '_ctl0:ContentPlaceHolder1:Link' page.forms.first['__EVENTARUGMENT'] = '123456' and submit the form: page.forms.first.click_button(page.forms.first.buttons.first) The result returned only (re)show the current list of links as if I have not clicked on any of the links. Any help will be appreciated. Thanks!

    Read the article

  • hash of array in objective-c, how?

    - by Horace Ho
    How is a hash of integer array can be represented in objective-c? Here is the ruby hash as an example: hi_scores = { "John" => [1, 1000], "Mary" => [2, 8000], "Bob" => [5, 2000] } such that can be accessed by: puts hi_scores["Mary"][1] => 8000 hopefully easy to serialize too. Thanks!

    Read the article

  • when was Kase born?

    - by Horace Ho
    First time I saw a class Kase, I was scratching my head. My guess it's something to do with a conflict of the keyboard case. BTW, since when, for which language(S), it becomes a norm?

    Read the article

  • XmlDataProvider authentication Http issue

    - by Allen Ho
    Hi, I have an XMLDataProvider IsAsynchronous="True" x:Key="xmlData" Source="http://192.168.15.90/text.xml"/ The only problem is the Source requires authtication. I can get around this but using a HttpWebRequest in which I can pass in NetworkCredentials, but I was just wondering if there was a simpler way of passing in credentials to the XMLDataProvider

    Read the article

  • How to store a user's password to another web application

    - by Horace Loeb
    I'm building a web application that shows users interesting visualizations of their Gmail activity (who they're emailing the most, etc). Obviously the user needs to give me his Gmail password to use the application, and I'm wondering how I should store it: Store the Gmail password in plaintext. Risky! Don't store the Gmail password at all; force the user to enter it every time he wants to sync data. Potentially inconvenient! Encrypt the Gmail password before storing it. The user's password to my application is the key. Something like (3) seems best, but with (3) I can only sync data when the user logs in (since I won't know his password to my application at any other time), which isn't ideal. I'd prefer a Mint.com-like solution whereby the user can click a button to sync data from Gmail at any time without re-entering his password (any idea how Mint accomplishes this without storing your banking passwords?)

    Read the article

  • Why should I prepend my custom attributes with "data-"?

    - by Horace Loeb
    So any custom data attribute that I use should start with "data-": <li class="user" data-name="John Resig" data-city="Boston" data-lang="js" data-food="Bacon"> <b>John says:</b> <span>Hello, how are you?</span> </li> Will anything bad happen if I just ignore this? I.e.: <li class="user" name="John Resig" city="Boston" lang="js" food="Bacon"> <b>John says:</b> <span>Hello, how are you?</span> </li> I guess one bad thing is that my custom attributes could conflict with HTML attributes with special meanings (e.g., name), but aside from this, is there a problem with just writing "example_text" instead of "data-example_text"? (It won't validate, but who cares?)

    Read the article

  • What code have you written with #pragma you found useful?

    - by Xavier Ho
    I've never understood the need of #pragma once when #ifndef #define #endif always works. I've seen the usage of #pragma comment to link with other files , but setting up the compiler settings was easier with an IDE. What are some other usages of #pragma that is useful, but not widely known? Edit: I'm not just after a list of #pragma directives. Perhaps I should rephrase this question a bit more: What code have you written with #pragma you found useful?

    Read the article

  • Parametrized get request in Ruby?

    - by Horace Loeb
    How do I make an HTTP GET request with parameters in Ruby? It's easy to do when you're POSTing: require 'net/http' require 'uri' HTTP.post_form URI.parse('http://www.example.com/search.cgi'), { "q" => "ruby", "max" => "50" } But I see now way of passing GET parameters as a hash using net/http.

    Read the article

  • Get Mechanize to handle cookies from an arbitrary POST (to log into https://www.t-mobile.com/ progra

    - by Horace Loeb
    I want to log into https://www.t-mobile.com/ programmatically. My first idea was to use Mechanize to submit the login form: However, it turns out that this isn't even a real form. Instead, when you click "Log in" some javascript grabs the values of the fields, creates a new form dynamically, and submits it. "Log in" button HTML: <button onclick="handleLogin(); return false;" class="btnBlue" id="myTMobile-login"><span>Log in</span></button> The handleLogin() function: function handleLogin() { if (ValidateMsisdnPassword()) { // client-side form validation logic var a = document.createElement("FORM"); a.name = "form1"; a.method = "POST"; a.action = mytmoUrl; // defined elsewhere as https://my.t-mobile.com/Login/LoginController.aspx var c = document.createElement("INPUT"); c.type = "HIDDEN"; c.value = document.getElementById("myTMobile-phone").value; // the value of the phone number input field c.name = "txtMSISDN"; a.appendChild(c); var b = document.createElement("INPUT"); b.type = "HIDDEN"; b.value = document.getElementById("myTMobile-password").value; // the value of the password input field b.name = "txtPassword"; a.appendChild(b); document.body.appendChild(a); a.submit(); return true } else { return false } } I could simulate this form submission by POSTing the form data to https://my.t-mobile.com/Login/LoginController.aspx with Net::HTTP#post_form, but I don't know how to get the resultant cookie into Mechanize so I can continue to scrape the UI available when I'm logged in. Any ideas?

    Read the article

  • Easier way to generate paths

    - by Horace Loeb
    Songs on Rap Genius have paths like /lyrics/The-notorious-b-i-g-ft-mase-and-puff-daddy/Mo-money-mo-problems which are defined in routes.rb as: map.song '/lyrics/:artist_slug/:title_slug', :controller => 'songs', :action => 'show' When I want to generate such a path, I use song_url(:title_slug => song.title_slug, :artist_slug => song.artist_slug). However, I'd much prefer to be able to type song_url(some_song). Is there a way I can make this happen besides defining a helper like: def x_song_path(song) song_path(:title_slug => song.title_slug, :artist_slug => song.artist_slug) end

    Read the article

  • WPF Animation Duration

    - by Allen Ho
    I have a storyboard like the following Duration="0:0:1" Completed="DeviceExplorer_Completed" The animation for some reason does not appear to be working linearly. If I change the duration to something like Duration="0:0:0.8" and assign the stroyboard to a MouseEnter event of a button, the animation moves but does not complete for some reason, I move my mouse over the button a few times before it enetually completes... Any ideas why?

    Read the article

  • Refer to similar associated models with a common name

    - by Horace Loeb
    I have these models: class Bill < ActiveRecord::Base has_many :calls has_many :text_messages end class Call < ActiveRecord::Base belongs_to :bill end class TextMessage < ActiveRecord::Base belongs_to :bill end Now, in my domain calls and text messages are both "the same kind of thing" -- i.e., they're both "bill items". So I'd like some_bill.bill_items to return all calls and text messages associated with that bill. What's the best way to do this?

    Read the article

  • WPF Menu Items Styles

    - by Allen Ho
    Hi, I have an application resource of the following <Style TargetType="{x:Type TextBlock}"> <Setter Property="Background" Value="{DynamicResource windowTextBackColor}"/> <Setter Property="Foreground" Value="{DynamicResource windowsTextForeColor}"/> </Style> So all the text blocks in my application should assume those colours. However the Menu and its containing MenuItems on my Main Window does not take these colours? I have to do the XAML for it to assume those colours, Is there a reason why setting a style that targets Text blocks does not work? Thanks

    Read the article

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