Search Results

Search found 493 results on 20 pages for 'jimmy yuen ho wong'.

Page 12/20 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • I don't like Python functions that take two or more iterables. Is it a good idea?

    - by Xavier Ho
    This question came from looking at this question on Stackoverflow. def fringe8((px, py), (x1, y1, x2, y2)): Personally, it's been one of my pet peeves to see a function that takes two arguments with fixed-number iterables (like a tuple) or two or more dictionaries (Like in the Shotgun API). It's just hard to use, because of all the verbosity and double-bracketed enclosures. Wouldn't this be better: >>> class Point(object): ... def __init__(self, x, y): ... self.x = x ... self.y = y ... >>> class Rect(object): ... def __init__(self, x1, y1, x2, y2): ... self.x1 = x1 ... self.y1 = y1 ... self.x2 = x2 ... self.y2 = y2 ... >>> def fringe8(point, rect): ... # ... ... >>> >>> point = Point(2, 2) >>> rect = Rect(1, 1, 3, 3) >>> >>> fringe8(point, rect) Is there a situation where taking two or more iterable arguments is justified? Obviously the standard itertools Python library needs that, but I can't see it being pretty in maintainable, flexible code design.

    Read the article

  • What OpenGL functions are not GPU accelerated?

    - by Xavier Ho
    I was shocked when I read this (from the OpenGL wiki): glTranslate, glRotate, glScale Are these hardware accelerated? No, there are no known GPUs that execute this. The driver computes the matrix on the CPU and uploads it to the GPU. All the other matrix operations are done on the CPU as well : glPushMatrix, glPopMatrix, glLoadIdentity, glFrustum, glOrtho. This is the reason why these functions are considered deprecated in GL 3.0. You should have your own math library, build your own matrix, upload your matrix to the shader. For a very, very long time I thought most of the OpenGL functions use the GPU to do computation. I'm not sure if this is a common misconception, but after a while of thinking, this makes sense. Old OpenGL functions (2.x and older) are really not suitable for real-world applications, due to too many state switches. This makes me realise that, possibly, many OpenGL functions do not use the GPU at all. So, the question is: Which OpenGL function calls don't use the GPU? I believe knowing the answer to the above question would help me become a better programmer with OpenGL. Please do share some of your insights.

    Read the article

  • Ruby on Rails user login form in main layout

    - by Jimmy
    Hey guys I have a simple ror application for some demo stuff. I am running into a problem with trying to move my login form from the users controller and just have it displayed in the main navigation so that a user can easily log in from anywhere. The problem is the form doesn't generate the correct action for the html form. Ruby code: <% form_for(url_for(:action => 'login'), :method => 'post') do |f| %> <li><%= f.text_field("username") %></li> <li><%= f.password_field("password") %></li> <li><%= submit_tag("Login")%></li> <% end %> The problem is depending on the controller I am currently in this generates HTML actions like <form action="/home" method="post">...</form> when it should be generating HTML like so <form action="/login" method="post">...</form> I know I could simply do an HTML form here but I want to keep things as easy to maintain as possible. Any help?

    Read the article

  • Please suggest me the best way to design my database.

    - by Raymond Ho
    I have a table named "Pages" and a table named "Categories". Each entry of the table "Pages" is linked to the table "Categories". The "Categories" table have 5 entries, they are: "Car", "Websites", "Technology", "Mobile Phones", and "Interest". So each time I put an entry to the "Pages" table, I need to map it to the "Categories" table so are arranged properly. Here's my table: Pages ______ id [PK] name url Categories ______ id [PK] Categoryname Pages2Categories ______ Pages.id Categories.id So my question is, is this the most efficient way to create this kind of relationships between tables? It seems very amateur

    Read the article

  • Ruby proc vs lambda in initialize()

    - by Jimmy Chu
    I found out this morning that proc.new works in a class initialize method, but not lambda. Concretely, I mean: class TestClass attr_reader :proc, :lambda def initialize @proc = Proc.new {puts "Hello from Proc"} @lambda = lambda {puts "Hello from lambda"} end end c = TestClass.new c.proc.call c.lambda.call In the above case, the result will be: Hello from Proc test.rb:14:in `<main>': undefined method `call' for nil:NilClass (NoMethodError) Why is that? Thanks!

    Read the article

  • How to get result size from an SQL query and check size

    - by Jimmy
    Hi I'm trying to write a piece of code for a simple verification method as part of a MVC. At present the SQL is not written as a prepared statement so obviously it is at risk to a SQL injection so any help in regards to writing the SQL as a prepared statement would be really helpful. The method which is in the User model. public boolean getLoginInfo() { try { DBAccess dbAccess = new DBAccess(); String sql = "SELECT username, password FROM owner WHERE username = '" + this.username + "'AND password = '" + this.password + "';"; dbAccess.close();dbAccess.executeQuery(sql); dbAccess.close(); return true; } catch (Exception e) { return false; } } I want to get the size of the result set which is generated by the SQL query and if the size of it is 1 return true else it's false. If you need more info on the rest of the MVC just post and I'll get it up here.

    Read the article

  • how to check some assembly is present in client and register that if not.

    - by Jimmy
    hi there, what i wana know is that how can i use assembly that is register in GAC in my C# application. Detail: What i wana achieved is that 1) Check ABC assembly that is register in my client machine or not from my windows application 2) If not then register that assemble in GAC of client from my windows application 3) And use this assembly and perform some functions Remember that that ABC assemble is my assembly having some of my function.

    Read the article

  • before filter not working as expected

    - by Jimmy
    Hey guys I have a ruby on rails app with a before filter setup in my application controller to ensure only the owner can edit a document, but my permission check is always failing even when it shouldn't. Here is the code: def get_logged_in_user id = session[:user_id] unless id.nil? @current_user = User.find(id) end end def require_login get_logged_in_user if @current_user.nil? session[:original_uri] = request.request_uri flash[:notice] = "You must login first." redirect_to login end end def check_current_user_permission require_login logger.debug "user id is #{params[:user_id]}" logger.debug "current user id is #{session[:user_id]}" if session[:user_id] != params[:user_id] flash[:notice] = "You don't have permission to do that." redirect_to :controller => 'home' end end The code to note is in the check_current_user_permission. Here is an example of my log output: user id is 3 current user id is 3 Redirected to http://localhost:3000/home Filter chain halted as [:check_current_user_permission] rendered_or_redirected. Can anyone shed some light into why this is failing? Obviously the user_id of 3 is equal to the session's user_id of 3. What is going wrong?

    Read the article

  • Manage bad_alloc exception in C++ construtor

    - by Jimmy zhang
    I have Java experience and recently am doing some C++ coding. My question is that if I have class A, in which I have to instantiate class B and class C as two of the member variables of A. If in the constructor of A, should I assume that allocations of class B and C never fail, and handle the bad allocation exception in the destructor of A? If I don't make that assumption, meaning that I add some try catch block to catch bad_alloc of class B and class C, then if the allocation exception occurs, should I do clean up in the constructor of A? What are the recommended practices? If "new" generates a bad allocation, what value does the pointer carry?

    Read the article

  • What is a great resource for learning about the implementation details of .NET generic collections?

    - by Jimmy W
    Hi all, I'm interested in understanding the underlying implementation details of generic collections in .NET. What I have in mind are details such as how the collections are stored, how each member of a collection is accessed by the CLR, etc. For collections that are analogous to traditional data structures, such as LinkedList and Dictionary, I think I have an understanding of what's going on underneath. However, I'm not as certain about collections like List (how is set up such that it is both indexable and expandable?) and SortedList, so any leads as to what I could look up to learn more about them would be greatly appreciated.

    Read the article

  • Is 'donation' considered as commerical?

    - by Horace Ho
    I want to port an open source program to iPhone, the license prohibited any commercial use of the code. I emailed the author and he sent back an email saying freeware is ok. Of course I cannot (should not) charge anything on top of the code. Still, I want to get compensation for my work on UI design, graphics and integration work. So I wonder: Is donation (via PayPal) OK for my case? Is in-app purchase OK? i.e. the program is free, the user has the option to buy addition theme graphics? Thanks

    Read the article

  • Neat way of calling InvokeRequired and Invoke

    - by ho
    I seem to remember seeing some neat way of calling InvokeRequired and Invoke to avoid repeating too much code in every event handler but I can't remember what that was. So does anyone know a neat way of writing that code? Preferably for VB.Net 2005.

    Read the article

  • Which OpenGL functions are not GPU-accelerated?

    - by Xavier Ho
    I was shocked when I read this (from the OpenGL wiki): glTranslate, glRotate, glScale Are these hardware accelerated? No, there are no known GPUs that execute this. The driver computes the matrix on the CPU and uploads it to the GPU. All the other matrix operations are done on the CPU as well : glPushMatrix, glPopMatrix, glLoadIdentity, glFrustum, glOrtho. This is the reason why these functions are considered deprecated in GL 3.0. You should have your own math library, build your own matrix, upload your matrix to the shader. For a very, very long time I thought most of the OpenGL functions use the GPU to do computation. I'm not sure if this is a common misconception, but after a while of thinking, this makes sense. Old OpenGL functions (2.x and older) are really not suitable for real-world applications, due to too many state switches. This makes me realise that, possibly, many OpenGL functions do not use the GPU at all. So, the question is: Which OpenGL function calls don't use the GPU? I believe knowing the answer to the above question would help me become a better programmer with OpenGL. Please do share some of your insights.

    Read the article

  • SQL-wrappers (activerecord) to recommened for python?

    - by Horace Ho
    is there an activerecord (any similar SQL-wrapper) for python? which is good for: used in a server-side python script light-weight supports MySQL what I need to do: insert (filename, file size, file md5, the file itself) into (string, int, string, BLOB) columns if the same file (checksum + filename) does not exist in db thx

    Read the article

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