Daily Archives

Articles indexed Friday September 7 2012

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

  • Is There a Real Advantage to Generic Repository?

    - by Sam
    Was reading through some articles on the advantages of creating Generic Repositories for a new app (example). The idea seems nice because it lets me use the same repository to do several things for several different entity types at once: IRepository repo = new EfRepository(); // Would normally pass through IOC into constructor var c1 = new Country() { Name = "United States", CountryCode = "US" }; var c2 = new Country() { Name = "Canada", CountryCode = "CA" }; var c3 = new Country() { Name = "Mexico", CountryCode = "MX" }; var p1 = new Province() { Country = c1, Name = "Alabama", Abbreviation = "AL" }; var p2 = new Province() { Country = c1, Name = "Alaska", Abbreviation = "AK" }; var p3 = new Province() { Country = c2, Name = "Alberta", Abbreviation = "AB" }; repo.Add<Country>(c1); repo.Add<Country>(c2); repo.Add<Country>(c3); repo.Add<Province>(p1); repo.Add<Province>(p2); repo.Add<Province>(p3); repo.Save(); However, the rest of the implementation of the Repository has a heavy reliance on Linq: IQueryable<T> Query(); IList<T> Find(Expression<Func<T,bool>> predicate); T Get(Expression<Func<T,bool>> predicate); T First(Expression<Func<T,bool>> predicate); //... and so on This repository pattern worked fantastic for Entity Framework, and pretty much offered a 1 to 1 mapping of the methods available on DbContext/DbSet. But given the slow uptake of Linq on other data access technologies outside of Entity Framework, what advantage does this provide over working directly with the DbContext? I attempted to write a PetaPoco version of the Repository, but PetaPoco doesn't support Linq Expressions, which makes creating a generic IRepository interface pretty much useless unless you only use it for the basic GetAll, GetById, Add, Update, Delete, and Save methods and utilize it as a base class. Then you have to create specific repositories with specialized methods to handle all the "where" clauses that I could previously pass in as a predicate. Is the Generic Repository pattern useful for anything outside of Entity Framework? If not, why would someone use it at all instead of working directly with Entity Framework? Edit: Original link doesn't reflect the pattern I was using in my sample code. Here is an (updated link).

    Read the article

  • Do I need to know servlets and JSP to learn spring or hibernate or any other java web frameworks?

    - by KyelJmD
    I've been asking a lot of people where to start learning java web development, I already know core java (Threading,Generics,Collections, a little experience with (JDBC)) but I do not know JSPs and servlets. I did my fair share of development with several web based applications using PHP for server-side and HTML,CSS,Javascript,HTML5 for client side. Most people that I asked told me to jump right ahead to Hibernate while some told me that I do not need to learn servlets and jsps and I should immediately study the Spring framework. Is this true? do I not need to learn servlets and JSPs to learn hibernate or Spring? All of their answers confused me and now I am completely lost what to learn or study. I feel that if I skipped learning JSP and servlets I would missed a lot of important concepts that will surely help me in the future. So the question, do I need to have foundation/know servlets and JSP to learn spring or hibernate or any other java web frameworks.?

    Read the article

  • How do you encode Algebraic Data Types in a C#- or Java-like language?

    - by Jörg W Mittag
    There are some problems which are easily solved by Algebraic Data Types, for example a List type can be very succinctly expressed as: data ConsList a = Empty | ConsCell a (ConsList a) consmap f Empty = Empty consmap f (ConsCell a b) = ConsCell (f a) (consmap f b) l = ConsCell 1 (ConsCell 2 (ConsCell 3 Empty)) consmap (+1) l This particular example is in Haskell, but it would be similar in other languages with native support for Algebraic Data Types. It turns out that there is an obvious mapping to OO-style subtyping: the datatype becomes an abstract base class and every data constructor becomes a concrete subclass. Here's an example in Scala: sealed abstract class ConsList[+T] { def map[U](f: T => U): ConsList[U] } object Empty extends ConsList[Nothing] { override def map[U](f: Nothing => U) = this } final class ConsCell[T](first: T, rest: ConsList[T]) extends ConsList[T] { override def map[U](f: T => U) = new ConsCell(f(first), rest.map(f)) } val l = (new ConsCell(1, new ConsCell(2, new ConsCell(3, Empty))) l.map(1+) The only thing needed beyond naive subclassing is a way to seal classes, i.e. a way to make it impossible to add subclasses to a hierarchy. How would you approach this problem in a language like C# or Java? The two stumbling blocks I found when trying to use Algebraic Data Types in C# were: I couldn't figure out what the bottom type is called in C# (i.e. I couldn't figure out what to put into class Empty : ConsList< ??? >) I couldn't figure out a way to seal ConsList so that no subclasses can be added to the hierarchy What would be the most idiomatic way to implement Algebraic Data Types in C# and/or Java? Or, if it isn't possible, what would be the idiomatic replacement?

    Read the article

  • How to fix: Ubuntu 12.04 reboots after loading with elilo

    - by Casey
    I have an HP p6-2120 with CPU: AMD A6-3620 APU with Radeon Graphics RAM: 6GB BIOS: HO2_710.ROM v7.10 [AMI v7.10 4/19/2012] Disk: SATA1 (/dev/sda) - 1 TB (windows) Disk: SATA2 (/dev/sdb) - 1 TB partitioned using "parted -a optimal /dev/sdb" as follows: .. 1049KB 201MB FAT32 boot flag set .. 201MB 60GB ext2 (/) .. 68GB 78GB linux-swap(v1) (swap) .. 78GB 790GB ext4 (/home) .. - rest is "free" space reserved for other purposes (eventually) ubuntu: 12.04.1 LTS [specifically: Release 12.04 (precise) 64-bit] kernel: linux 3.2.0-29-generic I created a bootable EFI USB from the ISO (64-bit) which I downloaded. I can run and install from the USB without any problems. The BIOS is an EFI bios that appears to be capable of booting in either EFI or Legacy mode. Initially, I did the "standard" install with NOTHING on disk2, and let the installer configure everything. The net result of this was that when I started the computer and forced it into "boot" menu mode, it DOES NOT recognize SATA2 as an EFI drive, and when I attempt to "legacy" boot from it, I get the message "ERROR: No Boot Disk has been detected." The "standard" install created one large partition that consumed the entire disk. At that point, I manually partitioned the disk (using sudo parted -a optimal /dev/sdb) as described above. I selected the "other" install, and changed the /dev/sdb1 to "bios_grub", /dev/sdb2 as "/" (ext4), /dev/sdb3 as swap, and /dev/sdb4 as "/home". [Note: fearing that possibly elilo did not recognize ext4, I switched /dev/sdb2 to ext2 and re-insalled] The net result was that the install appeared to trash the /dev/sdb1 partition so that it was NOT readable by anything. I re-formated /dev/sdb1 as FAT32 and set the boot flag. I repeated the install ignoring the messages about no bios_grub partition. After several attempts to get GRUB2 to work, I switched to elilo. I downloaded the most recent version and copied it (elilo-3.14-ia64.efi) to /dev/sdb1/efi/boot/bootx64.efi. (The BIOS boot loader did not recognize it either as elilo-3.14.ia64.efi or as elilo.efi. Based on the advice in one of the web-pages I found, I renamed it to bootx64.efi. This worked.) In that same directory (/efi/boot), I copied the file pointed to the link in /dev/sdb2/vmlinuz to /efi/boot/vmlinuz, and the file pointed to the link in /dev/sdb2/initrd.img to /efi/boot/initrd.img. I created an elilo.conf file as follows: timeout=5000 prompt default=linux-boot image=vmlinuz label=linux-boot read-only initrd=initrd.img root=/dev/sdb2 The /efi/boot directory contains 4 files: bootx64.efi elilo.conf vmlinuz initrd.img When I power-cycle the computer and force the boot menu, drive2 shows up as an EFI bootable drive. When I select it, I get the elilo prompt. Pressing , it appears to load the kernal (I have tried it with verbose=5, and there is a long string of messages with the final one a command line to load the kernel and a series of several dots that fly by) then the screen goes blank, and it reboots the computer. [Note: I have also tried substituting the UUID as found in the /etc/fstab of the installed system for the root directory. This had no effect.] This is a brief synopsis of several nights of fiddling with this. I would deeply appreciate any help you can give.

    Read the article

  • Special keyboard keys?

    - by Hailwood
    I have a new laptop, It has the icon for toggling the touchpad on fn+f1 so I would like to assign this shortcut, I have a working script, and I can assign the script to any other combination, but it appears that ubuntu does not pick up the fn+f1 combination? how can I correct this? The other one is, My laptop has three extra buttons, Assist, Web, and Vaio. These map to Help, Homepage, and nothing respectively. the Web button is working perfectly. The assist button if I am setting up a keyboard shortcut for something it binds fine, but then pressing it does nothing? The Vaio button seems to not be listened to much like the combination I posted above. How can i correct the assist and Vaio buttons?

    Read the article

  • How do I limit the size of my syslog?

    - by Wayne Werner
    I've got my mom's computer running Ubuntu 12.04 LTS. It's been working just fine but all of the sudden syslog has been filling up. And by filling up I mean I just deleted a /var/log/syslog that was 400GB in size. Yes - Gigabytes. While I'm sure there was some useful information in there, I'm not sure that 400GB is any kind of information to sift through. And what's really amazing about it is that it happened within a period of 8 hours - I had ran df around noon, and between then and now her drive filled up 30% (from just under 70% to 100%). What could be causing this and how could I fix it?`

    Read the article

  • Installing Ubuntu 12 on SATA III drive

    - by Jared
    I am trying to install Ubuntu 12.04 on a SATA III drive however the installer will not recognize my drive in the guided (dual-boot) install. I have changed the controller from IDE to AHCI to no avail, the install still will only recognize my very small second drive that is plugged into a SATA II port. The thing is, the unguided install sees this drive just fine, I just am not sure enough of what I'm doing to feel safe installing via this method. Is there a fix for this beyond plugging my drive into a SATA II port? I really would like to avoid this because of my terrible cable management skills it would be a huge pain to switch it over.

    Read the article

  • Mouse Not Working on Boot

    - by user88043
    I have seen several topics regarding this situation, but none of them truly address my issue (that, or there are no answers that solve the issue.) Upon booting into Ubuntu 12.04.1 x64 my mouse wired USB mouse (Steelseries Sensei if that makes any difference) either doesn't work or stops working immediately after the grub menu, prior to the login screen appearing. The cursor is present, but obviously not reactive to any mouse movement; even the LED on my mouse turns off (or fails to turn on.) The only way I've found to activate the mouse is to restart the computer, and even then it's 50/50 at best as to whether or not the mouse will be powered. This issue has never happened in Windows 7, so the mouse is operating properly on the hardware and connection side. Forgive my ignorance of Ubuntu (and Linux in general), but I was hopeful that someone would have some suggestions, or could at least instruct me on what to check in order to provide any further information for diagnoses.

    Read the article

  • XP shared printer doesn't show for printing from 12.04

    - by Anne
    Sorry if someone else has this same problem... I found similar, but not exactly the same. I have a Canon Pixma MP250 connected via USB to a WinXP machine. Running dual boot from laptop, 12.04. When I try to add the printer (on Ubuntu machine), it doesn't show up. Prints fine from Win7 (dual boot). Have been unable to find a CUPS driver, but have a cnijfilter (possibly has nothing to do with any of this?). So irritated (not at anyone)... just driving me crazy! Any help is awesome!

    Read the article

  • Can using an apt proxy (d-i mirror/http/proxy string http://mymirror) affect the installation of a .deb?

    - by Randolph
    I have been doing Ubuntu deployment using a preseed.cfg. After becoming comfortable with the packages being installed it was time to reduce download time and internet traffic by creating a mirror. I ended up doing a "partial mirror" using apt-cacher-ng and preseeding it by adding d-i mirror/http/proxy string http://mymirror to the preseed.cfg. This is where things got strange. I have a few .debs that I run as part of preseed/late_command by wgetting them and installing them with dpkg -i. The packages were installing without issue until added the proxy. With the proxy they fail to install. So does the proxy affect installing .debs during preseeded installation?

    Read the article

  • Hard time installing Ubuntu

    - by Nick
    I have a MSI GT780DXR that currently is booting windows 7. I've been trying to dual boot windows 7 and ubuntu for some time now. Here's specs that I think would make a difference Windows 7 500GB*2 RAID 0 hard drives. (Hardware RAID I'm not sure if it's a dedicated RAID card though) 7200RPM Nvidia GT570M Background: I tried to install 12.04 (64 bit) a few times but the Desktop live cd and pendrive boots with a black screen. I've tried wubi but it boots to a black screen as well. I then tried the alternative 12.04 (64 bit) and went through the installation all the way til partitioning. I let Ubuntu notice the raid setup and I setup my swap, /, and home drives, I used my free space to create the three partitions. I tried to resize the windows drive and it told me I couldn't and to be happy with my current setup. When I finally got past I got an error on installing GRUB 2 and decided to skip it and continued on to finish installation. When I tried to boot up I got an invalid partition table error. Windows recovery disc, and a GPARTED live cd couldn't find any hard drives. I ended up following advice and typed this into the recovery command prompt. bootrec /fixmbr bootrec /fixboot bootrec /rebuildBcd It worked and here I am now. The question is, how would I be able to dual boot windows 7 and Ubuntu 12.04 with this information? Thanks,

    Read the article

  • Does Huawei E398 LTE Modem works with Netgear Router?

    - by Paul Smith
    I've been using a Netgear router sharing the signal through my Huawei E160 dongle, but following the speeds update and the device limit, it does not satisfy the demand. Through research, I've found that Huawei E398 is the latest and functional dongle so far. I'm going to update, but the confusion comes: Is it compatible for my Netgear router? Will it work? Any information will be appreciated. I found the unlocked E398 here.

    Read the article

  • Default program for opening .pro Qt project files

    - by air-dex
    I would like to set Qt Creator (the one which is in the Nokia Qt SDK, not the one in Canonical PPAs) as the default program to open .pro Qt project files. But it appears that my Ubuntu install (12.04 while I am writing the question) recognizes .pro files as plain text files instead of Qt project files. I know that I could fix the problem by setting Qt Creator as the default program for opening plain text files but I want to keep on opening plain text files with the program I currently use for this (gedit). So my question is : how can I do for making my Ubuntu install recognizing .pro files as Qt project files instead of plain text files ? NB : I have already looked at Ubuntu Tweak to associate Qt project files with Qt Creator but I did not find anything relevant (perhaps I missed it too). EDIT : the solution is in the last comment of the accepted answer.

    Read the article

  • Booting and shutting down process is very slow, with some others issues

    - by Hoghweed
    Recently I've installed Ubuntu 12.04 replacing Ubuntu 11.10, after installation, When I started my "Lenovo W520", I feel uncomfortable. It is too slow in booting process and also very slow in shutting down. Some operations are very slow. The booting is so slow that, it's seems It is a Windows system instead of an Ubuntu. Can anyone suggest, what actions I can take to investigate the issue and then to fix the problem? Re-installation advice should be last option.

    Read the article

  • How to mount NAS folders via direct wired connection?

    - by Pavel Vlasov
    There are two machines connected to each other via network cable. One is notebook Ubuntu 12.04. Another is NAS Western Digital with a Debian. The NAS has some files shared via samba. I am not sure how it is called but under Windows these files are accessible via path \mybooklive\public. I know there is NFS - probably it is preferable over samba... So, how to get my files accessible from Ubuntu when a cable is plugged?

    Read the article

  • How to get the correct battery status?

    - by GUI Junkie
    At this moment, ever since I installed Ubuntu on this machine, the battery status says: not present. Looking at this answer, however, I find that /proc/acpi/battery/BAT1/info (sometimes its /proc/acpi/battery/BAT0/info, use tab complete to help) has the following info: present: yes design capacity: 4400 mAh last full capacity: 4400 mAh battery technology: rechargeable design voltage: 11100 mV design capacity warning: 300 mAh design capacity low: 132 mAh cycle count: 0 capacity granularity 1: 32 mAh capacity granularity 2: 32 mAh model number: BAT1 serial number: 11 battery type: 11 OEM info: 11 In accordance to this answer, I've checked the /proc/acpi/battery/BAT1/state file: present: yes capacity state: ok charging state: charged present rate: unknown remaining capacity: unknown present voltage: 10000 mV The acpi -b command returns: Battery 0: Unknown, 0%, rate information unavailable Any suggestions on getting the battery info updated?

    Read the article

  • Find "secret" port number

    - by CJ Sculti
    this may be kind of an odd question. My friend has challenged me. So somehow, he change the "port" of his site to 31337. If you just go to domain.com, you get redirected to google, to access the real site you go to domain.com:31337. He is going to change it again and he is challenging me to find out which port it is. Is this possible without guessing? Hopefully someone can help! Thanks. Oh, and is this the right stack exchange site to post this on...

    Read the article

  • Password-free logins using your email address only?

    - by Mario
    The state of logins is horrendous. With each site having it's own rules for passwords, it can be very hard to remember what variation you used on any given site. Logins are pure pain. One thing I love about Craigslist is that it did away with logins altogether. I know this design may not suit every site, but there's something to their design that beckons to be repeated. OpenID is great on sites that have adopted it, but it's still not standard. Would it be feasible/wise to use an email address as a login and provide no password? The site would send a short-term key directly to your email address. You click on the link and you're in. When you're done, you "logout" and your key is terminated. I've toyed with this idea before. What concerns (i.e. spammers, bots, etc.) would make this impractical or unsafe and could they be overcome?

    Read the article

  • Sampler referencing in HLSL - Sampler parameter must come from a literal expression

    - by user1423893
    The following method works fine when referencing a sampler in HLSL float3 P = lightScreenPos; sampler ShadowSampler = DPFrontShadowSampler; float depth; if (alpha >= 0.5f) { // Reference the correct sampler ShadowSampler = DPFrontShadowSampler; // Front hemisphere 'P0' P.z = P.z + 1.0; P.x = P.x / P.z; P.y = P.y / P.z; P.z = lightLength / LightAttenuation.z; // Rescale viewport to be [0, 1] (texture coordinate space) P.x = 0.5f * P.x + 0.5f; P.y = -0.5f * P.y + 0.5f; depth = tex2D(ShadowSampler, P.xy).x; depth = 1.0 - depth; } else { // Reference the correct sampler ShadowSampler = DPBackShadowSampler; // Back hemisphere 'P1' P.z = 1.0 - P.z; P.x = P.x / P.z; P.y = P.y / P.z; P.z = lightLength / LightAttenuation.z; // Rescale viewport to be [0, 1] (texture coordinate space) P.x = 0.5f * P.x + 0.5f; P.y = -0.5f * P.y + 0.5f; depth = tex2D(ShadowSampler, P.xy).x; depth = 1.0 - depth; } // [Standard Depth Calculation] float mydepth = P.z; shadow = depth + Bias.x < mydepth ? 0.0f : 1.0f; If I try and do anything with the sampler reference outside the if statement then I get the following error: Sampler parameter must come from a literal expression This code demonstrates that float3 P = lightScreenPos; sampler ShadowSampler = DPFrontShadowSampler; if (alpha >= 0.5f) { // Reference the correct sampler ShadowSampler = DPFrontShadowSampler; // Front hemisphere 'P0' P.z = P.z + 1.0; P.x = P.x / P.z; P.y = P.y / P.z; P.z = lightLength / LightAttenuation.z; } else { // Reference the correct sampler ShadowSampler = DPBackShadowSampler; // Back hemisphere 'P1' P.z = 1.0 - P.z; P.x = P.x / P.z; P.y = P.y / P.z; P.z = lightLength / LightAttenuation.z; } // Rescale viewport to be [0, 1] (texture coordinate space) P.x = 0.5f * P.x + 0.5f; P.y = -0.5f * P.y + 0.5f; // [Standard Depth Calculation] float depth = tex2D(ShadowSampler, P.xy).x; depth = 1.0 - depth; float mydepth = P.z; shadow = depth + Bias.x < mydepth ? 0.0f : 1.0f; How can I reference the sampler in this manner without triggering the error?

    Read the article

  • Is it considered poor programming to do this with xna components?

    - by Rob
    I created my own Menu System that is event driven. In order to have a loading screen and multithreaded loading to work, I devised this sort of implementation: //Let's check if the game is done loading. if (_game != null) { _gameLoaded = _game.DoneLoading; } //This means the game is loading still, //therefore the loading screen should be active. if (!_gameLoaded && _gameActive) { _gameScreenList[2].UpdateMenu(); } //The loading screen was selected. if (_gameScreenList[2].CurrentState == GameScreen.State.Shown && !_gameActive) { Components.Add(_game = new ParadoxGame(this)); _game.Initialize(); //Initializes the Game so that the loading can begin. _gameActive = true; } In the XNA Game Component that contains the actual game, in the LoadContent method I simply created a new Thread that calls another method ThreadLoad that has all the actual loading. I also have a boolean variable called DoneLoading in the XNA Game Component that is set to true at the end of the ThreadLoad. I am wondering if this is a poor implementation.

    Read the article

  • XNA 4.0 SpriteFont not displaying all Characters

    - by Iain Brown
    Am looking for a little help and trying to use SpriteFont in my XNA 4.0 game but the problem is am displaying to string "This is a test" but all that's displayed on the screen is "This is st" so the "a te" are missing from the screen. The space is there for the characters but the letters are not. The code am using is: spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); spriteBatch.DrawString(font,"this is a test",new Vector2(692,372),Color.White); spriteBatch.Draw(texture,new Rectangle(0,0,100,100),Color.White); spriteBatch.End(); Any help with this would be great!

    Read the article

  • QtCreator: QML Debugger, connection refused - switch of QML debugger

    - by Horst Walter
    In QtCreator (2.5.2, Win7) I get a permanent / repeating output in the Debugger window. Debugging etc. all fine. Since I do not need QML debugging, how can I switch off the QML debugger? Or fix the issue in order to get rid of the repeating message. QML Debugger: Error: (0) Connection refused QML Debugger: Connecting to debug server 127.0.0.1:3768 QML Debugger: resolving host... QML Debugger: connecting to debug server... Have tried CONFIG -= declarative_debug with no effect. Screenshot:

    Read the article

  • Issue in accessing JSON object?

    - by Esh
    Am facing issue in accessing the JSON object : JSON Object am receiving is : {"71":"Heart XXX","76":"No Heart YYYY"} I tried to get the value of 71 and 72 separately and use it ... but am getting some compile time issue as : Syntax error on token ".71", delete this token Code: var map=$("#jsonText").val(); alert(map); var obj=jQuery.parseJSON(map); alert("JSON ::"+obj.71); If am printing obj , am able to view [Object Object] Can any one out there please help me to find the mistake i did ..I know the question above is asked in many threads in SO . Below are the few threads i found , but failed when i attempted to implement it .. jquery json parsing Also tried using the Jquery tutorial given in Jquery JSON Its working fine if the key is a String but getting the above error if its a number ...

    Read the article

  • Matching Word with regular expression

    - by lbar
    I have the following text file: ... "somewords MYWORD";123123123123 "someother MYWORDOTHER";456456456456 "somedifferent MYWORDDIFFERENT";789789789 ... i need to match the word MYWORD, MYWORDOTHER, MYWORDDIFFERENT and then substitute the space before this word with ";". Someone can figure out a regex? I have done something like that: +[^ ][^ ][^ ][^ ][^ ][^ ][^ ]"; but this works only with a specific word lenght. I need to modify to get any word of any leght. Any help? Thank you.

    Read the article

  • jquery element's place when toggeling

    - by Noam Zadok
    i'm building a page, which will have categories that will contain a list of pages to go with them. at first all the list are hidden, and than I click on a category and the list slides down. this is the code of the script: $(document).ready(function() { $('.menu-list').hide(); $('.menu-title').click(function() { if ($(this).next().is(':not(:visible)')) { $('.menu-list:visible').slideUp(); $(this).next().slideDown(); } }); The script works, but the problem is when I'm clicking on a category in a column that has more categories than the other. than the last category is moving to the left and I don't want it to. Here is the code in jsfiddle: http://jsfiddle.net/U7rKX/4/ Can you help me?

    Read the article

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