Search Results

Search found 32 results on 2 pages for 'ygam'.

Page 1/2 | 1 2  | Next Page >

  • Django Testing: Faking User Creation

    - by Ygam
    I want to better write this test: def test_profile_created(self): self.client.post(reverse('registration_register'), data={ 'username':'ygam', 'email':'[email protected]', 'password1':'ygam', 'password2':'ygam' }) """ Test if a profile is created on save """ user = User.objects.get(username='ygam') self.assertTrue(UserProfile.objects.filter(user=user).exists()) and I just came upon this code on django-registration tests that does not actually "create" the user: def test_registration_signal(self): def receiver(sender, **kwargs): self.failUnless('user' in kwargs) self.assertEqual(kwargs['user'].username, 'bob') self.failUnless('request' in kwargs) self.failUnless(isinstance(kwargs['request'], WSGIRequest)) received_signals.append(kwargs.get('signal')) received_signals = [] signals.user_registered.connect(receiver, sender=self.backend.__class__) self.backend.register(_mock_request(), username='bob', email='[email protected]', password1='secret') self.assertEqual(len(received_signals), 1) self.assertEqual(received_signals, [signals.user_registered]) However he used a custom function for this "_mock_request": class _MockRequestClient(Client): def request(self, **request): environ = { 'HTTP_COOKIE': self.cookies, 'PATH_INFO': '/', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_NAME': 'testserver', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1', 'wsgi.version': (1,0), 'wsgi.url_scheme': 'http', 'wsgi.errors': self.errors, 'wsgi.multiprocess':True, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.input': None, } environ.update(self.defaults) environ.update(request) request = WSGIRequest(environ) # We have to manually add a session since we'll be bypassing # the middleware chain. session_middleware = SessionMiddleware() session_middleware.process_request(request) return request def _mock_request(): return _MockRequestClient().request() However, it may be too long of a function for my needs. I want to be able to somehow "fake" the account creation. I have not much experience on mocks and stubs so any help would do. Thanks!

    Read the article

  • Ruby Script Runner for Ubuntu Gedit

    - by Ygam
    I have this Java script runner installed in my gedit external tools: #!/bin/sh cd $GEDIT_CURRENT_DOCUMENT_DIR if javac $GEDIT_CURRENT_DOCUMENT_NAME; then java ${GEDIT_CURRENT_DOCUMENT_NAME%\.java} else echo "Failed to compile" fi I tried modifying to it to something like this #!/bin/sh cd $GEDIT_CURRENT_DOCUMENT_DIR ruby ${GEDIT_CURRENT_DOCUMENT_NAME%\.rb} but it doesn't work. I may have missed something, I don't know what because I don't do bash scripting. Hehe

    Read the article

  • Does it really takes 5-10 years (or more) to be really good in programming?

    - by Ygam
    I don't get it. Why is there such a notion that it takes this long to be really proficient in a single language? I somehow think that this statement meant that it takes such a long time to master your language, and use it in a lot of context (web programming, desktop applications, mobile applications, etc.). Adding to that, sometimes you get stuck on a single language in your job and doing repetitive things and don't have much time to study other languages, thus for a certain amount of time, you don't really do much learning at all, and that adds to the amount of time. What do you think?

    Read the article

  • How Do I Fix a mysql "system error: 111" in a hosting service?

    - by Ygam
    Got this error Lost connection to MySQL server at 'reading initial communication packet', system error: 111 I am currently hosting a site under a subdomain here is a page accessing the database : http://payment.ygamtester.co.cc/search/index.html I have seen a lot of posts about this all pointing to one solution use ssh to alter a file in the mysql server obviously you can't do that with a remotely hosted site under a hosting company

    Read the article

  • Hooks...exactly what they are

    - by Ygam
    I have seen hooks in Kohana PHP framework, and they work as some sort of a callback function triggered by a certain event (Kohana's events that is, some sort of method overloading). I have seen hooks in Wordpress, and I don't know what they are or how to use them (just saw them yesterday). I'm looking for events in "non-frameworked" php, I cannot find ones. Do hooks work only in an "event-based" environment? What are they anyway (in general, not just in PHP)? What are they good for if not in an "event-based" environment.

    Read the article

  • showing progressbar progress with ajax request

    - by Ygam
    Hi guys! I want to show progress with jquery ui progress bar when an ajax request fires and when it finishes. The problem is I don't know how to set values for the progress bar depending on the progress of the ajax request. Please hlep. Here's a code to start with: function ajaxnews() { $('.newstabs a').click(function(e){ var section = $(this).attr('id'); var url = base + 'news/section/' + section; $.ajax({ url : url, dataTye : 'html', start : loadNews, success : fillNews }); }); } // start callback functions function loadNews() { $('#progressbar').fadeIn(); $('#progressbar').progressbar({ //how shoud I set the values here}); } function fillNews() { $('#progressbar').progressbar('option', 'value', ?? /* how do I find this?*/); $('#progressbar').fadeOut(); }

    Read the article

  • simple PHP integer conversion

    - by Ygam
    convert this: $300 to this : 300 can't do it with intval() or (int) typecasting if the non-numerical character is suffixed (300$), both works and returns 300 if it is prefixed it returns 0 the non-numerical character can be anything other than the "$"(i.e. "askldjflksdjflsd") Please help

    Read the article

  • A Simple PHP Array Manipulation

    - by Ygam
    Hi guys! how would you turn this array: array( 0 => Title1, 1 => Title2, 3 => Address1, 4 => Address2, ) to this array: array ( 0 => array( 'title' => 'Title1' 'address' =>'Address1' ), 1 => array( 'title' => 'Title2', 'address' => 'Address2' ) ); when you were initially given $_POST['title'] = array('Title1', 'Title2); $_POST['address'] = array('Address1', 'Address2'); which when merged would give you the first array I have given I was able to solve this via a high level Arr:Rotate function in Kohana framework, along with Arr::merge function but I can't quite understand the implementation. Please help

    Read the article

  • Does Extreme Programming Need Diagramming Tools?

    - by Ygam
    I have been experimenting with some concepts from XP, like the following: Pair Programming Test First Programming Incremental Deliveries Ruthless Refactoring So far so good until I had a major stump: How do I design my test cases when there aren't any code yet? From what basis do I have to design them? From simple assumptions? From the initial requirements? Or is this where UML diagrams and the "analysis phase" fits in? Just had to ask because in some XP books I've read, there was little to no discussion of any diagramming tool (there was one which suggested I come up with pseudocodes and some sort of a flowchart...but it did not help me in writing my tests)

    Read the article

  • 3-d game programming

    - by Ygam
    what programming language/languages do they use to produce games lik Bioware's Dragon Age Origins and some other 3-d games like Call of Duty? If I would like to do 3d-game programming, where do I start? Are there even simple tutorials for this? I would like to do 3-d game programming for PC games:)

    Read the article

  • data structure algorithms for database searching

    - by Ygam
    I was used to the traditional way of doing database searching with the following using wildcards for term searches using where clause for specific data like addresses and names but at other times, I found these common methods to produce code that is so bloated, especially when it comes to complex searches. Are there algorithms out there that you use for complex database searching? I tried to look for some but had a hard time doing so. I stumbled accross the binary search but I can't find a use for it :(

    Read the article

  • how to code: "floating image" google maps control

    - by Ygam
    look at this url there is the "floating image", the one with arrow that when clicked centers the map on a certain location. I have been desperately trying to find out the way to do that, and I have coded my google maps app with just that one thing missing. any ideas?

    Read the article

  • PHP Treat String as Variable

    - by Ygam
    Hi guys. I have a piece of code here that does not work despite me using a $$ on it to treat the string as a variable: <? foreach (KOHANA::config('list.amenities_forms') as $k => $v) : ?> <div class="form"> <fieldset> <legend><?php echo $v ?></legend> <input type="checkbox" name="<?=$k?>flag" id="<?=$k?>flag"/> <label class="inline"><?=$v?></label> <label>Description</label> <textarea cols="50" rows="5" name="<?=$k?>[]"><?= empty($$k[0]) ? '' : $$k[0]?></textarea> <label>Size</label> <input type="text" name="<?=$k?>[]" value="<?= empty($$k[1]) ? '' : $$k[1]?>"/> <label>Capacity</label> <input type="text" name="<?=$k?>[]" value="<?= empty($$k[2]) ? '' : $$k[2]?>"/> </fieldset> </div> <? endforeach?> the function Kohana::config returns this array: 'amenities_forms' => array( 'meeting_space' => 'Meeting Space', 'breakfast_room' => 'Breakfast Room', 'living_quarters' => 'Living Quarters', 'restaurant' => 'Restaurant', 'bar' => 'Bar' ) what could I be doing wrong?

    Read the article

  • jquery block UI malfunction on ajax loading event

    - by Ygam
    problem: trigger errored when block UI is called on this code (function($){ function preloader() { $('a#preloader').click(function(e){ e.preventDefault(); var url = base_url + 'runtest/preloader'; $('div#content').load(url, preloaderCallback); }); } function remotePreload() { $('a#remotepreload').click(function(e){ e.preventDefault(); var object = $(this); object.data('clicked', 'yes'); var url = base_url + 'runtest/remote_preloader'; $('div#content').load(url); }); } /* * callback functions */ function preloaderCallback() { $('div.imageholder img').hide(); $('div.imageholder img').each(function(){ var img = new Image(); var sursa = $(this).attr('src'); var parent = $(this).parent(); var preloaderSource = '<img src="' + base_url + 'media/images/preloader.gif' + '" alt="loader"/>'; parent.append(preloaderSource); $(img).load(function(){ parent.append($(this)); $(this).hide().fadeIn(500); $(this).siblings().remove(); }).attr('src', sursa); }); } function blocker() { $('#content').block(); } function handlePageLoad() { $('a#remotepreload').ajaxStart(function(e){ var elem = $(e.target); if (elem.data('clicked') == 'yes') { // error when blocker() function is called here alert('Started'); } }); $('a#remotepreload').ajaxComplete(function(e){ var elem = $(e.target); if (elem.data('clicked') == 'yes') { elem.removeData('clicked'); alert('Ended'); } }); } // call onready functions $(function(){ preloader(); remotePreload();handlePageLoad(); }); })(jQuery); // here's the error from firefox's debugger uncaught exception: [Exception... "Could not convert JavaScript argument arg 0" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://localhost/testsuite/media/js/jquery.min.js :: anonymous :: line 115" data: no] here's the html markup <div id="wrap"> <div id="header"> <?= $header ?> </div> <div id="content"> <?= $content ?> </div> <div id="sidebar"> <?= $sidebar ?> </div> <div id="footer"> <?= $footer ?> </div> </div> EDIT I was using Jquery 1.4.1 when this happened. Switched back to 1.3 and everything went back to normal.

    Read the article

  • Have I taken a wrong path in programming by being excessively worried about code elegance and style?

    - by Ygam
    I am in a major stump right now. I am a BSIT graduate, but I only started actual programming less than a year ago. I observed that I have the following attitude in programming: I tend to be more of a purist, scorning unelegant approaches to solving problems using code I tend to look at anything in a large scale, planning everything before I start coding, either in simple flowcharts or complex UML charts I have a really strong impulse on refactoring my code, even if I miss deadlines or prolong development times I am obsessed with good directory structures, file naming conventions, class, method, and variable naming conventions I tend to always want to study something new, even, as I said, at the cost of missing deadlines I tend to see software development as something to engineer, to architect; that is, seeing how things relate to each other and how blocks of code can interact (I am a huge fan of loose coupling) i.e the OOP thinking I tend to combine OOP and procedural coding whenever I see fit I want my code to execute fast (thus the elegant approaches and refactoring) This bothers me because I see my colleagues doing much better the other way around (aside from the fact that they started programming since our first year in college). By the other way around I mean, they fire up coding, gets the job done much faster because they don't have to really look at how clean their codes are or how elegant their algorithms are, they don't bother with OOP however big their projects are, they mostly use web APIs, piece them together and voila! Working code! CLients are happy, they get paid fast, at the expense of a really unmaintainable or hard-to-read code that lacks structure and conventions, or slow executions of certain actions (which the common reasoning against would be that internet connections are much faster these days, hardware is more powerful). The excuse I often receive is clients don't care about how you write the code, but they do care about how long you deliver it. If it works then all is good. Now, did my "purist" approach to programming may have been the wrong way to start programming? Should I just dump these purist concepts and just code the hell up because I have seen it: clients don't really care how beautifully coded it is?

    Read the article

  • filter search results with another form

    - by Ygam
    so here's the problem I have one form, it outputs search results after submit, with this URL http://localhost/thi/search/results?keyword=barma&search=1&minprice=nomin&maxprice=nomax&minroom=nomin&maxroom=nomax&minyear=nomin&maxyear=2010 Now I have another form, which is supposed to filter the results from the previous form by getting the current url of the search results and appending to it the GET variables submitted by this form. I tried filtering before, but that is with anchor links. How am I supposed to do it with forms? Anny approaches?

    Read the article

  • Is marshaling/ serialization in PHP as simple as serialize($var) ?

    - by Ygam
    here's a definition of marshaling from Wikipedia: In computer science, marshalling (similar to serialization) is the process of transforming the memory representation of an object to a data format suitable for storage or transmission. It is typically used when data must be moved between different parts of a computer program or from one program to another. I have always done data serialization in php via its serialize function, usually on objects or arrays. But how is wikipedia's definition of marshaling/serialization takes place in this serizalize() function?

    Read the article

  • what's an option strict and explicit?

    - by Ygam
    I saw this post: "Typos… Just use option strict and explicit please.. during one software development project, which I was on as a consultant, they were getting ridiculous amounts of errors everywhere… turned out the developer couldn’t spell and would declare variables with incorrect spelling.. no big deal, until you use the correct spelling when you’re assigning a value to it… and you had option explicit off. Ouch to them…" what is an option strict and explicit anyway? I have googled it up but can't get the idea (because mostly it's Visual Basic, I'm doing PHP)

    Read the article

  • making use of c++ to speed up php

    - by Ygam
    I saw this post on Sitepoint quoting a statement by Rasmus Lerdorf which goes (according to Sitepoint) as follows: "How can you make PHP fast? Well, you can’t" was his quick answer. PHP is simply not fast enough to scale to Yahoo levels. PHP was never meant for those sorts of tasks. "Any script based language is simply not fast enough". To get the speed that is necessary for truly massive web systems you have to use compiled C++ extensions to get true, scaleable architecture. That is what Yahoo does and so do many other PHP heavyweights. Intrigued by the statement (not to mention the fact that up to now, all I was doing in PHP was small database-based apps), I was wondering how I could "use compiled C++ extensions" with PHP. Any ideas or resources?

    Read the article

  • Looking For A Good HTML Templater for PHP

    - by Ygam
    That's an HTML templater, not a php templater, not java or whatever. I am looking for something like HAML for PHP. I tried the 2 projects for PHP, PHAML and PHPHaml both of which are suffering from serious bugs. Do you know of any good html templater out there, preferably for PHP? EDIT I''m looking for something that can turn this <h1>Heading</h1> <p>entry</p> <blockquote>quote</blockquote> to something like this h1 : heading p : entry blockquote : quote something like what phphaml does

    Read the article

  • How do I display a dynamically resized image in Kohana without saving it?

    - by Ygam
    I have an image path string stored in a database It goes like: img/uploads/imagename.jpg I have a controller: $this->image = new Image($wines->image) //this is assuming that I have a wines table with the image property $this->image->resize(60, 250, Image::AUTO) echo $this->image->render(); //the problem is nothing is rendered //Is there a better way of doing this? the image path that I am passing at the Image object //instantiation is the result of a query

    Read the article

  • How can I compare my PHPASS-hashed stored password to my incoming POST data?

    - by Ygam
    Here's a better example, just a simple checking..stored value in database has password: fafa (hashed with phpass in registration) and username: fafa; i am using the phpass password hashing framework public function demoHash($data) //$data is the post data named password { $hash =new PasswordHash(8, false); $query = ORM::factory('user'); $result = $query ->select('username, password') ->where('username', 'fafa') ->find(); $hashed = $hash->HashPassword($data); $check = $hash->CheckPassword($hashed, $result->password); echo $result->username . "<br/>"; echo $result->password . "<br/>"; return $check; } check is returning false

    Read the article

  • Determining when or when not to escape output

    - by Ygam
    I have a page, where I have approximately 90 items I need to output. Most of them are object properties (I am using ORM so these objects map to my database tables). But the question is, do I have to escape each of those 90 outputs by applying functions to each (in my case, the htmlspecialchars)? Wouldn't that add a bit of an overhead (calling a single function 90 times)?

    Read the article

  • Is there server-side code which is not cross browser compatible?

    - by Ygam
    Was there a case in any server-side language where a code did not work in a browser while it did work in the rest? I am asking this because I can't imagine such a scenario because server-side code runs in the server, not in the browser but I have seen discussions where, as said, there were "server-side browser compatibility issues". I can't seem to recall where I have read it. Thanks in advance :)

    Read the article

1 2  | Next Page >