Daily Archives

Articles indexed Tuesday April 6 2010

Page 13/122 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Hadooop map reduce

    - by Aina Ari
    Im very much new to map reduce and i completed hadoop wordcount example. In that example it produces unsorted file (with key value) of word counts. So is it possible to make it sorted according to the most number of word occurrences by combining another map reduce task to the earlier one. Thanks in Advance

    Read the article

  • WPF: How to get the event when one FrameworkElement comes in contact with other FrameworkElement

    - by Raghav
    I am developing a small application with images and trash box icon on right hand bottom. I have multiple images floating in the main window, and using mouse I can move image from one corner to other corner of window, left, right, top and bottom. I can't figure out how do I catch an event when a image touches and panel (with trash box image), in the right hand corner. Does anybody knows which event or handler to listen? This is not a drag and drop case since my images are floating so no point using drag and drop. Thank you

    Read the article

  • How do you search a document for a string in c++?

    - by Jeff
    Here's my code so far: #include<iostream> #include<string> #include<fstream> using namespace std; int main() { int count = 0; string fileName; string keyWord; string word; cout << "Please make sure the document is in the same file as the program, thank you!" << endl << "Please input document name: " ; getline(cin, fileName); cout << endl; cout << "Please input the word you'd like to search for: " << endl; cin >> keyWord; cout << endl; ifstream infile(fileName.c_str()); while(infile.is_open()) { getline(cin,word); if(word == keyWord) { cout << word << endl; count++; } if(infile.eof()) { infile.close(); } } cout << count; } I'm not sure how to go to the next word, currently this infinite loops...any recommendation? Also...how do I tell it to print out the line that that word was on? Thanks in advance!

    Read the article

  • Implementation review for a MVC.NET app with custom membership

    - by mrjoltcola
    I'd like to hear if anyone sees any problems with how I implemented the security in this Oracle based MVC.NET app, either security issues, concurrency issues or scalability issues. First, I implemented a CustomOracleMembershipProvider to handle the database interface to the membership store. I implemented a custom Principal named User which implements IPrincipal, and it has a hashtable of Roles. I also created a separate class named AuthCache which has a simple cache for User objects. Its purpose is simple to avoid return trips to the database, while decoupling the caching from either the web layer or the data layer. (So I can share the cache between MVC.NET, WCF, etc.) The MVC.NET stock MembershipService uses the CustomOracleMembershipProvider (configured in web.config), and both MembershipService and FormsService share access to the singleton AuthCache. My AccountController.LogOn() method: 1) Validates the user via the MembershipService.Validate() method, also loads the roles into the User.Roles container and then caches the User in AuthCache. 2) Signs the user into the Web context via FormsService.SignIn() which accesses the AuthCache (not the database) to get the User, sets HttpContext.Current.User to the cached User Principal. In global.asax.cs, Application_AuthenticateRequest() is implemented. It decrypts the FormsAuthenticationTicket, accesses the AuthCache by the ticket.Name (Username) and sets the Principal by setting Context.User = user from the AuthCache. So in short, all these classes share the AuthCache, and I have, for thread synchronization, a lock() in the cache store method. No lock in the read method. The custom membership provider doesn't know about the cache, the MembershipService doesn't know about any HttpContext (so could be used outside of a web app), and the FormsService doesn't use any custom methods besides accessing the AuthCache to set the Context.User for the initial login, so it isn't dependent on a specific membership provider. The main thing I see now is that the AuthCache will be sharing a User object if a user logs in from multiple sessions. So I may have to change the key from just UserId to something else (maybe using something in the FormsAuthenticationTicket for the key?).

    Read the article

  • Reading,Writing, Editing BLOBS through DataTables and DataRows

    - by Soham
    Consider this piece of code: DataSet ds = new DataSet(); SQLiteDataAdapter Da = new SQLiteDataAdapter(Command); Da.Fill(ds); DataTable dt = ds.Tables[0]; bool PositionExists; if (dt.Rows.Count > 0) { PositionExists = true; } else { PositionExists = false; } if (PositionExists) { //dt.Rows[0].Field<>("Date") } Here the "Date" field is a BLOB. My question is, a. Will reading through the DataAdapter create any problems later on, when I am working with BLOBS? More, specifically, will it read the BLOB properly? b. This was the read part.Now when I am writing the BLOB to the DB,its a queue actually. I.e I am trying to store a queue in MySQLite using a BLOB. Will Conn.ExecuteNonQuery() serve my purpose? c. When I am reading the BLOB back from the DB, can I edit it as the original datatype, it used to be in C# environment i.e { Queue - BLOB - ? } {C# -MySQL - C# } So in this context, Date field was a queue, I wrote it back as a BLOB, when reading it back, can I access it(and edit) as a queue? Thank You. Soham

    Read the article

  • Comparing floats in their bit representations

    - by sczizzo
    Say I want a function that takes two floats (x and y), and I want to compare them using not their float representation but rather their bitwise representation as a 32-bit unsigned int. That is, a number like -495.5 has bit representation 0b11000011111001011100000000000000 or 0xC3E5C000 as a float, and I have an unsigned int with the same bit representation (corresponding to a decimal value 3286614016, which I don't care about). Is there any easy way for me to perform an operation like <= on these floats using only the information contained in their respective unsigned int counterparts?

    Read the article

  • Problem with multidimensional arrays in ruby.

    - by antiarchitect
    From script/console: >> pairs = Array.new(2).map!{Array.new(2).map!{Array.new(2, Array.new)}} => [[[[], []], [[], []]], [[[], []], [[], []]]] >> pair = Pair.first => #<Pair id: 39, charge_card_id: 1, classroom_id: 1, timeslot_id: 1, created_at: "2010-04-01 00:45:37", updated_at: "2010-04-01 00:45:47"> >> pairs[0][0][0] << pair => [#<Pair id: 39, charge_card_id: 1, classroom_id: 1, timeslot_id: 1, created_at: "2010-04-01 00:45:37", updated_at: "2010-04-01 00:45:47">] >> pairs[0][0] => [[#<Pair id: 39, charge_card_id: 1, classroom_id: 1, timeslot_id: 1, created_at: "2010-04-01 00:45:37", updated_at: "2010-04-01 00:45:47">], [#<Pair id: 39, charge_card_id: 1, classroom_id: 1, timeslot_id: 1, created_at: "2010-04-01 00:45:37", updated_at: "2010-04-01 00:45:47">]] >> So the question is why the pair object appears in pairs[0][0][0] AND in pairs[0][0][1] inspite of I did'n ask it to appear there. Notice I don't nedd to pairs[0][0][0] = pair - I want it as a first array member, so I need to use << or .push.

    Read the article

  • Retrieving Spotlight query used to open document in application

    - by vicvicvic
    If you search for something that opens Preview.app (e.g. a PDF file) in Spotlight, the application not only opens the file but actually copies the Spotlight query into the application's search field (for deeper search). iPhoto and Mail.app also do this. This is a really nice feature. Unfortunately, Apple does not document how it's implemented. Opening a document from Spotlight appears to simply send application:openFile to the application delegate. Is it possible to retrieve the user's Spotlight query somehow? Or is this a hardcoded feature of Spotlight?

    Read the article

  • Custom model validation of dependent properties using Data Annotations

    - by Darin Dimitrov
    Since now I've used the excellent FluentValidation library to validate my model classes. In web applications I use it in conjunction with the jquery.validate plugin to perform client side validation as well. One drawback is that much of the validation logic is repeated on the client side and is no longer centralized at a single place. For this reason I'm looking for an alternative. There are many examples out there showing the usage of data annotations to perform model validation. It looks very promising. One thing I couldn't find out is how to validate a property that depends on another property value. Let's take for example the following model: public class Event { [Required] public DateTime? StartDate { get; set; } [Required] public DateTime? EndDate { get; set; } } I would like to ensure that EndDate is greater than StartDate. I could write a custom validation attribute extending ValidationAttribute in order to perform custom validation logic. Unfortunately I couldn't find a way to obtain the model instance: public class CustomValidationAttribute : ValidationAttribute { public override bool IsValid(object value) { // value represents the property value on which this attribute is applied // but how to obtain the object instance to which this property belongs? return true; } } I found that the CustomValidationAttribute seems to do the job because it has this ValidationContext property that contains the object instance being validated. Unfortunately this attribute has been added only in .NET 4.0. So my question is: can I achieve the same functionality in .NET 3.5 SP1? UPDATE: It seems that FluentValidation already supports clientside validation and metadata in ASP.NET MVC 2. Still it would be good to know though if data annotations could be used to validate dependent properties.

    Read the article

  • How can I accurately determine the age of a hard drive?

    - by Todd Stout
    Yes, if it's large, heavy, and only 65 Meg in capacity, you can assume it's ancient. An RLL controller would positively indicate the drive is from antiquity. What about drives that are only 3 or 4 years old? If I know the serial number, make and model is there a public database that indicates a manufacturing date? Update: As trite as this question might seem to some, the hard drive I was looking at that precipitated this question had no obvious manufacturing date stamped on it. I realize that most do. I think the answers given are very useful to myself and others.

    Read the article

  • Fedora vs Ubuntu to host Subversion and Bugszilla over Apache

    - by Tone
    I'm not interested in a flame war of Ubuntu vs Fedora vs whatever. What I am interested in is whether or not I should move my current Ubuntu server to Fedora. I have been able to get Subversion setup and hosted via Apache over https and it works quite well (I'm a .NET guy so this was all new to me). I'm having trouble though with installing Bugszilla - have run into some issues getting all the perl scripts to run successfully so my questions are: 1) Will Bugszilla will install easier on Fedora? Can I just install a package instead of having to download the tar.gz file and untar it, run perl scripts, etc. 2) Is Fedora considered to be a better production server system? I have no desire for a GUI, just need it to host Subversion, Bugzilla over Apache2, and act as a file and print server for my home network.

    Read the article

  • Is there a version of Emacs thats runs exactly the same on OSX, Windows and Linux?

    - by Zubair
    I'm using Emacs on different environments and unsure of which version to use so that they all behave the same as I hear there are differences between XEamcs, Emacs, and some other versions. Which should I use? By the way, I am not looking to start a flame war with this post, I just want a version of emacs that runs the same everywhere which is the whole point of me wanting to switch to emacs.

    Read the article

  • php regular expression help finding multiple filenames only not full URL

    - by jason
    I am trying to fix a regular expression i have been using in php it finds all find filenames within a sentence / paragraph. The file names always look like this: /this-a-valid-page.php From help i have received on SOF my old pattern was modified to this which avoids full urls which is the issue i was having, but this pattern only finds one occurance at the begging of a string, nothing inside the string. /^\/(.*?).php/ I have a live example here: http://vzio.com/upload/reg_pattern.php

    Read the article

  • recaptcha image and curl + php

    - by user253530
    $page = $curl->post($baseUrl.'/submit.php', array('url'=>$address,'phase'=>'1','randkey'=>$randKey[0],'id'=>'c_1')); $exp = explode('recaptcha_image',$page); The id recaptcha_image is not found although if i echo $page; the webpage will be displayed and surprisingly even the recpatcha div (with the image itself). Curl shouldn't load the image for recaptcha but somehow it does though when i try to find the div, it is not there. Is there a way to capture the url of the recaptcha image?

    Read the article

  • Setting Rails Checkbox from Another Model

    - by Kevin
    I have a checkbox that belongs to "Foo" class. I have another "Preferences" class that sets the default for what that checkbox should be. I tried using f.check_box :email_preference, :value => preferences.email_preference but it doesn't work. I use this page to do new record creation as well as edit, so obviously for new records I would want to take the preferences.email_preference setting as a default, then for editing the record use the foo.email_preference. Any suggestions?

    Read the article

  • Noob-Ready Cython Tutorials

    - by spearfire
    I know a bunch of scripting languages, (python, ruby, lua, php) but I don't know any compiled languages like C/C++ , I wanted to try and speed up some python code using cython, which is essentially a python - C compiler, aimed at creating C extensions for python. Basically you code in a stricter version of python which compiles into C - native code. here's the problem, I don't know C, yet the cython documentation is aimed at people who obviously already know C (nothing is explained, only presented), and is of no help to me, I need to know if there are any good cython tutorials aimed at python programmers, or if I'm gonna have to learn C before I learn Cython. bear in mind I'm a competent python programmer, i would much rather learn cython from the perspective of the language I'm already good at, rather than learn a whole new language in order to learn cython. 1) PLEASE don't recommend psyco edit: ANY information that will help understand the oficial cython docs is useful information

    Read the article

  • Is it OK to manage associations manually?

    - by sosborn
    Here are the relevant models: User Product Order A User can sell or buy products An order has a buyer, a seller and one product I know that I can do this with a HABTM relationship between orders and user, but is seems to me like it would be simpler to put in the Order table the following columns: :seller_id :buyer_id and manage those relationships manually as orders are only created once and never edited. However, this doesn't seem very Rails-like and I am wondering if I am missing something conceptually at the HABTM relationship.

    Read the article

  • Multiple dynamic method calls or declaring a variable in Grails

    - by user303979
    In my view, if I have a situation where I need to use a dynamic method (such as Domain.findByName("name")) in multiple places, would it be better to define a variable with and refer to that, rather than have the dynamic method in multiple places? I know this seems like an obvious answer, but I just wanted to make sure Grails doesn't cache it or something, and indeed two DB calls are being made.

    Read the article

  • Mac OS X 10.5 App "not supported on this architecture" cured by copying?

    - by JWWalker
    I have an app that updates itself over the internet, and the updated copy won't run on PowerPC machines (G5) running Leopard (10.5.8). Double-clicking the app produces a message saying "You can't open the application "appname" because it is not supported on this architecture." But here's the weird part: if I duplicate the app using the Finder or using a cp -R command, then the duplicate runs fine! And yet, if I do ls -laeR on both apps, the results are identical. I restarted the machine, and the difference between the two copies was still there. Sometimes, renaming the app made it run. After a few tries, I managed to rename it back to the original name and still have it run. If this was just on one machine, I'd dismiss it as disk corruption, cosmic rays, or a voodoo hex, but it was reported by a customer and then I reproduced it on my own machine. Any ideas what could cause this behavior?

    Read the article

  • Problem with insert Thai Language data to SQL Server 2008 field datatype text and show ????

    - by embarus
    Hello everyone I created MVC ASP.Net Web application and tried insert Thai language data to SQL Server 2008 database to field with data type text and then database store ?????? which is incorrect. For Html Page I user charset utf-8 However I tried to Encode string before insert data to database and change database field collation. These do not solve problem. I'm looking forward to your reply. Thanks, embarus

    Read the article

  • Seeking tuturial: introduction to ODBC with Delphi

    - by mawg
    I have a lot of embedded C/C++/Ada experience and an outdated smattering of Delphi plus some database stuff. Now I have to implement an app in Delphi which can manipulate MySql, Oracle, maybe MS Acess. In short, I need ODBC. I need to programatically created a database, define its structure and populate its contents, then later query its existence and programatically search. I would prefer not to use 3rd party components, unless there is a compelling reason to do so (performance ought not to be an issue for the app, it won't have much data or be run often, at least not in v1.0) . Can anyone point me at a tutorial which can get me up to speed? Thanks

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >