Daily Archives

Articles indexed Monday June 9 2014

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

  • Javascript Module pattern with DOM ready

    - by dego89
    I am writing a JS Module pattern to test out code and help me understand the pattern, using a JS Fiddle. What I can't figure out is why my "private methods" on line 25 and 26, when referenced via DOM ready, have a value of undefined. JSFiddle Code Sample: var obj = { key: "value" }; var Module = (function () { var innerVar = "5"; console.log("obj var in Module:"); console.log(obj); function privateFunction() { console.log("privateFunction() called."); innerFunction(); function innerFunction() { console.log("inner function of (private function) called."); } } function _numTwo() { console.log("_numTwo() function called."); } return { test: privateFunction, numTwo: _numTwo } }(obj)); $(document).ready(function () { console.log("$ Dom Ready"); console.log("Module in Dom Ready: "); console.log(Module.test()); });

    Read the article

  • Indefinite loops where the first time is different

    - by George T
    This isn't a serious problem or anything someone has asked me to do, just a seemingly simple thing that I came up with as a mental exercise but has stumped me and which I feel that I should know the answer to already. There may be a duplicate but I didn't manage to find one. Suppose that someone asked you to write a piece of code that asks the user to enter a number and, every time the number they entered is not zero, says "Error" and asks again. When they enter zero it stops. In other words, the code keeps asking for a number and repeats until zero is entered. In each iteration except the first one it also prints "Error". The simplest way I can think of to do that would be something like the folloing pseudocode: int number = 0; do { if(number != 0) { print("Error"); } print("Enter number"); number = getInput(); }while(number != 0); While that does what it's supposed to, I personally don't like that there's repeating code (you test number != 0 twice) -something that should generally be avoided. One way to avoid this would be something like this: int number = 0; while(true) { print("Enter number"); number = getInput(); if(number == 0) { break; } else { print("Error"); } } But what I don't like in this one is "while(true)", another thing to avoid. The only other way I can think of includes one more thing to avoid: labels and gotos: int number = 0; goto question; error: print("Error"); question: print("Enter number"); number = getInput(); if(number != 0) { goto error; } Another solution would be to have an extra variable to test whether you should say "Error" or not but this is wasted memory. Is there a way to do this without doing something that's generally thought of as a bad practice (repeating code, a theoretically endless loop or the use of goto)? I understand that something like this would never be complex enough that the first way would be a problem (you'd generally call a function to validate input) but I'm curious to know if there's a way I haven't thought of.

    Read the article

  • How to Structure a Trinary state in DB and Application

    - by ABMagil
    How should I structure, in the DB especially, but also in the application, a trinary state? For instance, I have user feedback records which need to be reviewed before they are presented to the general public. This means a feedback reviewer must see the unreviewed feedback, then approve or reject them. I can think of a couple ways to represent this: Two boolean flags: Seen/Unseen and Approved/Rejected. This is the simplest and probably the smallest database solution (presumably boolean fields are simple bits). The downside is that there are really only three states I care about (unseen/approved/rejected) and this creates four states, including one I don't care about (a record which is seen but not approved or rejected is essentially unseen). String column in the DB with constants/enum in application. Using Rating::APPROVED_STATE within the application and letting it equal whatever it wants in the DB. This is a larger column in the db and I'm concerned about doing string comparisons whenever I need these records. Perhaps mitigatable with an index? Single boolean column, but allow nulls. A true is approved, a false is rejected. A null is unseen. Not sure the pros/cons of this solution. What are the rules I should use to guide my choice? I'm already thinking in terms of DB size and the cost of finding records based on state, as well as the readability of code the ends up using this structure.

    Read the article

  • What are the parameters that let businesses choose .NET or Java over other languages/frameworks? [on hold]

    - by Othman
    Some of the biggest enterprise applications such as HR software, Sales and ERP, are written in .NET or Java. Also, Governments online solutions such as paying parking fines, and universities courses registration systems are all in .NET or Java. On the other hand, Facebook, Google and Wikipedia, are not using .NET or Java so much (Google uses at least both Java and Python). Twitter also was using Ruby for a long time, as well as Python. These websites work on much more data and at larger scales in terms of users and performance than any enterprise applications, yet still these companies have chosen a different path. What are the parameters driving such decisions? Note This question is not about why do you prefer x over y! or why those people are using this. The question is primarily asking about the parameters that makes Java Or .NET becomes better suite in enterprise applications based on Performance, Reliability, Scalability etc.

    Read the article

  • Can decoupling hurt maintainability in certain situations?

    - by Ceiling Gecko
    Can the fact that the business logic is mapped to interfaces instead of implementations actually hinder the maintenance of the application in certain situations? A naive example with the Java's Hibernate framework would be, that for example (provided I don't have the whole code-base in my head, the project structure is a mess and classes are named with arbitrary names) if I wish to see what's going on in a certain DAO, to see if it actually is doing what it's supposed to do, then instead of traversing backwards up the tree from the point where the data service is invoked (where the tree will end in an interface with no implementation details whatsoever apart from the signature) I have to for example go and look for a configuration XML file to see which class is mapped to said interface as the implementation before being able to access the actual implementation details. Are there any situations where having loose coupling can actually hurt maintainability?

    Read the article

  • Dynamic Query Generation : suggestion for better approaches

    - by Gaurav Parmar
    I am currently designing a functionality in my Web Application where the verified user of the application can execute queries which he wishes to from the predefined set of queries with where clause varying as per user's choice. For example,Table ABC contains the following Template query called SecretReport "Select def as FOO, ghi as BAR from MNO where " SecretReport can have parameters XYZ, ILP. Again XYZ can have values as 1,2 and ILP can have 3,4 so if the user chooses ILP=3, he will get the result of the following query on his screen "Select def as FOO, ghi as BAR from MNO where ILP=3" Again the user is allowed permutations of XYZ / ILP My initial thought is that User will be shown a list of Report names and each report will have parameters and corresponding values. But this approach although technically simple does not appear intuitive. I would like to extend this functionality to a more generic level. Such that the user can choose a table and query based on his requirements. Of course we do not want the end user to take complete control of DB. But only tables and fields that are relevant to him. At present we are defining what is relevant in the code. But I want the Admin to take over this functionality such that he can decide what is relevant and expose the same to the user. On user's side it should be intuitive what is available to him and what queries he can form. Please share your thoughts what is the most user friendly way to provide this feature to the end user.

    Read the article

  • Fiscal quarter vs calendar quarter

    - by Geotarget
    I'm building a Date/Time class with a "configurable quarter" system as follows. User specifies which month the quarter starts at (config) Set of functions to deal with quarters (next quarter, prev quarter, etc) All quarter functions respect the config Now this class is primarily to be used for fiscal quarter calculations. So assuming I have this class with a configurable "quarter" system, would I need another parallel set of functions for calendar quarters too? What are the applications for calendar quarters anyways? By calendar quarters I mean where Q1 is Jan-Mar, and Q4 is Oct-Dec. By fiscal quarters I mean whatever standard your Country uses (in India Q1 starts in April)

    Read the article

  • Use a template to get alternate behaviour?

    - by Serge
    Is this a bad practice? const int sId(int const id); // true/false it doesn't matter template<bool i> const int sId(int const id) { return this->id = id; } const int MCard::sId(int const id){ MCard card = *this; this->id = id; this->onChange.fire(EventArgs<MCard&, MCard&>(*this, card)); return this->id; } myCard.sId(9); myCard.sId<true>(8); As you can see, my goal is to be able to have an alternative behaviour for sId. I know I could use a second parameter to the function and use a if, but this feels more fun (imo) and might prevent branch prediction (I'm no expert in that field). So, is it a valid practice, and/or is there a better approach?

    Read the article

  • Relationship between TDD and Software Architecture/Design

    - by Christopher Francisco
    I'm new to TDD and have been reading the theory since applying it is more complicated than it sounds when you're learning by yourself. As far as I know, the objective is to write test cases for each requirement and run the test so it fails (to prevent a false positive). Afterward, you should write the minimum amount of code that can pass the test and move to the next one. That being said, is it true that you get a fast development, but what about the code itself? this theory makes me think you are not considering things like abstraction, delegation of responsibilities, design patterns, architecture and others since you're just writing "the minimum amount of code that can pass the test". I know I'm probably wrong because if this were true, we'd have a lot of crappy developers with poor software architecture and documentation so I'm asking for a guide here, what's the relationship between TDD and Software Architecture/Design?

    Read the article

  • Why DbContext object shouldn't be referred in Service Layer?

    - by nazmoonnoor
    I've been looking for some implementations of Service Layer and Controller interaction in blogs and in some open source projects. All of them seem to refer DbContext object in repository classes but avoided to use in service classes. Service classes essentially using a IQueryable<T> references of DbSet<T>. I want to know why this practice is good and why DbContext shouldn't have a reference in Service Layer.

    Read the article

  • Inspecting the model in a Rails application

    - by Matt Sherman
    I am learning some Ruby on Rails, and am a newbie. Most of my background is in ASP.net MVC on the back end. As I play with a basic scaffold project, I wonder about this case: you jump into an established Rails project and want to get to know the model. Based on what I have seen so far (again, simple scaffold), the properties for a given class are not immediately revealed. I don't see property accessors on the model classes. I do understand that this is because of the dynamic nature of Ruby and such things are not necessary or even perhaps desirable. Convention over code, I get that. (Am familiar with dynamic concepts, mostly via JS.) But if I am somewhere off in a view, and want to quickly know whether the (eg) Person object has a MiddleName property, how would I find that out? I don't have to go into the migrations, do I?

    Read the article

  • Disable discrete AMD GPU

    - by Smajl
    My notebook has two graphic cards and it suffers from severe overheating after installing Ubuntu (no problem with Windows 7 on the same machine). I figured out that the problem may be in the graphic card and I would like to disable the discrete one. I followed some tutorials on this topic (for example http://planetoss.com/articles/how-to-disable-the-discrete-amd-graphics-card-in-linux/). But the problem is, that after executing the commands, nothing really happens and both GPU are still running. Here is what I have done: smajl@smajl-mini:~$ sudo chown smajl /sys/kernel/debug/vgaswitcheroo/switchsmajl@smajl-mini:~$ echo IGD > /sys/kernel/debug/vgaswitcheroo/switch smajl@smajl-mini:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch 0:IGD:+:DynPwr:0000:01:05.0 1:DIS-Audio: :Pwr:0000:02:00.1 2:DIS: :DynPwr:0000:02:00.0 smajl@smajl-mini:~$ echo OFF > /sys/kernel/debug/vgaswitcheroo/switch smajl@smajl-mini:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch 0:IGD:+:DynPwr:0000:01:05.0 1:DIS-Audio: :Pwr:0000:02:00.1 2:DIS: :DynPwr:0000:02:00.0 What am I missing here? Also, more on the overheating topic: 1) Installed TLP 2) updated system 3) set power setting mode to "power save" ...and nothing helps Tried same thing with Linux Mint without success. Is there anything else to try if I manage to disable the second GPU and the problem preserves? Otherwise I would have to get back to win in order not to melt my laptop.. :-/

    Read the article

  • Finish long directory name with tab problem

    - by user1880405
    I have simple problem that I have to long directories which I want to cd into, but I would like to know easy way. mosquito@mosquito-K56CB:~/Downloads$ ls | grep Guns Guns n' Roses - Appetite for Destruction (Japanese Edition) 1987 Guns n' Roses - Use Your Illusion I 1991 Of course I can just copy the name and put it like this: cd "Guns n' Roses - Appetite for Destruction (Japanese Edition) 1987" But why when I write cd Guns then tab, it finishes line into: cd Guns\ n\'\ Roses\ -\ then by my understanding I should just start writing App.. with tab and it should finish whole name, but it does not. And hitting tab twice does not show me anything either. What I am missing here?

    Read the article

  • Can not use keyboard on unity

    - by ikhsan
    Dear Ubuntu Community, currently I am using Ubuntu 14.04, and few hours ago, an update notifier prompted to install an update. After update finished, it ask for system restart, I think there is some kernel update etc. The problem start after restart, I can type password when login, but after entering unity desktop, my keyboard become suddenly unusable, system doesn't respond to any key press, after few minutes, it lock the screen automatically, but still I can't type password to unlock the screen. I tried to logout (mouse is working properly), and login again, try starting onscreen keyboard, but still have no luck, system still doesn't respond to the key press. I tried to login in console, and keyboard working well, tried to install xfce, and keyboard also working properly, keyboard also working properly when login to unity as guest, it only not working when I login using my account. I also try to reset unity config via unity-tweak-tool --reset-unity , but still no luck any suggestion to resolve this?

    Read the article

  • Ubuntu not mounting brand-new external drive

    - by user245115
    I bought a brand new 3TB external drive for my birthday coming up, It's a WD My Book, it came as NTFS, and I'm trying to make it mount using a simple script on boot. (Not /etc/fstab, I ruined my comp. using that by accident and had to re-install, I'm instead having a script run in /etc/init.d) The thing is, it's under /dev/sdf and I want it to mount in /exhd, the script seems to run but it doesn't mount it, any help here?

    Read the article

  • Built in webcam installation

    - by user291941
    I followed instructions for installing built in webcam but everytime after entering cmd and pwd a statement execute that "unable to locate package cheese"..plz help me out i need to submit my project within a week and still stuck here... This is what it is showing every time... wtc@ubuntu:~$ sudo apt-get install cheese [sudo] password for wtc: Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package cheese wtc@ubuntu:~$

    Read the article

  • Ubuntu stuck, goes black and comes to login screen

    - by Iury Simões
    I'm using normally the ubuntu, version: ~$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=13.10 DISTRIB_CODENAME=saucy DISTRIB_DESCRIPTION="Ubuntu 13.10" And so, for no reason, the screen goes black and come back to login screen. This not happen on login screen, like login screen infinite loop problem. I get the login and use it normally then suddenly the screen goes black. I was using Ubuntu 14 and for this problem I formatted and installed Ubuntu 13, but the problem remains.

    Read the article

  • Skype webcam won't work

    - by user291917
    I am a very new Ubuntu 12.04 user and would like to install Skype. It used to be available from Ubuntu Software Centre but it is no longer available from there. So I downloaded it and installed same. The Ubuntu SC Installed section does not list it But Ubuntu Tweak does. Skype works for sound only but no webcam = Logitec QuickCam Express 046d:0928. Could you please help to make it work. According what I read it should work out of the box BUT it does not. Your advise/help by email to [email protected] would be most appreciated. Kindest regards Bela Yorke

    Read the article

  • Scripting with variables from file

    - by Nooster
    I have several videos on my PC that I would like to shorten. For instance I have a 30 sec video where I want to have the section from sec 15 to 20 (a 5sec video). To cut this, I use avconv. avconv -i input.mp4 -ss 15 -acodec copy -vcodec copy -t 5 output.mp4 This command works pretty well. I have many videos I want to cut the same way. This is why I created a textfile containing the information: input-name, start of cut, length of cut, output-name. Those are written into in.txt that looks like this: input.mp4 15 5 output.mp4 input1.mp4 32 10 output1.mp4 input2.mp4 10 7 output2.mp4 ... My question is: How do I have to modify the avconv-command to cut my videos automatically? What I tried was this, but it didn't work at all: avconv -i $1 -ss $2 -acodec copy -vcodec copy -t $3 $4 < in.txt Any idea?

    Read the article

  • Problem with Software Center

    - by user215391
    I am not able use my Ubuntu Software Center and Synaptic package manager. I can't understand what's the problem. When I use the command: sudo apt-get update it shows this error: E: Malformed line 1 in source list /etc/apt/sources.list.d/canonical_partner.list (dist parse) E: The list of sources could not be read. I have seen How do I remove a malformed line from my sources.list?, but it didn't help.

    Read the article

  • Apache doesn't load .php files

    - by Haddex
    First, sorry for my English and asking something that it's quite answered all over the web. I've read a lot of post about this problem but I still can't find the solution. I'm a web developer who recently moved to Ubuntu from Windows 7. I had a website done (it's online and working) and I set up LAMP to keep working with it. I made a test.php file with: <?php phpinfo(); ?> and put it on /var/www/html directory, it shows all the information about the php and I was really happy: "Ok, it's all done, tomorrow I will work hard" But I placed my whole web into /var/www/html , not in a folder, the index.php is in /var/www/html but guess what: doesn't load any of my .php files, the browser just keep thinking. What I did: I rebooted Apache: /etc/init.d/apache2 restart I tried again with the test.php file and it works fine I put in /var/www/html a .html file and works fine. I looked for /etc/apache2/sites-enable/000-default.conf and it says: DocumentRoot /var/www/html I looked for /etc/apache2/mods-enabled/dir.conf and it says: DirectoryIndex index.html index.cgi index.pl index.php ... Edit* I think it's something related to phpmyadmin, like if I'm not able to connect with the database. But I got nothing on the screen when trying to load the page so...I'm not sure. I can access to the url localhost/phpmyadmin and I edited the connection.php file like this: <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_rakstadconnection = "localhost"; $database_rakstadconnection = "rakstadclandb"; $username_rakstadconnection = "root"; $password_rakstadconnection = "admin"; $rakstadconnection = mysql_connect($hostname_rakstadconnection, $username_rakstadconnection, $password_rakstadconnection) or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("SET NAMES 'utf8'"); ?> The name of the database is correct, like the user and password. http://i89.photobucket.com/albums/k220/Haddex/Capturadepantallade2014-06-09112609_zpsc45ddb72.png http://i89.photobucket.com/albums/k220/Haddex/Capturadepantallade2014-06-09112120_zps0b9e15f7.png *Edit2: could this be because it's a website that I brought to Linux from Windows? I used Dreamweaver. Edit3: I changed the # to /*/, nothing. The error.log file says: [Mon Jun 09 17:08:13.627881 2014] [:error] [pid 1517] [client 127.0.0.1:46663] PHP Warning: require_once(/var/www/html/Connections/rakstadconnection.php): failed to open stream: Permission denied in /var/www/html/index.php on line 1 [Mon Jun 09 17:08:13.627933 2014] [:error] [pid 1517] [client 127.0.0.1:46663] PHP Fatal error: require_once(): Failed opening required 'Connections/rakstadconnection.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/index.php on line 1 I'm reading error log but...should I add a linux path into a my index.php file? Don't think so. Thanks.

    Read the article

  • APT wedged by kernel version mismatch

    - by Leopd
    Apt is seemingly unable to do anything useful for me, repeatedly giving messages of this form: dpkg: dependency problems prevent configuration of linux-server: linux-server depends on linux-image-server (= 3.2.0.37.44); however: Version of linux-image-server on system is 3.2.0.37.45. linux-server depends on linux-headers-server (= 3.2.0.37.44); however: Version of linux-headers-server on system is 3.2.0.37.45. dpkg: error processing linux-server (--configure): dependency problems - leaving unconfigured This is basically the same problem as I cannot install any package (linux-image-server, linux-server dependencies errors) which got closed Duplicate to an answer that is totally useless for this situation. None of the advice in that very generic answer about dependencies helps. Explicitly: sudo apt-get clean sudo apt-get autoclean sudo apt-get update all have no not effect. While sudo apt-get -f install sudo dpkg --configure -a sudo apt-get -u dist-upgrade sudo apt-get -o Debug::pkgProblemResolver=yes dist-upgrade all give some form of the error message above.

    Read the article

  • Wireless suddenly dropping with a Ralink RT2870

    - by cwwk
    I have a Linksys WUSB600N v1 Dual-Band Wireless-N Network Adapter Ralink RT2870 USB dongle that worked flawlessly in 11.10. Since upgrading, I can't keep a connection for more than five minutes. The wild world of Google was unable to provide a solution, and I would rather not downgrade although that remains a possibility. Results of syslog: slack@slack:~$ tail /var/log/syslog Apr 26 20:26:10 slack AptDaemon: INFO: Initializing daemon Apr 26 20:26:10 slack AptDaemon.PackageKit: INFO: Initializing PackageKit compat layer Apr 26 20:26:10 slack dbus[972]: [system] Successfully activated service 'org.freedesktop.PackageKit' Apr 26 20:26:10 slack AptDaemon.PackageKit: INFO: Initializing PackageKit transaction Apr 26 20:26:10 slack AptDaemon.Worker: INFO: Simulating trans: /org/debian/apt/transaction/aaed4e38eb3c41ad86d2bab6ca03ee7c Apr 26 20:26:10 slack AptDaemon.Worker: INFO: Processing transaction /org/debian/apt/transaction/aaed4e38eb3c41ad86d2bab6ca03ee7c Apr 26 20:26:12 slack dbus[972]: [system] Activating service name='com.ubuntu.SystemService' (using servicehelper) Apr 26 20:26:12 slack dbus[972]: [system] Successfully activated service 'com.ubuntu.SystemService' Apr 26 20:30:26 slack AptDaemon.PackageKit: INFO: Get updates() Apr 26 20:30:27 slack AptDaemon.Worker: INFO: Finished transaction /org/debian/apt/transaction/aaed4e38eb3c41ad86d2bab6ca03ee7c Any suggestions?

    Read the article

  • How can I advetise efficiatly on my sites? [on hold]

    - by Smillification
    Are there any ad networks that give publishers/websites the ability to display adverts that are chosen by the publisher immediately on page load. Lets say the page loads, and a script inserts certain key words that the ad network uses to search their inventory of adverts and assigns the nearest one with matching tags to the publisher advert area? I know Google's adsense and many other similar services index/reads the pages content and then assign certain advert depending on the content with little or no control by the publisher... Any help is appreciated.

    Read the article

  • Domain in PENDINGDELETE, question about drop

    - by kcdwayne
    A domain I want is in the pendingDelete stage according to WHOIS. I have been monitoring it since redemptionPeriod, and it entered into pendingDelete 5 days ago today. After checking a few services (SnapNames, etc), they report it is scheduled to drop on the 11th (7 days, by my calculations). I'm not quite sure what to believe. The domain isn't highly valuable. It is to me and one other company. I can see no backorders placed on the big name sites, so I'm thinking of trying to get it without a backorder service. Any insight as to when it will actually drop? I've read 11AM-2PM PST, but I'm unsure. Thanks.

    Read the article

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