Daily Archives

Articles indexed Thursday June 10 2010

Page 18/121 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Return enum instead of bool from function for clarity ?

    - by Moe Sisko
    This is similar to : http://stackoverflow.com/questions/2908876/net-bool-vs-enum-as-a-method-parameter but concerns returning a bool from a function in some situations. e.g. Function which returns bool : public bool Poll() { bool isFinished = false; // do something, then determine if finished or not. return isFinished; } Used like this : while (!Poll()) { // do stuff during wait. } Its not obvious from the calling context what the bool returned from Poll() means. It might be clearer in some ways if the "Poll" function was renamed "IsFinished()", but the method does a bit of work, and (IMO) would not really reflect what the function actually does. Names like "IsFinished" also seem more appropriate for properties. Another option might be to rename it to something like : "PollAndReturnIsFinished" but this doesn't feel right either. So an option might be to return an enum. e.g : public enum Status { Running, Finished } public Status Poll() { Status status = Status.Running; // do something, then determine if finished or not. return status; } Called like this : while (Poll() == Status.Running) { // do stuff during wait. } But this feels like overkill. Any ideas ?

    Read the article

  • Complex orderby question (entity framework)

    - by PFranchise
    Ok, so I will start by saying that I am new to all this stuff, and doing my best to work on this project. I have an employee object, that contains a supervisor field. When someone enters a search on my page, a datagrid displays employees whose name match the search. But, I need it to display all employees that report to them and a third tier of employees that report to the original employee's underlings. I only need three tiers. To make this easier, employees only come in 3 ranks, so if rank==3, that employee is not in charge of others. I imagine the best method of retrieving all these employees from my employee table would be something like from employee in context.employees where employee.name == search || employee.boss.name == search || employee.boss.boss.name == search But I am not sure how to make the orderby appear the way I want to. I need it to display in tiers. So, it will look like: Big Boss Boss underling underling Boss underling Boss Boss Big Boss Like I said, there might be an easier way to approach this whole issue, and if there is, I am all ears. Any advice you can give would be HIGHLY appreciated.

    Read the article

  • JavaScript OOP problem

    - by Danmark
    I create windows like this: var obj = document.createElement('div'); obj.className = 'window'; obj.style.width = 300 + 'px'; obj.style.height = 200 + 'px'; obj.style.left = 30 + 'px'; obj.style.top = 200 + 'px'; //and so on and what I need is to attach some data to each window. The data will be grabbed via Ajax and displayed in the windows. How should I do it so that each window hold its own unique data? I don't need to display the whole data every time and this data would need be organized before being displayed, so I can't just add it with innerHTML. I need a way to hold it somewhere else where I could easily get it and then display it with innerHTML.

    Read the article

  • Having access to a private variable from other classes in Java

    - by Crystal
    If I want to create a form that adds people to a List, how do I have access to that List from another class? Where would I define that List so other classes can access the members, the size, etc? For example, if I have Class Foo that has the GUI for my form, along with buttons to add and remove people to the List, it would make sense to me to declare the List as a private instance variable of Class Foo. But then if I have another class, Class Bar, how does it get the values that are currently in that List to update some other graphical components? Or is that the wrong place to declare the List in general? Thanks.

    Read the article

  • Change User Password in ASP.NET Forms Authentication

    - by naveen
    Hi Guys, I code in C# (ASP.NET) and am using Forms authentication. I would like to know which is the best method to change a user password without using the asp:ChangePassword control. I dont want to use the reset password method. I just want to grab the password i have inside my textbox and replace it with my older password. Please note that the PasswordFormat I use is passwordFormat="Hashed" Some code snippets would be helpful Regards, Naveen Jose

    Read the article

  • help optimize sql query

    - by msony
    I have tracking table tbl_track with id, session_id, created_date fields I need count unique session_id for one day here what i got: select count(0) from ( select distinct session_id from tbl_track where created_date between getdate()-1 and getdate() group by session_id )tbl im feeling that it could be better solution for it

    Read the article

  • Make a Method of the Business Layer secure. best practice / best pattern

    - by gsharp
    We are using ASP.NET with a lot of AJAX "Page Method" calls. The WebServices defined in the Page invokes methods from our BusinessLayer. To prevent hackers to call the Page Methods, we want to implement some security in the BusinessLayer. We are struggling with two different issues. First one: public List<Employees> GetAllEmployees() { // do stuff } This Method should be called by Authorized Users with the Role "HR". Second one: public Order GetMyOrder(int orderId) { // do sutff } This Method should only be called by the owner of the Order. I know it's easy to implement the security for each method like: public List<Employees> GetAllEmployees() { // check if the user is in Role HR } or public Order GetMyOrder(int orderId) { // check if the order.Owner = user } What I'm looking for is some pattern/best practice to implement this kind of security in a generic way (without coding the the if then else every time) I hope you get what i mean :-)

    Read the article

  • How to pass the parameter to the function

    - by avaro
    Hi, I have stored procedure that takes input parameter of table type. procedure test( name samptable type); My table has the structure like table: samptable( name chracter varying; address text[]; ) So how shoul i pass the values to the function to fill the table.

    Read the article

  • git mv and only change case of directory

    - by oschrenk
    While I found similar question I didn't find an answer to my problem When I try to rename the directory from FOO to foo via git mv FOO foo I get fatal: renaming 'FOO' failed: Invalid argument OK. So I try git mv FOO foo2 && git mv foo2 foo But when I try to commit via git commit . I get # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # foo nothing added to commit but untracked files present (use "git add" to track) When I add the directory via git add foo nothing changes and git commit . gives me the same message again. What am I doing wrong? I thought I'm using a case-sensitive system (OSX) why can't I simply rename the directory?

    Read the article

  • How do I get preferences to work in Android?

    - by Dan T
    I've really been struggling through this. New to Java/Android. I'm writing my first app and this is the first thing that has taken me longer than a couple days of searching to figure out. Here's the setup: It's a BAC calculator / drink counter: A formula is used to calculate the BAC. Here's the forumla: Bac = ((StandardDrinks / 2) * (GenderConstant / Weight)) - (0.017 * Hours); So as you can see, being able to modify the gender and weight will produce more accurate and personalized results. So I have them as doubles: double GenderConstant = 7.5; //9 for female double Weight = 180; To change these variables I would like the person to be able to go into the settings and choose different values. I have these things set up, but not linked to the variables shown above because I cannot for the life of me figure out how. Here they are: I press the menu button and this pops up. Great. I'll click Settings. Now the preferences pops up. Here is my preferences.xml: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="Personal Settings"> <ListPreference android:title="Gender" android:summary="Verify or deny the presence of a Y chromosome." android:key="genderPref" android:defaultValue="male" android:entries="@array/genderArray" android:entryValues="@array/genderValues" /> <ListPreference android:title="Weight" android:summary="How much the planet pulls on you, in pounds." android:key="weightPref" android:defaultValue="180" android:entries="@array/weightArray" android:entryValues="@array/weightValues" /> </PreferenceCategory> <PreferenceCategory android:title="Drink Settings"> <ListPreference android:title="Beer Size" android:summary="The volume of your beer, in ounces." android:key="beerPref" android:defaultValue="12" android:entries="@array/beerArray" android:entryValues="@array/beerValues" /> <ListPreference android:title="Shot Size" android:summary="The volume of your shot, in ounces." android:key="shotPref" android:defaultValue="1.5" android:entries="@array/shotArray" android:entryValues="@array/shotValues" /> <ListPreference android:title="Wine Size" android:summary="The volume of your wine, in ounces." android:key="winePref" android:defaultValue="5" android:entries="@array/wineArray" android:entryValues="@array/wineValues" /> </PreferenceCategory> </PreferenceScreen> Onward to the weight ListPreference: And that shows up. The values are stored as string-arrays in res/values/arrays.xml. Here's a sample, of just the weight ones: <string-array name="weightArray"> <item>120 lbs</item> <item>150 lbs</item> <item>180 lbs</item> <item>210 lbs</item> <item>240 lbs</item> <item>270 lbs</item> </string-array> <string-array name="weightValues"> <item>120</item> <item>150</item> <item>180</item> <item>210</item> <item>240</item> <item>270</item> </string-array> This is basically as far as I've gotten. I can click a value, sure, but it doesn't change the formula because it's not linked with the doubles I created in DrinkingBuddy.java. All of the stuff displayed in the settings are just empty shells for now, including the spinner on the main layout (the default time is just set to 1 hour) I did create a Preferences.java and have tried implementing various combinations of code found in tutorials and resources around the web, but to no avail. Here it is anyway, filled with failed attempts to make beerPref (the settings option to change how many ounces in the beer) correlate with a variable in my main class: package com.dantoth.drinkingbuddy; import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.Preference.OnPreferenceClickListener; public class Preferences extends PreferenceActivity { public static final String PREF_BEER_SIZE = "PREF_BEER_SIZE"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); //Get the custom preference Preference beerPref = (Preference) findPreference("beerPref"); beerPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { SharedPreferences customSharedPreference = getSharedPreferences("myCustomSharedPrefs", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = customSharedPreference.edit(); editor.commit(); return true; }} );} } A full on tutorial and sample code would be AWESOME as I've yet to find any reliable guides out there.

    Read the article

  • How to speed-up Eclipse startup?

    - by Ivan
    I've installed Eclipse Modelling Framework (eclipse-modeling-galileo-SR1-incubation-linux-gtk.tar.gz) by extracting 'features' and 'plugins' filders of the package to '~/.eclipse/org.eclipse.platform_3.5.0_1543616141'. And now Eclipse splashscreen is shown for many minutes (the whole system (incl. BIOS, Linux and KDE) takes much less time to start). I don't need Eclipse Modelling Framework to be loaded at startup, if it is, I only need it when I start a modelling project. How to set up Eclipse to start faster and don't load all the plugins at startup time? My system runs Arch Linux 2010.05, OpenJDK 6.0, Eclipse 3.5.2.

    Read the article

  • How to configure traffic from a specific IP hardcoded to an IP to forward to another IP:PORT using i

    - by cclark
    Unfortunately we have a client who has hardcoded a device to point at a specific IP and port. We'd like to redirect traffic from their IP to our load balancer which will send the HTTP POSTs to a pool of servers able to handle that request. I would like existing traffic from all other IPs to be unaffected. I believe iptables is the best way to accomplish this and I think this command should work: /sbin/iptables -t nat -A PREROUTING -s $CUSTIP -j DNAT -p tcp --dport 8080 -d $CURR_SERVER_IP --to-destination $NEW_SERVER_IP:8080 Unfortunately it isn't working as expected. I'm not sure if I need to add another rule, potentially in the POSTROUTING chain? Below I've substituted the variables above with real IPs and tried to replicate the layout in my test environment in incremental steps. $CURR_SERVER_IP = 192.168.2.11 $NEW_SERVER_IP = 192.168.2.12 $CUST_IP = 192.168.0.50 Port forward on the same IP /sbin/iptables -t nat -A PREROUTING -p tcp -d 192.168.2.11 --dport 16000 -j DNAT --to-destination 192.168.2.11:8080 Works exactly as expected. IP and port forward to a different machine /sbin/iptables -t nat -A PREROUTING -p tcp -d 192.168.2.11 --dport 16000 -j DNAT --to-destination 192.168.2.12:8080 Connections seem to timeout. Restrict IP and port forward to only be applied to requests from a specific IP /sbin/iptables -t nat -A PREROUTING -p tcp -s 192.168.0.50 -d 192.168.2.11 --dport 16000 -j DNAT --to-destination 192.168.2.12:8080 Times out as well. Probably for the same reason as the previous entry. Does anyone have any insights or suggestions? thanks,

    Read the article

  • Google indexe désormais le Web en temps réel, et dope ses recherches à la "Caffeine"

    Mise à jour du 10.06.2010 par Katleen Google indexe désormais le Web en temps réel, et dope ses recherches à la "Caffeine" Google vient d'achever le développement de son nouveau moteur d'indexation : Caffeine. Cette évolution essentielle de son moteur de recherche devrait répondre aux préoccupations actuelles, à savoir que le guerre de la recherche en ligne se focalise actuellement sur l'immédiateté. L'indexation en temps réel du plus de données possibles (images, vidéos, articles, statuts Facebook, etc.) est dans l'air du temps, comme le prouvent les dernières améliorations apportées par Microsoft à Bing (prise en compte des Tweets). L'actuel moteur d'indexation de Google e...

    Read the article

  • Mozilla reproche à Apple et Google de vouloir s'approprier le HTML5, tandis que Microsoft est félici

    Mozilla reproche à Apple et Google de vouloir s'approprier le HTML5, tandis que Microsoft est félicité pour son soutien de la technologie Christopher Blizzard, évangéliste Open Source chez Mozilla, tire à boulets rouges sur Apple et Google. Il accuse les deux firmes d'essayer de s'approprier le format HTML5 de manière déloyale, alors qu'elles ne sont pas les seuls à travailler à son développement. Apple d'abord, qui à publié sur son site des démonstrations des capacités de l'HTML5 réservées aux utilisateurs de Safari (il faut passer par l'onglet "développeurs" pour les visionner depuis un autre navigateur). "Tous les navigateurs ne les supportent pas", indique en bas de page le groupe à la pomme, ce qui laissera...

    Read the article

  • OWB/ODI Users: Last Chance to Submit and Vote On Sessions for OpenWorld 2010

    - by antonio romero
    Now is the last chance for OWB and ODI users to propose new ETL/DW/DI sessions for OpenWorld! Oracle OpenWorld 2010 "Suggest a Session" lets members of the Oracle Mix community submit and vote on papers/talks for OpenWorld. The most popular session proposals will be included in the conference program. One promising OWB-related topic has already been submitted: Case Study: Real-Time Data Warehousing and Fraud Detection with Oracle 11gR2 Dr. Holger Friedrich and consultants from sumIT AG in Switzerland built a real-time data warehouse and accompanying BI system for real-time online fraud detection with very limited resources and a short schedule. His presentation will cover: How sumIT AG efficiently loads complex data feeds in real time in Oracle 11gR2 using, among others, Advanced Queues and XML DB How they lowered costs and sped up development, by leveraging the DBs development features including Oracle Warehouse Builder How they delivered a production-ready solution in a few short months using only three part-time developers Come vote for this proposal, on Oracle Mix: https://mix.oracle.com/oow10/proposals/10566-case-study-real-time-data-warehousing-and-fraud-detection-with-oracle-11gr2  I have already invited members of the OWB/ODI Linkedin group (with over 1400 members) to come vote on topics like this one and propose their own. If enough of us vote on a few topics, we are sure to get some on the agenda!  And if you have your own topics, using the Suggest-a-Session instructions here: http://wiki.oracle.com/page/Oracle+OpenWorld+2010+Suggest-a-Session If you propose a topic, don't forget to come to Linkedin and promote it! I have already sent the members of the Linkedin group an email announcement about this, and I will send another in a week, with links to all topics submitted. Thanks, all!

    Read the article

  • Textmate bundle to remove a directory and build with Jekyll

    - by m1755
    I am looking for a simple Textmate bundle that will do the following two tasks in order: Delete the entire contents (including folders) of a directory (eg. ~/Sites/my_site). Run the jekyll command in the directory of the Textmate project. I am going to associate this with a "save current file" and use it to auto build my Jekyll site into the specified directory each time I save a file inside the project. Notes If #2 isn't possible, then cd into a specified directory and run the jekyll command. Would prefer bash or ruby.

    Read the article

  • Clearing NSUserDefaults

    - by TonyNeallon
    I'm using +[NSUserDefaults standardUserDefaults] to store application settings. This consists of roughly a dozen string values. Is it possible to delete these values permanently instead of just setting them to a default value?

    Read the article

  • How difficult is Haskell multi-threading?

    - by mvid
    I have heard that in Haskell, creating a multi-threaded application is as easy as taking a standard Haskell application and compiling it with the -threaded flag. Other cases, however, have described the use of a par command within the actual source code. What is the state of Haskell multi-threading? How easy is it to introduce into programs? Is there a good multi-threading tutorial that goes over these different commands and their uses?

    Read the article

  • Using font in site

    - by Misha Moroshko
    I know that I can use fonts like arial "for free". But what if I want to use not a standard font ? Is that something that a browser should support ? Where I can check, for example, which fonts Firefox 3.6.3 supports ? I would like, for example, to change the font of input text area.

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >