Daily Archives

Articles indexed Monday March 29 2010

Page 8/123 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Calling Model Functions from a Library

    - by Abs
    Hello all, I have turned a normal PHP class into a library so I can use it in Codeigniter as a library. I can load it and call the functions I need in that class. Here is that class to help with the question. However, there are quite a few points where I have to call functions in my class. These functions reside in the model that instantiated my class. How can I do this as currently normal calls don't work. Here is my code: class Controlpanel_model extends Model { var $category = ''; var $dataa = 'a'; function Controlpanel_model(){ parent::Model(); } function import_browser_bookmarks(){ $this->load->library('BookmarkParser'); /* *In this function call to the class I pass * what model functions exist that it should call * You can view how this done by clicking the link above and looking at line 383 */ $this->bookmarkparser->parseNetscape("./bookmarks.html", 0, 'myURL', 'myFolder'); return $this->dataa; } function myURL($data, $depth, $no) { $category = $this->category; $this->dataa .= 'Tag = '.$category.'<br />'.'URL = '.$data["url"].'<br />'.'Title = '.$data["descr"].'<br />'.'<br /><br />'; } function myFolder($data, $depth, $no) { $this->category = $data["name"]; } } Thanks all for any help.

    Read the article

  • Negative execution time

    - by FinalArt2005
    Hello, I wrote a little program that solves 49151 sudoku's within an hour for an assignment, but we had to time it. I thought I'd just let it run and then check the execution time, but it says -1536.087 s. I'm guessing it has to do with the timer being some signed dataype or something, but I have no idea what datatype is used for the timer in the console (code::blocks console, I'm not sure if this is actually a separate console, or just a runner that runs the terminal from the local operating system), so I can't check what the real time was. I'd rather not run this again with some coded timer within my program, since I'd like to be able to use my pc again now. Anybody have any idea what this time could be? It should be somewhere between 40 and 50 minutes, so between 2400 and 3000 seconds. Regards, Erik

    Read the article

  • Java: Why is this Subclass valid?

    - by incrediman
    Here, I have an abstract class: abstract class A<E extends A> { abstract void foo(E x); } Here's a class that extends A: class B extends A<B>{ void foo(B x){} } And here's another (E is B here on purpose): class C extends A<B>{ void foo(B x){} } Both of those classes are valid, and the reasoning for that makes sense to me. However what confuses me is how this could possibly be valid: class D extends A{ void foo(A x){} } Since when are generics optional like that? I thought the extending class (subclass) of A would be required to specify an E?

    Read the article

  • What is a really simple explanation of unit testing?

    - by ensnare
    I've never done any unit testing before, and would like to learn what it is and how it can be useful in my Python code. I've read through a few Python unit testing tutorials online but they're all so complicated and assume an extended programming background. I'm using Python with Pylons to create a simple web app. Any simple examples would be greatly appreciated. Thanks!

    Read the article

  • Why is the SelectTemplate Method run 2 times in debug mode?

    - by msfanboy
    Hello, debuging this class the SelectTemplate Method is run 2 times, but why? The first time the item is always null. public class PersonDataTemplateSelector : DataTemplateSelector { public override DataTemplate SelectTemplate(object item,DependencyObject container) { if (item is Person) { Person person = item as Person; Window window = Application.Current.MainWindow; if (System.ComponentModel.DesignerProperties.GetIsInDesignMode( window)) return null; if (person.Gender == "male") return window.FindResource("boysViewTemplate") as DataTemplate; else return window.FindResource("girlsViewTemplate") as DataTemplate; } return null; } }

    Read the article

  • passing an argument to a custom save() method

    - by Nick
    How do I pass an argument to my custom save method, preserving proper *args, **kwargs for passing to te super method? I was trying something like: form.save(my_value) and def save(self, my_value=None, *args, **kwargs): super(MyModel, self).save(*args, **kwargs) print my_value But this doesn't seem to work. What am I doing wrong?

    Read the article

  • BDD on Rails - Is the community more behind Shoulda or RSpec?

    - by Wayne M
    For a new application I want to start dabbling in BDD and I'm trying to decide between using RSpec or Thoughtbot's Shoulda. I like the macros that Shoulda uses, and the fact that it doesn't seem to reinvent the way Ruby/Rails does testing, but simply provides an add-on. On the other hand, the macros seem like a bit too much "magic" instead of being explicit about what you're testing (however I know from dabbling that it's annoying to write a dozen "should be invalid without xxx" two-liners on a model). To be honest I find writing specifications/tests for models to be trivially and almost boringly easy, but I find writing them for controllers to be insanely difficult because I'm never sure exactly what I should be testing or how to write it. I'm iffy on the subject of mocking and stubbing since I think they give you false assumptions (since you can just tell it to think it has whatever data you need or to pretend that Method X was called) and I know that RSpec makes heavy use of both of them. I like the documentation that RSPec produces but I'm creating an application for sale, not to give to a client so the pretty documentation isn't that useful. I like Cucumber but it seems like overkill (and yes I know it can be used with Shoulda). At this point is the Rails community in favor of RSpec or Shoulda?

    Read the article

  • help, php calendar links

    - by Ray
    Below is a partial table row that will create a line row of 3 columns. Two columns in each side is links, left is previous year and right is next year links. Center is links for january thru december. When you click a month links, the calendar will show that month you've clicked in the current year the calendar is on. For example, the calendar will open current month and year by default...March 2010. If you clicked previous year (2009), it will display current month (March) of last year (2009)...and then if you click Jun, the calendar will display June of whatever the year the calendar is currently on, which is June of 2009. my question is, what can i do to following code to do such thing. $Calendar.= "</tr><tr><td>"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=" . $LastYear["year"] ."\"> $LastY </a></td>\n"; $Calendar.= "<td colspan=\"5\">"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[0] ."\">Jan.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[1] ."\">Feb.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[2] ."\">Mar.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[3] ."\">Apr.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[4] ."\">May</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[5] ."\">Jun.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[6] ."\">Jul.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[7] ."\">Aug.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[8] ."\">Sep.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[9] ."\">Oct.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[10] ."\">Nov.</a> | "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[11] ."\">Dec.</a> </td>"; $Calendar.= "<td>"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=" . $NextYear["year"] ."\"> $NextY </a></td>\n"; Thanks in advance.

    Read the article

  • How do you prevent file confusion if version-control keywords are forbidden?

    - by Thomas L Holaday
    At least two brilliant programmers, Linus Torvalds and Guido von Rossum, disparage the practice of putting keywords into a file that expand to show the version number, last author, etc. I know how keyword differences clutter up diffs. One of the reasons I like SlickEdit's DiffZilla is because it can be set to skip leading comments. However, I have vivid memories of team-programming where we had four versions of a file (two different releases, a customer one-off, and the development version) all open for patching at the same time, and was quite helpful to verify with a glance that each time we navigated to an included header we got the proper one, and each time we pasted code the source and destination were what we expected. There is also the where-did-this-file-come-from problem that arises when a hasty developer copies a file from one place to another using the file system, rather than checking it out of the repository using the tool; or, more defensibly, when files under control in locations A, B, and C need to be marshalled (with cherry-picking) into a distribution location D. In places where VCS keywords are banned, how do you cope?

    Read the article

  • Can't change UITableViewCell size in Interface Builder

    - by Ondrej
    Does anyone have the same problem as I do? ... I've upgraded to the iPhone SDK 3.2 and I am unable to resize UITableViewCell object in my XIB file (usually I've been just resizing the view but now the cell has the same size and there is just a grey are around) ... btw, I've tried to reinstall twice including one deep reinstall.

    Read the article

  • Error when logging in with Machinist in Shoulda test

    - by user303747
    I am having some trouble getting the right usage of Machinist and Shoulda in my testing. Here is my test: context "on POST method rating" do p = Product.make u = nil setup do u = login_as post :vote, :rating => 3, :id => p end should "set rating for product to 3" do assert_equal p.get_user_vote(u), 3 end And here's my blueprints: Sham.login { Faker::Internet.user_name } Sham.name { Faker::Lorem.words} Sham.email { Faker::Internet.email} Sham.body { Faker::Lorem.paragraphs(2)} User.blueprint do login password "testpass" password_confirmation { password } email end Product.blueprint do name {Sham.name} user {User.make} end And my authentication test helper: def login_as(u = nil) u ||= User.make() @controller.stubs(:current_user).returns(u) u end The error I get is: /home/jason/moderndarwin/vendor/rails/activerecord/lib/active_record/validations.rb:1090:in `save_without_dirty!': Validation failed: Login has already been taken, Email has already been taken (ActiveRecord::RecordInvalid) from /home/jason/moderndarwin/vendor/rails/activerecord/lib/active_record/dirty.rb:87:in `save_without_transactions!' from /home/jason/moderndarwin/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!' from /home/jason/moderndarwin/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction' from /home/jason/moderndarwin/vendor/rails/activerecord/lib/active_record/transactions.rb:182:in `transaction' from /home/jason/moderndarwin/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!' from /home/jason/moderndarwin/vendor/rails/activerecord/lib/active_record/transactions.rb:208:in `rollback_active_record_state!' from /home/jason/moderndarwin/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!' from /usr/lib/ruby/gems/1.8/gems/machinist-1.0.6/lib/machinist/active_record.rb:55:in `make' from /home/jason/moderndarwin/test/blueprints.rb:37 from /usr/lib/ruby/gems/1.8/gems/machinist-1.0.6/lib/machinist.rb:77:in `generate_attribute_value' from /usr/lib/ruby/gems/1.8/gems/machinist-1.0.6/lib/machinist.rb:46:in `method_missing' from /home/jason/moderndarwin/test/blueprints.rb:37 from /usr/lib/ruby/gems/1.8/gems/machinist-1.0.6/lib/machinist.rb:20:in `instance_eval' from /usr/lib/ruby/gems/1.8/gems/machinist-1.0.6/lib/machinist.rb:20:in `run' from /usr/lib/ruby/gems/1.8/gems/machinist-1.0.6/lib/machinist/active_record.rb:53:in `make' from ./test/functional/products_controller_test.rb:25:in `__bind_1269805681_945912' from /home/jason/moderndarwin/vendor/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:293:in `call' from /home/jason/moderndarwin/vendor/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:293:in `merge_block' from /home/jason/moderndarwin/vendor/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:288:in `initialize' from /home/jason/moderndarwin/vendor/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:169:in `new' from /home/jason/moderndarwin/vendor/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:169:in `context' from ./test/functional/products_controller_test.rb:24 I can't figure out what it is I'm doing wrong... I have tested the login_as with my auth (Authlogic) in my user_controller testing. Any pointers in the right direction would be much appreciated!

    Read the article

  • Makefile: finding include/lib for libraries installed through macports

    - by Henk
    Libraries/include files installed by macports go in /opt/local/lib and /opt/local/include, neither of which are scanned by gcc/ld by default. As a result, a project I'm working on won't compile in that environment. Should this be fixed by manually adding -L/opt/local/lib to my Makefile's LDFLAGS (and -I... as well), or is there some configuration that should be done to fix this globally on the computer?

    Read the article

  • Private VCS hosts for school projects?

    - by Ibrahim
    I want to use version control for a partner project for school, but these days it seems like there are no private, free VCS hosts that I could use. I would prefer to use git if possible, but I wouldn't mind SVN. Alternatively, if there aren't any, shouldn't there be some way for me to use git without a central repository? I don't know enough about git, but I assume that is the point of a DVCS, no? I've considered scp'ing a clone of the repository to my school unix account and then giving my partner access to that, but it seems like it would be a bit of a pain. What are your thoughts/suggestions? Edit: I do know of one site called xp-dev, but I'm not sure how much I trust it. But I could use that and use git-svn on my side, since my partner has actually only ever used svn. But still wondering if there are any alternatives.

    Read the article

  • How to best implement Version Control for Web Development?

    - by Adam Taylor
    Version control systems are obviously important in development projects but there use in web development projects appears to be more complex, what with the requirement of having a web server to run all but the simplest of web applications. With that in mind, I have looked around and discovered a few different methods of using version control in web development projects: Provide each developer with a virtual machine which is a replication of the development server and have the developer run their working copy of the application in the virtual machine. Have each developer use a sub domain on the development server, e.g. john.project.com and checkout their working copy of the app to the directories the sub domain points to. Use the version control system to checkout code, make a change, commit the code and then check it on the development server (which points to the head of the repository). I can see a drawback of 1 being the added time required to create the virtual machines and ensure that the virtual machines are kept insync with the development server (also the need(?) to continuously change the developers host file to point at the virtual machine not the development server). I can see 2 possibly being a problem if absolute URLs are used within the site unless there is an easy way to update the configuration to use the new subdomains as well. 3 is the easiest to set up but is rather primitive and it will presumably become quite tedious for a developer to keep checking in the code after every time change. How have the users of stackoverflow used version control with web development projects and which method/workflow was most effective. Please also include extra methods I haven't thought of / read about.

    Read the article

  • Rails: find by day of week with timestamp

    - by Sleepycat
    I need to grab the records for same day of the week for the preceeding X days of the week. There must be a better way to do it than this: Transaction.find_by_sql "select * from transactions where EXTRACT(DOW from date) = 1 and organisation_id = 4 order by date desc limit 7" It gets me what I need but is Postgres specific and not very "Rails-y". Date is a timestamp. Anyone got suggestions?

    Read the article

  • postgres - remove whitespace from field?

    - by n00b0101
    I imported a bunch of data using pgloader, and am now seeing that there's a bunch of whitespace (both spaces and tabs) inside of the fields. Is there a way to quickly update the fields to remove it from the beginning, the end, and the middle? I know there's TRIM, but that won't work for me... As an added problem... I only want to remove double spaces and replace it with a single space, but there might be 5 or 6 spaces in a row, and I'd prefer not to have to rerun a replace query until they're all ok? I was looking at regex_replace, but, I'm not sure how to make certain that it removes it from the middle of a string as well...

    Read the article

  • How do I display children in succession, as3

    - by VideoDnd
    How do I display children in succession? By succession I mean 1,2,3,4, etc. Perhapse incrementing with a loop or using a timer is what I'm after. Add, remove, appear, or disappear children, could all work. I want a simple way to display 1 child every second until I reach 10. METHODS TRYED addChild and removeChild visible !visible for loop

    Read the article

  • Outputting a bar chart to an iPhone application?

    - by Moddy
    Right, I really want to output a Bar Graph to an Obj-C iPhone application - now I may be missing a vital SDK class or something; but right now my solution is to embed a WebView and inside that have a JQuery/Flot based graph - not totally ideal I know! Just wondering if anybody has any other creative solutions or whether a WebView/AJAX solution is the way to go? (For the record; my data source will be figures returned from an external source - i.e downloaded from the internet. So I was even toying with having a PHP Proxy/script do all the work on that, return the figures AND a graph to the application - but then I risk placing extra strain on the server!)

    Read the article

  • Chrome Browser: Cookie lost on refresh

    - by Nirmal
    I am experiencing a strange behaviour of my application in Chrome browser (No problem with other browsers). When I refresh a page, the cookie is being sent properly, but intermittently the browser doesn't seem to pass the cookie on some refreshes. This is what I am using for page headers: header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Thu, 25 Nov 1982 08:24:00 GMT"); // Date in the past Do you see any issue here that might affect the cookie handling? Thank you for any suggestion.

    Read the article

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