Search Results

Search found 242 results on 10 pages for 'vincent leung'.

Page 7/10 | < Previous Page | 3 4 5 6 7 8 9 10  | Next Page >

  • Populating a foreign key table with variable user input

    - by Vincent
    I'm working on a website that will be based on user contributed data, submitted using a regular HTML form. To simplify my question, let's say that there will be two fields in the form: "User Name" and "Country" (this is just an example, not the actual site). There will be two tables in the database : "countries" and "users," with "users.country_id" being a foreign key to the "countries" table (one-to-many). The initial database will be empty. Users from all over the world will submit their names and the countries they live in and eventually the "countries" table will get filled out with all of the country names in the world. Since one country can have several alternative names, input like Chile, Chili, Chilli will generate 3 different records in the countries table, but in fact there is only one country. When I search for records from Chile, Chili and Chilli will not be included. So my question is - what would be the best way to deal with a situation like this, with conditions such that the initial database is empty, no other resources are available and everything is based on user input? How can I organize it in such way that Chile, Chili and Chilli would be treated as one country, with minimum manual interference. What are the best practices when it comes to normalizing user submitted data and is there a scientific term for this? I'm sure this is a common problem. Again, I used country names just to simplify my question, it can be anything that has possible different spellings.

    Read the article

  • What is the best web-based File Explorer?

    - by Vincent
    I would like to know what you think is the best web-based File Explorer to manage files in a remote server through HTTP / Web. It would be preferable to have PHP or Flash technology, but any good suggestion would do. More generally, how would you allow someone to manage files on a remote server with HTTP being the only open outgoing port?

    Read the article

  • Monitor and Terminate Python script based on system resource use

    - by Vincent
    What is the "right" or "best" way to monitor the system resources a python script is using and terminate it if the resource use exceeds some predetermined values. In my case memory usage is of concern. I am not asking how to measure the system resource use although I am open to suggestions. As a simple example, let's assume I have a function that finds prime numbers less than some large number and adds them to a list based on some condition. I don't know ahead of time how many prime numbers will satisfy the condition so I what to be sure to terminate the function if I use up to much system memory (8gb lets say). I know that there are ways to monitor the size of python objects. What I don't know is the proper way to monitor the size of the list and exit is to just include a size test in the prime function loop and exit if it exceeds 8gb or if there is an "external" way to monitor and exit.

    Read the article

  • Jquery - check if atleast one checkbox is checked

    - by Vincent
    All, I have the following HTML form and it can have many checkboxes. When the submit button is clicked, I want the user to get a javascript alert to check atleast one checkbox if none are checked. Is there an easy way to do this using Jquery? <form name = "frmTest" id="frmTest"> <input type="checkbox" value="true" checked="true" name="chk[120]"> <input type="checkbox" value="true" checked="true" name="chk[128]"> <input type="checkbox" name="chk[130]"> <input type="checkbox" name="chk[143]"> <input type="submit" name="btnsubmit" value="Submit"> </form> Thanks

    Read the article

  • Annotate gem and rails 3.1

    - by vincent jacquel
    Does anyone have any idea why annotate does not work anymore in rails 3.1 ? When trying to run it with : $ rvmsudo bundle exec annotate --position before and given I've got the following in my gemfile: gem "annotate", '2.4.0' I get the following error: /usr/local/rvm/gems/ruby-1.9.2-p180@rails31/gems/activerecord-3.1.0/lib/active_record /railties/databases.rake:3:in `<top (required)>': undefined method `namespace' for main:Object (NoMethodError) I'm using RVM with a gemset dedicated to rails 3.1 with Ruby 1.9.2

    Read the article

  • Odd C interview question

    - by Brennan Vincent
    Hi guys. I found this problem on a site full of interview questions, and was stumped by it. Is there some preprocessor directive that allows one to read from standard input during compilation? Write a small C program, which while compiling takes another program from input terminal, and on running gives the result for the second program. (NOTE: The key is, think UNIX). Suppose, the program is 1.c Then, while compiling $ cc -o 1 1.c int main() { printf("Hello World\n"); } ^D $ ./1 Hello World

    Read the article

  • construct graph from python set type.

    - by Vincent
    The sort question, is the an off the self function to make a graph from a set of python sets? The longer: I have several python set types. They each overlap or some are sub sets of others. I would like to make a graph (as in nodes and edges) with the edges weighted by common intersection of the sets. There are several graphing packages for python. (NetworkX, igraph,...) I am not familiar with the use of any of them. Will any of them make a graph directly from a list of sets ie, MakeGraphfromSets(alistofsets) If not do you know of an example of how to take the list of sets to define the edges. It actually looks like it might be straight forward but an example is always good to have.

    Read the article

  • Sort array with multiple keys

    - by Vincent
    All, I have the following array in array format. The JSON format is shown just for user-friendliness. How can I sort the array ascending with the key "name" in php? "food": [ { "id": 1, "name": "dessert" }, { "id": 2, "name": "maincourse" }, { "id": 3, "name": "entrees" }, { "id": 4, "name": "appetizers" } ]

    Read the article

  • derived class as default argument g++

    - by Vincent
    Please take a look at this code: template<class T> class A { class base { }; class derived : public A<T>::base { }; public: int f(typename A<T>::base& arg = typename A<T>::derived()) { return 0; } }; int main() { A<int> a; a.f(); return 0; } Compiling generates the following error message in g++: test.cpp: In function 'int main()': test.cpp:25: error: default argument for parameter of type 'A<int>::base&' has type 'A<int>::derived' The basic idea (using derived class as default value for base-reference-type argument) works in visual studio, but not in g++. I have to publish my code to the university server where they compile it with gcc. What can I do? Is there something I am missing?

    Read the article

  • use/run python's 2to3 as or like a unittest

    - by Vincent
    I have used the 2to3 utility to convert code from the command line. What I would like to do is run it basically as a unittest. Even if it tests the file rather than parts(funtions, methods...) as would be normal for a unittest. It does not need to be a unittest and I don't what to automatically convert the files I just want to monitor the py3 compliance of files in a unittest like manor. I can't seem to find any documentation or examples for this. An example and/or documentation would be great. Thanks

    Read the article

  • Question regarding Ajax Hacking

    - by Vincent
    All, I have a PHP website written in Zend Framework and MVC. Most of the controller actions check if the request is an Ajax request or not, else they redirect the user to home page. I am thinking about various ways to break that site. I am considering the following scenario: A user creates his own PHP project on his Local machine. User writes a JQuery ajax post request to one of the controllers on my site and tries to post malicious info. Ex: $.ajax({ type: 'POST', url: "https://marketsite/getinfo/getstuff", cache: false, dataType: "html", success: function(html_response){ alert(html_response); }, error: function(xhr,ajaxOptions,errorThrown){ alert(errorThrown); } }); My Question is does "url" attribute in the ajax request above take absolute path? I know it takes relative path. Also, is it possible to break any site by sending such requests? Thanks

    Read the article

  • Body class for controller in Rails app.

    - by Vincent
    Currently I have this in my layout: <body class="<%= controller.controller_name %>"> I want to add an additional class that will be the same for all actions in any controller where it's set, something like: class SomeController < ApplicationController body_class 'page' ... end class AnotherController < ApplicationController body_class 'page' ... end Which will result in: <body class="some page"> <body class="another page"> What would be the easiest way to achieve this? Can I use controller class variables for this?

    Read the article

  • CURL alternative - Design ideas

    - by Vincent
    All, I am looking for some web application design ideas here. I have a server X that hosts an SDK, which has the capacity to talk a piece of hardware. When I make an HTTPS request from an external PHP web application (hosted on Server Y) to Server X through curl, Server X gives JSON data as a response. I use this data to render my UI for the web app on Server Y. The above method seems to be slow and has a tendency to fail in production if there are too many concurrent requests. Can anybody let me know if there is an alternative to CURL or any other design people are using to pull data like this from servers? Thanks

    Read the article

  • Redirect URL from AJAX Calls

    - by Vincent
    All, I have an application written in Zend MVC Framework. So, naturally all regular requests and ajax requests go through /public/index.php. I want my application to support maintenance mode. So, in my index.php file, I have the following code: if( Zend_Registry::get('config')->maintenance == 'true' ) { header('Location:/maintenance.php'); } The issue is, when ajax requests are called they render servermaintenance.php inside the page instead of redirecting to this page. How can I make sure it gets redirected instead of getting rendered? Thanks

    Read the article

  • Migrating from Struts2 to Spring MVC

    - by Vincent Ramdhanie
    Scenario: A fairly mature project uses Struts2 and Spring and Hibernate. I say mature because it has been going on a for a while and there are many struts actions written already. Suppose we wanted to remove Struts2 from the project and instead depend entirely on Spring MVC without rewriting the entire project. Is this something that should even be considered? Are there any migration guides out there? Has anyone done this before and would like to warn me against it?

    Read the article

  • Is a full html page needed when loading a page with jQuery mobile?

    - by Vincent Hiribarren
    I am currently looking at jQuery mobile and its system of loading web pages with XmlHttpRequest. Thanks to that it is possible to automatically perform transition animations between two pages, for instance. However, something is not clear to me. If I understand correctly, each new page of a jQuery mobile powered website is injected in the DOM of the initial web page. The documentation of jQuery mobile even tells that because of this mechanism, the <title> tag of new webpages are not taken into account. So, in a way, if my initial webpage A.html loads a page B.html, I would tend to think that the webpage B.html does not need to have a full HTML grammar with the <html>, <head> or <body> tags. My page B.html could directly begin with a <div> element. Am I right?Is a full html page needed when loading a HTML page with jQuery mobile?What are the pros and cons about having a webpage with a wrong/truncated HTML syntax (appart that this page should not be accessed directly but through the main page)?

    Read the article

  • Haskell: Gluing a char and a list together?

    - by Vincent
    So I have this code here: toWords :: String - [a] toWords "" = [] toWords (nr1 : rest) | nr1 == ' ' = toWords rest | otherwise = nr1 : toWords rest The "toWords" function should simply remove all spaces and return a list with all the words. But I keep getting this error: test.hs:5:18: Couldn't match expected type a' against inferred typeChar' `a' is a rigid type variable bound by the type signature for `toWords' at test.hs:1:22 In the first argument of `(:)', namely `nr1' In the expression: nr1 : toWords rest In the definition of `toWords': toWords (nr1 : rest) | nr1 == ' ' = toWords rest | otherwise = nr1 : toWords rest Failed, modules loaded: none.

    Read the article

  • Zend - Deny access to CSS, JS, Image files

    - by Vincent
    All, I have the following Zend application structure: helloworld - application - configs - controllers - models - layouts - include - library - public - design -- css -- site.css -- js -- global.js -- images -- siteheader.gif -- sitefooter.gif - .htaccess - index.php My .htaccess file in public folder looks like this: Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] My document root points to the "public" folder. Currently, if the user visits a directory level URL, (Ex: http://localhost/design or localhost/css) , my .htaccess file above make sure to show him the "Access Forbidden" page. But if he visits the file level URL, (Ex: http://localhost/design/css/site.css), it shows him the CSS file or the js file or PHP file.. How can I make sure to lock file level access for the above file types, if accessed directly from the URL? Since my application is JS intensive, I want to protect it from users looking at it. Thanks

    Read the article

  • Sun webstack vs Installing PHP, MySQL, Apache individually

    - by Vincent
    Is it possible to install PHP, MySQL, Apache individually on Solaris instead of installing them through a webstack? What are the advantages and disadvantages? I seem to frequently get a CURL error on Solaris when dealing with HTTPS sites. (error:81072080:lib(129):func(114):reason(128). I have no clue why that error is occuring and thought it might solve it, if I upgrade to latest PHP,MySQL,Apache versions. At this point I am not even sure if it's a Solaris issue. Any advice? Thanks

    Read the article

  • Can phper give me some code snippet to consume the .net wcf service

    - by Vincent
    Hi, I can successfully make a call to wcf from php without WCF message security enabled. I search the whole forum and cannot find any clue. I'd like to know how can I pass the credential ? My WCF service use the basichttpbinding on SSL with Message security enabled. Here is my code snippet to call my wcf from .NET ServiceReference1.TestClient sc = new TestClient(); sc.ClientCredentials.UserName.UserName = "[email protected]"; sc.ClientCredentials.UserName.Password = "ABC123"; Console.WriteLine(sc.GetProfiledSchemas(412));

    Read the article

  • Zend Framework - Deny access to folders other than public folder

    - by Vincent
    All, I have the following Zend application structure: helloworld - application - configs - controllers - models - layouts - include - library - public - .htaccess - index.php - design - .htaccess The .htaccess in the root folder has the following contents: ##################################################### # CONFIGURE media caching # Header unset ETag FileETag None Header unset Last-Modified Header set Expires "Fri, 21 Dec 2012 00:00:00 GMT" Header set Cache-Control "max-age=7200, must-revalidate" SetOutputFilter DEFLATE # ##################################################### ErrorDocument 404 /custom404.php RedirectMatch permanent ^/$ /public/ The .htaccess in the public folder has the following: Options -MultiViews ErrorDocument 404 /custom404.php RewriteEngine on # The leading %{DOCUMENT_ROOT} is necessary when used in VirtualHost context RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -l [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] My vhost configuration is as under: <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "C:\\xampp\\htdocs\\xampp\\helloworld\\" ServerName helloworld ServerAlias helloworld <Directory "C:\\xampp\\htdocs\\xampp\\helloworld\\"> Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from 127.0.0.1 </Directory> </VirtualHost> Currently, if the user visits, http://localhost, my .htaccess files above make sure, the request is routed to http://localhost/public automatically. If the user visits any other folder apart from public folder from the address bar, he gets a directory listing of that folder. How can I make sure to deny the user access to every other folder except the public folder? I want the user to be redirected to the public folder if he visits any other folder. However, if the underlying code requests something from other folders, (ex: ) it should still work.. Thanks

    Read the article

  • Zend XML parsing

    - by Vincent
    I have an xml file called error.xml like this: <?xml version="1.0" encoding="UTF-8"?> <errorList> <error> <code>0</code> <desc>Fault</desc> <ufmessage>Fault</ufmessage> </error> <error> <code>1</code> <desc>Unknown</desc> <ufmessage>Unknown</ufmessage> </error> <error> <code>2</code> <desc>Internal Error</desc> <ufmessage>Internal Error</ufmessage> </error> </errorList> I am using Zend and have the above xml file stored in a Zend Registry variable called "apperrors" like this: $apperrors = new Zend_Config_Xml( 'error.xml'); Zend_Registry::set('apperrors', $apperrors->errorList); If my code throws an error code of 2, I want a snippet of code to check the error code with "code" key in "apperrors" array and echo the ufmessage value corresponding to it. How can I do this? Ex: //Error thrown by the code. Hardcoded for now... $errorThrownByCode = 2; //Get the Zend Registry value for all errors $errorList = Zend_Registry::get('apperrors'); //Write some code to compare $errorThrownByCode with $errorList->error->code //If found echo $errorList->error->ufmessage, else echo "An Unknown error occured"; Thanks

    Read the article

  • Construct a variadic template of unsigned int recursively

    - by Vincent
    I need a tricky thing in a C++ 2011 code. Currently, I have a metafunction of this kind : template<unsigned int N, unsigned int M> static constexpr unsigned int myFunction() This function can generate number based on N and M. I would like to write a metafunction with input N and M, and that will recursively construct a variadic template by decrementing M. For example, by calling this function with M = 3, It will construct a variadic template called List equal to : List... = myFunction<N, 3>, myFunction<N, 2>, myFunction<N, 1>, myFunction<N, 0> How to do that (if it is possible of course) ?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10  | Next Page >