Search Results

Search found 413 results on 17 pages for 'thierry dimitri roy'.

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

  • Beginner error in CUDA

    - by Dimitri
    Hi folks, first all i want to wish you a merry christmas. I am writing a small program in CUDA and i have the following errors : contraste.cu(167): error: calling a host function from a __device__/__global__ function is not allowed I don't understand why. Can you please help me and show me my errors. It seems that my program is correct. Here is a the bunch of code causing the problems : __global__ void kernel_contraste(float power, unsigned char tab_in[], unsigned char tab_out[], int nbl, int nbc) { int x = threadIdx.x; printf("I am the thread %d\n", x); } Part of my main program : unsigned char *dimg, *dimg_res; ..... cudaMalloc((void **)dimg, h * w * sizeof(char)); cudaMemcpy(dimg, r.data, h*w*sizeof(char), cudaMemcpyHostToDevice); cudaMalloc((void **)dimg_res, h*w*sizeof(char)); dim3 nbThreadparBloc(256); dim3 numblocs(1); kernel_contraste<<<numblocs, nbThreadparBloc >>>(puissance, dimg, dimg_res, h, w); cudaThreadSynchronize(); ..... cudaFree(dimg); cudaFree(dimg_res); The line 167 is the line where i call the printf in function kernel_contraste. For information, this program takes an image as an input( a sun Rasterfile ) and a power then it calculates the contraste of that image. Thanks !!

    Read the article

  • how do you remove the navigation bar on Android?

    - by Thierry-Dimitri Roy
    When I listen to a YouTube video fullscreen in landscape on my Galaxy Nexus, the navigation bar on the right disapear after a few seconds (the bar which contains the "back", "home" and "recent apps" buttons ). I want to do the same thing when a user watch a video in my app. What is the code to hide the navigation bar? [UPDATE] Here is the bar I want to hide. Not the title bar, nor the action bar. The navigation bar. (the bar which contains the "back", "home" and "recent apps" buttons ). I also don't want to "dim" the buttons. I'm looking into removing the bar entirely (like the YouTube app does when you plan a video fullscreen in landscape mode)

    Read the article

  • If I never ever use HashSet, should I still implement GetHashCode?

    - by Dimitri C.
    I never need to store objects in a hash table. The reason is twofold: coming up with a good hash function is difficult and error prone. an AVL tree is almost always fast enough, and it merely requires a strict order predicate, which is much easier to implement. The Equals() operation on the other hand is a very frequently used function. Therefore I wonder whether it is necessary to implement GetHashCode (which I never need) when implementing the Equals function (which I often need)?

    Read the article

  • Using overloaded operator== in a generic function

    - by Dimitri C.
    Consider the following code: class CustomClass { public CustomClass(string value) { m_value = value; } public static bool operator==(CustomClass a, CustomClass b) { return a.m_value == b.m_value; } public static bool operator!=(CustomClass a, CustomClass b) { return a.m_value != b.m_value; } public override bool Equals(object o) { return m_value == (o as CustomClass).m_value; } public override int GetHashCode() { return 0; /* not needed */ } string m_value; } class G { public static bool enericFunction1<T>(T a1, T a2) where T : class { return a1.Equals(a2); } public static bool enericFunction2<T>(T a1, T a2) where T : class { return a1==a2; } } Now when I call both generic functions, one succeeds and one fails: var a = new CustomClass("same value"); var b = new CustomClass("same value"); Debug.Assert(G.enericFunction1(a, b)); // Succeeds Debug.Assert(G.enericFunction2(a, b)); // Fails Apparently, G.enericFunction2 executes the default operator== implementation instead of my override. Can anybody explain why this happens?

    Read the article

  • Noob question about hibernate criteria

    - by Dimitri
    Hello, I have a class called User which has 2 properties : login/password. I am trying to authenticate a user in my application using hibernate criteria but my request doesn't work. [EDIT] The returned value is NULL. I have two users in my database for testing. Here is my code : @Override public User authenticate(String login, String password) throws NullPointerException { Session session = this.getSession(); User user = (User) session .createCriteria(User.class) .add( Restrictions.and( Property.forName("login").eq(login), Property.forName("password").eq(password) )).uniqueResult(); if (user == null){ throw new NullPointerException("User not found"); } return user; } Can someone tells me what is wrong with my code? Happy new Year 2011 !!

    Read the article

  • In Django, what's the best way to handle optional url parameters from the template?

    - by Thierry Lam
    I have the following type of urls which are both valid: hello/ hello/1234/ My urls.py has the following: urlpatterns = patterns('hello.views', url(r'^$', 'index', name='index'), url(r'^(?P<user_id>\d+)/$', 'index', name='index'), ) In my views.py, when I pass user_id to the template, it defaults to 0 if not specified. My template looks like the following, I'm using namespace hello for my hello app: {% url hello:index user_id %} If user_id is not specified, the url defaults to hello/0/. The only way I can think of preventing the default 0 from showing in the url is by an if stmt: {% if user_id %} {% url hello:index user_id %} {% else %} {% url hello:index %} {% endif %} The above will give me hello/ if there are no user_id and hello/1234/ if it's present. Is the above solution the best way to solve this issue?

    Read the article

  • SQL code to insert multiple rows in ms-access table

    - by Thierry
    I'm trying to speed up my code and the bottleneck seems to be the individual insert statements to a Jet MDB from outside Access via ODBC. I need to insert 100 rows at a time and have to repeat that many times. It is possible to insert multiple rows in a table with SQL code? Here is some stuff that I tried but neither of them worked. Any suggestions? INSERT INTO tblSimulation (p, cfYear, cfLocation, Delta, Design, SigmaLoc, Sigma, SampleSize, Intercept) VALUES (0, 2, 8.3, 0, 1, 0.5, 0.2, 220, 3.4), (0, 2.4, 7.8, 0, 1, 0.5, 0.2, 220, 3.4), (0, 2.3, 5.9, 0, 1, 0.5, 0.2, 220, 3.4) INSERT INTO tblSimulation (p, cfYear, cfLocation, Delta, Design, SigmaLoc, Sigma, SampleSize, Intercept) VALUES (0, 2, 8.3, 0, 1, 0.5, 0.2, 220, 3.4) UNION (0, 2.4, 7.8, 0, 1, 0.5, 0.2, 220, 3.4) UNION (0, 2.3, 5.9, 0, 1, 0.5, 0.2, 220, 3.4)

    Read the article

  • How do I create and use a junction table in Rails?

    - by Thierry Lam
    I have the following data: A post called Hello has categories greet Another post called Hola has categories greet, international My schema is: create_table "posts", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "categories", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "posts_categories", :force => true do |t| t.integer "post_id" t.integer "category_id" t.datetime "created_at" t.datetime "updated_at" end After reading the Rails guide, the most suitable relationship for the above seems to be: class Post < ActiveRecord::Base has_and_belongs_to_many :categories end class Category < ActiveRecord::Base has_and_belongs_to_many :posts end My junction table also seems to have a primary key. I think I need to get rid of it. What's the initial migration command to generate a junction table in Rails? What's the best course of action, should I drop posts_categories and re-create it or just drop the primary key column? Does the junction table have a corresponding model? I have used scaffold to generate the junction table code, should I get rid of the extra code? Assuming all the above has been fixed and is working properly, how do I query all posts and display them along with their named categories in the view. For example: Post #1 - hello, categories: greet Post #2 - hola, categories: greet, international

    Read the article

  • How do I perform a batch insert in Django?

    - by Thierry Lam
    In mysql, you can insert multiple rows to a table in one query for n 0: INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9), ..., (n-2, n-1, n); Is there a way to achieve the above with Django queryset methods? Here's an example: values = [(1, 2, 3), (4, 5, 6), ...] for value in values: SomeModel.objects.create(first=value[0], second=value[1], third=value[2]) I believe the above is calling an insert query for each iteration of the for loop. I'm looking for a single query, is that possible in Django?

    Read the article

  • How can i make a link to update my iPhone application?

    - by thierry
    hi, i know how to make a link to my app on the appstore with this URL itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id= but i don't want the user goes on the software page but directly in the update tab what is the link to do this? is there a link to update the app ?(if an update existing) thanks

    Read the article

  • Is it a good idea to cache data from web services into a database?

    - by Thierry Lam
    Let's assume that Stackoverflow offers web services where you can retrieve all the questions asked by a specific user. A request to get all question from user A can result in the following json output: { { "question": "What is rest?", "date_created": "20/02/2010", "votes": 1, }, { "question": "Which database to use for ...", "date_created": "20/07/2009", "votes": 5, }, } If I want to manipulate and present the data in any ways that I want, will it be wise to dump it in a local database? At some point, I will also want to retrieve all answers for each question and store them in a local database. The workflow that I'm thinking is: User logs in. Web services retrieve all questions asked by the logged in user, dump them in a local database. User wants all answers for a specific question, another web service does the retrieval and dump them in a local database. After user logs out, delete from the local database all questions and answers from that user.

    Read the article

  • How do I exclude data from local table schema_migrations from being pushed to Heroku DB?

    - by Thierry Lam
    I was able to push my Ruby on Rails app with MySQL(local dev) to the Heroku server along with migrating my model with the command heroku rake db:migrate. I have also read the documentation on Database Import/Export. Is that doc referring to pushing actual data from my local dev DB to whichever Heroku's DB? Do I need to modify anything in the file database.yml to make it happen? I ran the following command: heroku db:push and I am getting the error: Sending data 2 tables, 3 records !!! Caught Server Exception | ETA: --:--:-- Taps Server Error: PGError ERROR: duplicate key value violates unique constraint "unique_schema_migrations" I have 2 tables, one I create for my app and the other schema_migrations. The total number of entries among the 2 tables is 3. I'm also printing the number of entries I have in the table I have created and it's showing 0. Any ideas what I might be missing or what I am doing wrong? EDIT: I figured out the above, Heroku's DB already have schema_migrations the moment I ran migrate. New question: Does anyone know how I can exclude data from a specific table from being pushed to Heroku DB. The table to exclude in this case will be schema_migrations. Not so good solution: I googled around and someone else was having the same issue. He suggested naming the schema_migrations table to zschema_migrations. In this way data from the other tables will be pushed properly until it fails on the last table. It's a pretty bad solution but will do for the time being. A better solution will be to use an existing Rails command which can reset a specific table from a database. I don't think Rake can do that.

    Read the article

  • How do you store accented characters coming from a web service into a database?

    - by Thierry Lam
    I have the following word that I fetch via a web service: André From Python, the value looks like: "Andr\u00c3\u00a9". The input is then decoded using json.loads: >>> import json >>> json.loads('{"name":"Andr\\u00c3\\u00a9"}') >>> {u'name': u'Andr\xc3\xa9'} When I store the above in a utf8 MySQL database, the data is stored like the following using Django: SomeObject.objects.create(name=u'Andr\xc3\xa9') Querying the name column from a mysql shell or displaying it in a web page gives: André The web page displays in utf8: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> My database is configured in utf8: mysql> SHOW VARIABLES LIKE 'collation%'; +----------------------+-----------------+ | Variable_name | Value | +----------------------+-----------------+ | collation_connection | utf8_general_ci | | collation_database | utf8_unicode_ci | | collation_server | utf8_unicode_ci | +----------------------+-----------------+ 3 rows in set (0.00 sec) mysql> SHOW VARIABLES LIKE 'character_set%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) How can I retrieve the word André from a web service, store it properly in a database with no data loss and display it on a web page in its original form?

    Read the article

  • Is Django's manage.py syncdb or South used to create the test database?

    - by Thierry Lam
    With Django 1.1.1 and South 0.62, running a test from the CLI usually have the following output: Creating table some_model Installing index for my_app.SomeModel model . ----- Ran 1 test in 1s OK After upgrading to South 0.7, the output is invoking South's migration: Creating table some_model Installing index for my_app.SomeModel model Migrating... Running migrations for my_app: - Migrating forwards to 0001_initial > my_app:0001_initial - Loading initial data for my_app Migrated: - my_app . ----- Ran 1 test in 1s OK To create the test DB, has the test always used South migration in the past(before South 0.7) even if the output is not explicitly being shown?

    Read the article

  • Does Django tests run slower on the mac compared to linux?

    - by Thierry Lam
    I'm currently developing my Django projects on both: Mac OS X 10.5, 32 bit Ubuntu Server 9.10 64 bits (1 CPU, 512MB RAM) Both of the above OS are using: Python 2.6.4 Django 1.1.1 MySQL 5.1 Running 12 tests for one of my application take: Mac: 57.513s Linux: 30.935s EDIT: Mac Hardware Spec: MacBook Pro 2.2 GHz Intel Core 2 Duo 3GB RAM I'm running the Ubuntu OS on the same mac above through VMware Fusion 2.0.6. You might argue that Ubuntu Server 64 bits is faster but I have observed a similar speed difference on Ubuntu 8.10 32 bits desktop edition. Even if I turn off my linux VM and other mac applications, I still experience the slowness. Has anyone else experienced this Django test speed difference across those two OS?

    Read the article

  • How do I construct a Django form with model objects in a Select widget?

    - by Thierry Lam
    Let's say I'm using the Django Site model: class Site(models.Model): name = models.CharField(max_length=50) My Site values are (key, value): 1. Stackoverflow 2. Serverfault 3. Superuser I want to construct a form with an html select widget with the above values: <select> <option value="1">Stackoverflow</option> <option value="2">Serverfault</option> <option value="3">Superuser</option> </select> I'm thinking of starting with the following code but it's incomplete: class SiteForm(forms.Form): site = forms.IntegerField(widget=forms.Select()) Any ideas how I can achieve that with Django form?

    Read the article

  • What's the best way to aggregate the boolean values of a Python dictionary?

    - by Thierry Lam
    For the following Python dictionary: dict = { 'stackoverflow': True, 'superuser': False, 'serverfault': False, 'meta': True, } I want to aggregate the boolean values above into the following boolean expression: dict['stackoverflow'] and dict['superuser'] and dict['serverfault'] and dict['meta'] The above should return me False. I'm using keys with known names above but I want it to work so that there can be an infinite number of unknown key names.

    Read the article

  • How do I collect a bunch of Django abstract models in a QuerySet?

    - by Thierry Lam
    I have the following abstract Django models: class Food(models.Model): name = models.CharField(max_length=100) class Meta: abstract = True In one of my view, I created a bunch of Food model: panino = Food(name='Panino') poutine = Food(name='Poutine') food = [panino, poutine] From the above, I'm not saving the model and storing the Food model in a regular Python list. I want to store the above food models in a QuerySet object. How can I do that without storing any data to the database?

    Read the article

  • Maintenance tool for Application Database

    - by Thierry
    Hello ! Does anybody know about a good tool which help maintaining the database of an application ? I'm working on an application which uses a database (Microsoft Sql Server). When a development requires to change something in the database (e.g., structure, data migration...), we create a script (Transact-SQL script) and add it into our revision control tool (subversion - that tool also contains our code). Each script must add a line in a log table to keep a trace of all the scripts that have been ran into a database. In order to build a database for our application, one needs to run all scripts ordered by their creation date. I'm not really happy with this technique notably because it make application migration a bit hard. If we want to install a new version of the application somewhere, e.g., migrate from version 1.3 to 2.1, we must get all the scripts between these two versions. Then run them and ensure that everything is done in a transaction... For sure we could built home-made tools to help but I wonder if some tools already exists to do that kind of job.

    Read the article

  • What's the non brute force way to filter a Python dictionary?

    - by Thierry Lam
    I can filter the following dictionary like: data = { 1: {'name': 'stackoverflow', 'traffic': 'high'}, 2: {'name': 'serverfault', 'traffic': 'low'}, 3: {'name': 'superuser', 'traffic': 'low'}, 4: {'name': 'mathoverflow', 'traffic': 'low'}, } traffic = 'low' for k, v in data.items(): if v['traffic'] == traffic: print k, v Is there an alternate way to do the above filtering?

    Read the article

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