Daily Archives

Articles indexed Friday May 7 2010

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

  • Blackberry - Running Background Application

    - by Leandro
    Good afternoon. I'm starting programming in java and blackberry. I am developing an application with three windows, which I will show basic information about the device, these windows are already done and working. I need to create a process running in the background, this process will run every 10 minutes. As I make this process run in the background and is working to close the windows? This is the kind that runs the application: public class InfoBerry extends UiApplication{ public vtnprincipal vtnprincipal; public vtnbateria vtnbateria; public vtnestado vtnestado ; public vtnacerca vtnacerca; public InfoBerry(){ } public static void main(String[] args) { InfoBerry theApp = new InfoBerry(); theApp.mostrarpantalla(); } public void mostrarpantalla(){ vtnprincipal = new vtnprincipal(this); vtnbateria = new vtnbateria(this); vtnestado = new vtnestado(this); vtnacerca = new vtnacerca(this); // Inicailizamos los componentes de la pantalla principal vtnprincipal.incventana(); // La pnemos en lo alto de la pila de pantallas pushScreen(this.vtnprincipal); } } And this is the class you need to run in the background. As I have to make the call to this class to run in the background? class iconnoti extends MainScreen{ //icono de la temperatura EncodedImage imgtem = EncodedImage.getEncodedImageResource("icon_bateria_t.png"); ApplicationIcon icontem = new ApplicationIcon(imgtem); //icono de la carga de la bateria EncodedImage imgcarga = EncodedImage.getEncodedImageResource("icon_bateria.png"); ApplicationIcon iconcarga = new ApplicationIcon(imgcarga); //icono de la memoria EncodedImage imgmemo = EncodedImage.getEncodedImageResource("icon_memoria.png"); ApplicationIcon iconmemo = new ApplicationIcon(imgmemo); ApplicationIcon mIcon = icontem; boolean act; public iconnoti() { } public void rotar_temperatura(){ cron c1; actualizar_icono(icontem); actualizar_valor(DeviceInfo.getBatteryTemperature()); c1 = new cron(2,10000); c1.start(); } public void rotar_memoria(){ cron c1; actualizar_icono(iconmemo); actualizar_valor(34); c1 = new cron(3,10000); c1.start(); } public void rotar_nivel(){ cron c1; actualizar_icono(iconcarga); actualizar_valor(DeviceInfo.getBatteryLevel()); c1 = new cron(1,10000); c1.start(); } public void iniciar_servicio() { try { ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance(); ApplicationIndicator Indicator = reg.register(mIcon, false, true); } catch (Exception e) { } } public void parar_servicio() { try { ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance(); reg.unregister(); } catch (Exception e) { } } void actualizar_valor(int value) { try { ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance(); ApplicationIndicator appIndicator = reg.getApplicationIndicator(); appIndicator.setValue(value); } catch (Exception e) { } } void actualizar_icono(ApplicationIcon icon) { try { ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance(); ApplicationIndicator appIndicator = reg.getApplicationIndicator(); appIndicator.setIcon(icon); } catch (Exception e) { } } } class cron extends Thread { //private ApplicationIcon icono; public int valor; private int tiempo; iconnoti icon = new iconnoti(); public cron(int v, int t){ valor = v; tiempo = t; } public void run() { try { sleep(tiempo); } catch (InterruptedException e) { } if(valor == 1){ icon.rotar_temperatura(); }else if(valor == 2){ icon.rotar_memoria(); }else if(valor == 3){ icon.rotar_nivel(); } } } Thanks for the help.

    Read the article

  • LINQ to SQL Web Application Best Practices

    - by derek
    In my experience building web applications, I've always used a n-tier approach. A DAL that gets data from the db and populates the objects, and BLL that gets objects from the DAL and performs any business logic required on them, and the website that gets it's display data from the BLL. I've recently started learning LINQ, and most of the examples show the queries occurring right from the Web Application code-behinds(it's possible that I've only seen overly simplified examples). In the n-tier architectures, this was always seen as a big no-no. I'm a bit unsure of how to architect a new Web Application. I've been using the Server Explorer and dbml designer in VS2008 to create the dbml and object relationships. It seems a little unclear to me if the dbml would be considered the DAL layer, if the website should call methods within a BLL, which then would do the LINQ queries, etc. What are some general architecture best practices, or approaches to creating a Web Application solution using LINQ to SQL?

    Read the article

  • Best datastructure for frequently queried list of objects

    - by panzerschreck
    Hello, I have a list of objects say, List. The Entity class has an equals method,on few attributes ( business rule ) to differentiate one Entity object from the other. The task that we usually carry out on this list is to remove all the duplicates something like this : List<Entity> noDuplicates = new ArrayList<Entity>(); for(Entity entity: lstEntities) { int indexOf = noDuplicates.indexOf(entity); if(indexOf >= 0 ) { noDuplicates.get(indexOf).merge(entity); } else { noDuplicates.add(entity); } } Now, the problem that I have been observing is that this part of the code, is slowing down considerably as soon as the list has objects more than 10000.I understand arraylist is doing a o(N) search. Is there a faster alternative, using HashMap is not an option, because the entity's uniqueness is built upon 4 of its attributes together, it would be tedious to put in the key itself into the map ? will sorted set help in faster querying ? Thanks

    Read the article

  • c++ object sizes

    - by anon
    Suppose I have: struct Foo: public Bar { .... } Foo introduces no new member varaibles. Foo only introduces a bunch of member functions & static functions. Does any part of the C++ standard now guarantee me that: sizeof(Foo) == sizeof(Bar) ? Thanks!

    Read the article

  • A Python Wrapper for Shutterfly. Uploading an Image

    - by iJames
    I'm working on a Django app in which I want to order prints through Shutterfly's Open API: http://www.shutterfly.com/documentation/start.sfly So far I've been able to build the appropriate POSTs and GETs using the modules and suggested code snippets including httplib, httplib2, urllib, urllib2, mimetype, etc. But I'm stuck on the image uploading when placing an order (the ordering process is not the same process as uploading images to albums which I haven't tried.) From what I can tell, I'm supposed to basically create the multipart form data by concatenating the HTTP request body together with the binary data of the image. I take the strings: --myuniqueboundary1273149960.175.1 Content-Disposition: form-data; name="AuthenticationID" auniqueauthenticationid --myuniqueboundary1273149960.175.1 Content-Disposition: file; name="Image.Data"; filename="1_41_orig.jpg" Content-Type: image/jpeg and I put this data into it and end with the final boundary: ...\xb5|\xf88\x1dj\t@\xd9\'\x1f\xc6j\x88{\x8a\xc0\x18\x8eGaJG\x03\xe9J-\xd8\x96[\x91T\xc3\x0eTu\xf4\xaa\xa5Ty\x80\x01\x8c\x9f\xe9Z\xad\x8cg\xba# g\x18\xe2\xaa:\x829\x02\xb4["\x17Q\xe7\x801\xea?\xad7j\xfd\xa2\xdf\x81\xd2\x84D\xb6)\xa8\xcb\xc8O\\\x9a\xaf(\x1cqM\x98\x8d*\xb8\'h\xc8+\x8e:u\xaa\xf3*\x9b\x95\x05F8\xedN%\xcb\xe1B2\xa9~Tw\xedF\xc4\xfe\xe8\xfc\xa9\x983\xff\xd9... That ends up making it look like this (when I use print to debug): ... --myuniqueboundary1273149960.175.1 Content-Disposition: file; name="Image.Data"; filename="1_41_orig.jpg" Content-Type: image/jpeg ????q?ExifMM* ? ??(1?2?<??i?b?NIKON CORPORATIONNIKON D40HHQuickTime 7.62009:02:17 13:05:25Mac OS X 10.5.6%??????"?'??0220?????? ???? ? ?|_???,b???50??5 ... --myuniqueboundary1273149960.175.1-- My code for grabbing the binary data is pretty much this: filedata = open('myjpegfile.jpeg','rb').read() Which I then add to the rest of the body. I've see something like this code everywhere. I'm then using this to post the full request (with the headers too): response = urllib2.urlopen(request).read() This seems to me to be the standard way that form POSTS with files happens. Am I missing something here? At some point I might be able to make this into a library worth posting up on github, but this problem has stopped me cold in my tracks. Thanks for any insight!

    Read the article

  • feedback for programming newbies looking to build a social networking site?

    - by kgardnr
    my partner and i are launching a social learning platform - the requirements have been mapped out and are quite basic/intuitive. we are familiar with html/css, and have some very basic understanding of php, but we would love some feedback on whether we should tackle this ourselves or not. we've built websites, but in the past relied mostly on pre-fab code, i.e. wordpress, ning, etc. we've been looking specifically at ruby for developing the network, but i haven't delved into it fully yet. we're looking for some guidance and feedback - e.g. thoughts on ruby on rails? what's the learning curve? are we getting in over our heads? thanks in advance!

    Read the article

  • Puzzlepart Product Boxing Rocks

    - by madsn
    I had a few main drivers for starting the Puzzlepart project in the first place. First; working with great people, secondly having fun at work following the team principles.Third; always challenge with new ways of work. One of the main concepts that has evolved in our team is the concept of "tangible". Anything and everything HAS to be tangible and touchable and we thrive for this in everything that we do. The past two days of workshopping is a great example of this. Andreas had experienced good...(read more)

    Read the article

  • Updating the $PATH for running an command through SSH with LDAP user account

    - by Guillaume Bodi
    Hi all, I am setting up a Mac OSX 1.6 server to host Git repositories. As such we need to push commits to the server through SSH. The server has only an admin account and uses a user list from a LDAP server. Now, since it is accessing the server through a non interactive shell, git operations are not able to complete since git executables are not in the default path. As the users are network users, they do not have a local home folder. So I cannot use a ~/.bashrc and the like solution. I browsed over several articles here and there but could not get it working in a nice and clean setup. Here are the infos on the methods I gathered so far: I could update the default PATH environment to include the git executables folder. However, I could not manage to do it successfully. Updating /etc/paths didn't change anything and since it's not an interactive shell, /etc/profile and /etc/bashrc are ignored. From the ssh manpage, I read that a BASH_ENV variable can be set to get an optional script to be executed. However I cannot figure how to set it system wide on the server. If it needs to be set up on the client machine, this is not an acceptable solution. If someone has some info on how it is supposed to be done, please, by all means! I can fix this problem by creating a .bashrc with PATH correction in the system root (since all network users would start here as they do not have home). But it just feels wrong. Additionally, if we do create a home folder for an user, then the git command would fail again. I can install a third party application to set up hooks on the login and then run a script creating a home directory with the necessary path corrections. This smells like a backyard tinkering and duct tape solution. I can install a small script on the server and ForceCommand the sshd to this script on login. This script will then look for a command to execute ($SSH_ORIGINAL_COMMAND) and trigger a login shell to run this command, or just trigger a regular login shell for an interactive session. The full details of this method can be found here: http://marc.info/?l=git&m=121378876831164 The last one is the best method I found so far. Any suggestions on how to deal with this properly?

    Read the article

  • Bridge 2 routers

    - by Nathan Adams
    I have 2 Linksys WRT54GL routers flashed with DD-WRT. On each I have a different ISP, and thus a different private network. I would like to be able to talk to either network regardless of what network I am on. Example: ISP1 - Router1 - Client ISP2 - Router2 - Client What I would like to do is something like: ISP1 - Router1 - Client              ^              |              v ISP2 - Router2 - Client This would be ideally because then I don't need to introduce another device in the mix, unless I have to. But I guess the first question is - is this even possible?

    Read the article

  • When are reference files(dlls) loaded?

    - by Daniel
    I wrote a program that makes a reference to Microsoft.Web.Administration.dll, which is not present on Windows Server 2003. The program checks for the os and does not reference the dll if the os is 2003. if(OSVersion == WindowsServer2003) //do the job without referencing the Microsoft.Web.Administration.<br> else if(OSVersion == WindowsServer2008) //reference the Microsoft.Web.Administration.dll file.<br> When I tested this program on Windows Server 2003, an error occured telling me it couldn't locate the Microsoft.Web.Administration.dll. But when I separated the if-else block into 2 different methods as below, and the error did not occur. if(OSVersion == WindowsServer2003) //do the job without referencing the Microsoft.Web.Administration.<br> else if(OSVersion == WindowsServer2008) //DoIt2008Style(); So I wanted to know about reference file loading time in more detail. could you point me to some resources?

    Read the article

  • cannot open shared library during execution

    - by Sharat Chandra
    I compiled my program as follows. mpicc b_eff_io.c -o b_eff_io2 -I/scratch/irodero/papi/include -L/scratch/irodero/papi/src -lpapi -lm Howeever I got this error error while loading shared libraries: libpapi.so: cannot open shared object file: No such file or directory What shud I do ?

    Read the article

  • (SQL) Selecting from a database based on multiple pairs of pairs

    - by Owen Allen
    The problem i've encountered is attempting to select rows from a database where 2 columns in that row align to specific pairs of data. IE selecting rows from data where id = 1 AND type = 'news'. Obviously, if it was 1 simple pair it would be easy, but the issue is we are selecting rows based on 100s of pair of data. I feel as if there must be some way to do this query without looping through the pairs and querying each individually. I'm hoping some SQL stackers can provide guidance. Here's a full code break down: Lets imagine that I have the following dataset where history_id is the primary key. I simplified the structure a bit regarding the dates for ease of reading. table: history history_id id type user_id date 1 1 news 1 5/1 2 1 news 1 5/1 3 1 photo 1 5/2 4 3 news 1 5/3 5 4 news 1 5/3 6 1 news 1 5/4 7 2 photo 1 5/4 8 2 photo 1 5/5 If the user wants to select rows from the database based on a date range we would take a subset of that data. SELECT history_id, id, type, user_id, date FROM history WHERE date BETWEEN '5/3' AND '5/5' Which returns the following dataset history_id id type user_id date 4 3 news 1 5/3 5 4 news 1 5/3 6 1 news 1 5/4 7 2 photo 1 5/4 8 2 photo 1 5/5 Now, using that subset of data I need to determine how many of those entries represent the first entry in the database for each type,id pairing. IE is row 4 the first time in the database that id: 3, type: news appears. So I use a with() min() query. In real code the two lists are programmatically generated from the result sets of our previous query, here I spelled them out for ease of reading. WITH previous AS ( SELECT history_id, id, type FROM history WHERE id IN (1,2,3,4) AND type IN ('news','photo') ) SELECT min(history_id) as history_id, id, type FROM previous GROUP BY id, type Which returns the following data set. history_id id type user_id date 1 1 news 1 5/1 2 1 news 1 5/1 3 1 photo 1 5/2 4 3 news 1 5/3 5 4 news 1 5/3 6 1 news 1 5/4 7 2 photo 1 5/4 8 2 photo 1 5/5 You'll notice it's the entire original dataset, because we are matching id and type individually in lists, rather than as a collective pairs. The result I desire is, but I can't figure out the SQL to get this result. history_id id type user_id date 1 1 news 1 5/1 4 3 news 1 5/3 5 4 news 1 5/3 7 2 photo 1 5/4 Obviously, I could go the route of looping through each pair and querying the database to determine it's first result, but that seems an inefficient solution. I figured one of the SQL gurus on this site might be able to spread some wisdom. In case I'm approaching this situation incorrectly, the gist of the whole routine is that the database stores all creations and edits in the same table. I need to track each users behavior and determine how many entries in the history table are edits or creations over a specific date range. Therefore I select all type:id pairs from the date range based on a user_id, and then for each pairing I determine if the user is responsible for the first that occurs in the database. If first, then creation else edit. Any assistance would be awesome.

    Read the article

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