Search Results

Search found 96 results on 4 pages for 'cong hui'.

Page 3/4 | < Previous Page | 1 2 3 4  | Next Page >

  • When Should One Call glGetError ?

    - by Ngu Soon Hui
    glLoadIdentity says GL_INVALID_OPERATION is generated if glLoadIdentity is executed between the execution of glBegin and the corresponding execution of glEnd. But GL_INVALID_OPERATION is a flag returns by glGetError. My question is, when should we call glGetError ( in order to know whether we are calling opengl in correct sequence)?

    Read the article

  • Reverse Breath First Search in C#

    - by Ngu Soon Hui
    Anyone has a ready implementation of the Reverse Breath First Search algorithm in C#? By Reverse Breath First Search, I mean instead of searching a tree starting from a common node, I want to search the tree from the bottom and gradually converged to a common node. Let's see the below figure, this is the output of a Breath First Search: In my reverse breath first search, 9,10,11 and 12 will be the first few nodes found ( the order of them are not important as they are all first order). 5, 6, 7 and 8 are the second few nodes found, and so on. 1 would be the last node found. Any ideas or pointers?

    Read the article

  • Generate Color Gradient in C#

    - by Ngu Soon Hui
    My question here is similar to the question here, except that I am working with C#. I have two colors, and I have a predefine steps. How to retrieve a list of Colors that are the gradients between the two? This is an approach that I tried, which didn't work: int argbMax = Color.Chocolate.ToArgb(); int argbMin = Color.Blue.ToArgb(); var colorList = new List<Color>(); for(int i=0; i<size; i++) { var colorAverage= argbMin + (int)((argbMax - argbMin) *i/size); colorList.Add(Color.FromArgb(colorAverage)); } If you try the above code, you will find that a gradual increase in argb doesn't correspond to a visual gradual increase in the color. Any idea on this?

    Read the article

  • Unique Constraint At Data Level in GAE

    - by Ngu Soon Hui
    It seems that the unique constraint is not natively supported in GAE, although one can enforce unique check before putting an object to store. But that was in January 2009, what about now? Can I specify unique constraint on a column during schema creation? i.e. class Account(db.Model): name = db.StringProperty() email = db.StringProperty() as unique # something like this @classmethod def create(cls, name, email): a = Account(name=name, email=email) a.put() return a

    Read the article

  • Transform Two Lists into One Different List

    - by Ngu Soon Hui
    I have two lists of double List<double> X List<double> Y And I have a destination object: public class PointD { public double X {get;set;} public double Y {get;set;} } How to transform them into a single list? public static List<PointD> Transform(List<double> X, List<double> Y) { } All the errors checking must be there.

    Read the article

  • DllImport Based on OS Platform

    - by Ngu Soon Hui
    I have a mixture of unmanaged code ( backend) and managed code ( front end), as such, I would need to call the unmanaged code from my managed code, using interop techniques and DllImport attribute. Now, I've compiled two versions of unmanaged code, for both 32 and 64 bit OS; they are named service32.dll and service64.dll respectively. So, in my .Net code, I would have to do a DllImport for both dlls: [DllImport(@"service32.dll")] //for 32 bit OS invocation public static void SimpleFunction(); [DllImport(@"service64.dll")] //for 64 bit OS invocation public static void SimpleFunction(); And call them depending on which platform my application is running on. The issue now is that for every unmanaged function, I have to declared it twice, one for 32 bit OS and one for 64 bit OS. This is a duplication of work, and everytime I change the signature of an unmanaged function, I have to modified it in two places. Is there anyway that I can change the argument in DllImport so that the correct dll will be invoked automagically, depending on the platform?

    Read the article

  • Set A Transparent Color

    - by Ngu Soon Hui
    I have a Color, and I have a method that should return a more "transparent" version of that color. I tried the following method: public static Color SetTransparency(int A, Color color) { return Color.FromArgb(A, Color.R, Color.G, Color.B); } but for some reason, no matter what the A is, the returned Color's transparency level just won't change. Any idea?

    Read the article

  • Efficient copy of entire directory

    - by Hui Jin
    I want to copy one directory and the two files under it to another shared location of shared storage. Is it possible to combine the three(one directory and two files) as a continuous file writing and decompose it at another side to save the cost? I am limited to c language and Unix/Linux. I am considering to create a structure with the inode info and get the data at receiver. Thanks!

    Read the article

  • Interface that Entails the Implementation of Indexer

    - by Ngu Soon Hui
    I am looking for a framework-defined interface that declares indexer. In other words, I am looking for something like this: public interface IYourList<T> { T this[int index] { get; set; } } I just wonder whether .Net framework contains such interface? If yes, what is it called? You might ask why I can't just create the interface myself. Well, I could have. But if .Net framework already has that why should I reinvent the wheel?

    Read the article

  • Disable Source tab in Google Code

    - by Ngu Soon Hui
    How to disable source tab in Google Code? I don't want any random users to look at my code. Before you say that this can't be done, that Google Code is by default open source. Someone managed to do it, somehow. Edit: Before you downvote me further, take a look at the link I provided. It's possible to do it, despite whatever you want to say. And I want to know how.

    Read the article

  • Propel: How the "Affected Rows" Returned from doUpdate is defined

    - by Ngu Soon Hui
    In propel there is this doUpdate function, that will return the numbers of affected rows by this query. The question is, if there is no need to update the row ( because the set value is already the same as the field value), will those rows counted as the affected row? Take for example, I have the following table: ID | Name | Books 1 | S1oon | Me 2 | S1oon | Me Let's assume that I write a ORM function of the equivalent of the following query: update `new table` set Books='Me' where Name='S1oon'; What will the doUpdate result return? Will it return 0 ( because all the Books column are already Me, hence there is no need to update), or will it be 2 ( because there are 2 rows that fulfill the where condition) ?

    Read the article

  • ToList()-- Does it Create a New List?

    - by Ngu Soon Hui
    Let's say I have a class public class MyObject { public int SimpleInt{get;set;} } And I have a List<MyObject>, and I ToList() it and then change one of the SimpleInt, will my change be propagated back to the original list. In other words, what would be the output of the following method? public void RunChangeList() { var objs = new List<MyObject>(){new MyObject(){SimpleInt=0}}; var whatInt = ChangeToList(objs ); } public int ChangeToList(List<MyObject> objects) { var objectList = objects.ToList(); objectList[0].SimpleInt=5; return objects[0].SimpleInt; } Why? P/S: I'm sorry if it seems obvious to find out. But I don't have compiler with me now...

    Read the article

  • Set Mime_type validation in Symfony

    - by Ngu Soon Hui
    I want to make sure that during file upload time, only the file of the format jpeg, png and gif are allowed. So the "File of type:" below in the screenshot must show jpeg, png and gif: I did the following for my validator in Symfony: $this->setValidator ( 'upload your filehere', new sfValidatorFile ( array ( 'required'=>true, 'mime_types' => array ('image/jpeg, image/png, image/gif' ) ) , array( 'mime_types'=> 'only jpeg' ) ) ); but when I click on the upload button, the files are not filtered accordingly; what did I do wrong? I also try $this->setValidator ( 'upload your filehere', new sfValidatorFile ( array ( 'required'=>true, 'mime_types' => 'image/jpeg, image/png, image/gif' ) , array( 'mime_types'=> 'only jpeg' ) ) ); But it doesn't work, too. I tried the following in my form class, but unfortunately it doesn't work as well: <?php class UploadCaseForm extends sfForm { public function configure() { $this->setWidgets ( array ('Documents' => new sfWidgetFormInputFile ( ) ) ); $this->widgetSchema->setNameFormat ( 'UploadCase[%s]' ); $this->validatorSchema ['Documents'] = new sfValidatorFile ( array ('mime_types' => 'web_images' ), array ('invalid' => 'Invalid file.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be of JPEG, PNG or GIF format.' ) ); } } ?> Here's the action code: public function executeIndex(sfWebRequest $request) { $this->form = new UploadCaseForm ( ); if ($this->getRequest ()->getMethod () == sfRequest::POST) { var_dump($request->getParameter('UploadCase')); } } Edit: The accepted answer is the answer, as far as the server side validation goes. If anyone wants a client side validation, i.e., filtering the type of file that can be uploaded even before the operation hits server, then maybe there is no reliable way to do it, because of browser's constraint.

    Read the article

  • Construct A Polygon Out of Union of Many Polygons

    - by Ngu Soon Hui
    Supposed that I have many polygons, what is the best algorithm to construct a polygon--maybe with holes- out of the union of all those polygons? For my purpose, you can imagine each piece of a polygon as a jigsaw puzzle piece, when you complete them you will get a nice picture. But the catch is that a small portion <5% of the jigsaw is missing, and you are still require to form a picture as complete as possible; that's the polygon-- maybe with holes-- that I want to form. My naive approach is to take two polygons, union them, and take another polygon, union it with the union of the two polygons, and repeat this process until every single piece is union. Then I will run through the union polygon list and check whether there are still some polygons can be combined, and I will repeat this process until a satisfactory result is achieved. But this seems to be like an extremely naive approach. I just wonder is there any other better algorithm?

    Read the article

  • Why Is It That Generics Constraint Can't Be Casted to Its Derived Type?

    - by Ngu Soon Hui
    It is quite puzzling to find out that Generics Constraint Can't Be Casted to Its Derived Type. Let's say I have the following code: public abstract class BaseClass { public int Version { get { return 1; } } public string FixString { get; set; } public BaseClass() { FixString = "hello"; } public virtual int GetBaseVersion() { return Version; } } public class DeriveClass: BaseClass { public new int Version { get { return 2; } } } And guess what, this method will return a compilation error: public void FreeConversion<T>(T baseClass) { var derivedMe = (DeriveClass)baseClass; } I would have to cast the baseClass to object first before I can cast it to DerivedClass. Seems to me pretty ugly. Why this is so?

    Read the article

  • Multiple databases support in Symfony

    - by Ngu Soon Hui
    I am using Propel as my DAL for my Symfony project. I can't seem to get my application to work across two or more databases. Here's my schema.yml: db1: lkp_User: pk_User: { type: integer, required: true, primaryKey: true, autoIncrement: true } UserName: { type: varchar(45), required: true } Password: longvarchar _uniques: Unique: [ UserName ] db2: tesco: Id: { type: integer, required: true, primaryKey: true, autoIncrement: true } Name: { type: varchar(45), required: true } Description: longvarchar And here's the databases.yml: dev: db1: param: classname: DebugPDO test: db1: param: classname: DebugPDO all: db1: class: sfPropelDatabase param: classname: PropelPDO dsn: 'mysql:dbname=bpodb;host=localhost' #where the db is located username: root password: #pass encoding: utf8 persistent: true pooling: true db2: class: sfPropelDatabase param: classname: PropelPDO dsn: 'mysql:dbname=mystore2;host=localhost' #where the db is located username: root password: #pass encoding: utf8 persistent: true pooling: true When I call php symfony propel-build-model, only db1 is generated, db2 is not. Any idea how to fix this problem?

    Read the article

  • Algorithm to Group All the Cycles Together

    - by Ngu Soon Hui
    I have a lot of cycles ( indicated by numeric values, for example, 1-2-3-4 corresponds to a cycle, with 4 edges, edge 1 is {1:2}, edge 2 is {2:3}, edge 3 is {3,4}, edge 4 is {4,1}, and so on). A cycle is said to be connected to another cycle if they share one and only one edge. For example, let's say I have two cycles 1-2-3-4 and 5-6-7-8, then there are two cycle groups because these two cycles are not connecting to each other. If I have two cycles 1-2-3-4 and 3-4-5-6, then I have only one cycle group because these two cycles share the same edge. What is the most efficient way to find all the cycle groups?

    Read the article

  • Debug.Assert Appears in Release Mode

    - by Ngu Soon Hui
    We all know that Debug.Assert will not be compiled into the dlls when compiled in release mode. But for some reason Debug.Assert did appear in the release version of a component I wrote. I suspect that I might have mess up my csproject setting. Any idea why Debug.Assert appears in release mode? P/S: I have double checked to make sure that I was really compiling in release mode before asking this question.

    Read the article

  • Upload files in Google App Engine

    - by Ngu Soon Hui
    I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through db.TextProperty and db.BlobProperty. I'll be glad anyone can provide code sample ( both the client and the server side) on how this can be done, thanks

    Read the article

< Previous Page | 1 2 3 4  | Next Page >