Open Side Menu Go to the Top

06-30-2014 , 12:39 AM
Quote:
Originally Posted by daveT
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_get_resp_body_errors', '_request_id', '_reset', '_resp_body_errors', '_resp_body_warnings', '_resp_codes', '_response_content', '_response_dict', '_response_dom', '_response_error', '_response_obj', '_response_soup', '_time', 'build_request', 'build_request_data', 'build_request_headers', 'config', 'debug', 'debug_callback', 'do', 'error', 'error_check', 'execute', 'execute_request', 'getNodeText', 'method', 'parallel', 'process_response', 'proxies', 'proxy_host', 'proxy_port', 'request', 'response', 'response_code', 'response_codes', 'response_content', 'response_dict', 'response_dom', 'response_json', 'response_obj', 'response_soup', 'response_status', 'session', 'timeout', 'v', 'verb', 'warnings']
There it is.

FWIW, in Python you almost never want to muck with __dict__ directly. You also generally don't want to call methods starting with `_` unless you're very sure of what you're doing; that naming convention usually means "treat this as a private method if Python had those"
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
06-30-2014 , 02:35 AM
I couldn't remember the rule about which was which and exactly how to use __n__, but now that I think of it, that is operator over-loading in classes. I could have looked at some of my old code, but that makes me feel sad, and I could have done some searching, but maybe I'd rather come here and complain that I lost my Python-Fu.

In case you missed it, there is a response_json() available. I'm sure xhad still has nightmares from Python / JSON.

I'm pulling the stuff down as JSON and feeding directly into PostgreSQL. Much less headache! I have no idea why people like JSON, but to each their own.

Also, learned something really cool today. In Postgres, if you don't know where the single-quotes are and you want to escape, just do:

Code:
INSERT INTO my_table 
values ($${My buti'fool JSON go's 'he're'}$$)
Works like magic.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-30-2014 , 05:46 AM
Quote:
Originally Posted by daveT
I couldn't remember the rule about which was which and exactly how to use __n__, but now that I think of it, that is operator over-loading in classes.
`__dunder__` means "this method is used in some context other than being directly called." Operators you can overload are one specific case of that. `__dict__` has to do with how accessing attributes is implemented, e.g. `foo.x` is by default equivalent to `foo.__dict__['x']`.

Quote:
I'm sure xhad still has nightmares from Python / JSON.
I actually found Python's JSON library pretty easy to work with?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-30-2014 , 05:07 PM
incredible but true:

the BSD sed utility that comes with your Mac OSX does not support the case-insensitive matching flag.

http://stackoverflow.com/questions/4...place-with-sed

wow.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
06-30-2014 , 06:11 PM
It's seriously aggravating how long it takes for apple to approve my $100 iOS developer account.

I want to put something on my phone, stop being pricks.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-01-2014 , 12:15 AM
Ooops, was supposed to write a 5-7 page paper on OpenCl and ended up writing 12... hope this prof doesn't dock for being an overachiever....
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-01-2014 , 10:02 AM
Going over the page limit is generally seen as not being able to organise your thoughts in a concise manner and focusing the topic in an appropriate way. Good rule of thumb is if you don't have ~30 sources (balanced mix, not just the typical ABC textbooks but use 6 of them where one would have been enough to inflate sources) for your 12 pages you're probably "rambling" and can cut down on text to get there (say the same but with less words). If you have enough sources then you need to focus the topic more by leaving out some of the good parts (the lesser evil), you'll want in the neighbourhood of 20 sources for 7 pages.
Just general advice, every paper is different.

[assuming university paper]

Last edited by clowntable; 07-01-2014 at 10:09 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-01-2014 , 10:24 AM
This prof was terrible and I think he just pulled the 5-7 pages out of his ass anyways. He wanted diagrams and screenshots as well as a laundry list of questions addressed within the paper. To top it off he couldn't even be bothered to use correct spelling and grammar in his own assignment description.

Last edited by KatoKrazy; 07-01-2014 at 10:29 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-01-2014 , 11:01 AM
Can you cut your page count down by moving the graphs and such to a few pages after the paper officially "ends?"
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-01-2014 , 12:38 PM
We're making our 5th pass or so at an automated unit/integration testing stack for our node/angular app. We were using zombie, but that didn't play nice with angular. Then Karma but that didn't work well on windows machines (which unfortunately some of our developers are on). Then casper/phantom - but that seems to be flaky as hell and doesn't work for unit testing.

So now we seemed to have solved the Windows problems, and we're back to Karma/Jasmine/Phantom--which seems fine for unit testing against stub data but is insanely slow when doing integration testing against live data. My plan is to write a utility that spins up 10 or so node instances so it can run 10 integration tests in parallel. I've been too buried in project work until now to start looking at it.

Does anyone have any other suggestions? We'd like to stay on the same platform, for unit testing and integration testing if at all possible - so the devs don't have to learn two different testing languages and/or frameworks. We have offshore devs scattered all over and constantly churning on and off, so training is difficult. It also has to work well on Windows. And any kind of built in way to run a bunch of tests in parallel would be a huge plus. A test suite that takes 45 minutes to run would slow us down in a lot of painful ways.

When it comes to full blown automated unit/integration testing on an industrial-sized site, it really seems like there's no industry standard, things are constantly changing, and nothing really works that well. We talk to high powered outside consultants from time to time and I always pick their brains about testing. They seem to all say it's very difficult and there's no magic bullet. We could possibly get access to Selenium for the integration testing. But that wouldn't help with our unit testing.

Even if we figure out all the technical challenges - the cultural change to true test-driven-development is probably going to be our biggest hurdle. Given the standard corporate way we don't like to make hard choices up front that will slow down the project, and govern from crisis to crisis in a roller coaster of denial and panic, I'm not optimistic.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-01-2014 , 04:16 PM
suzzer,

Have you seen http://theintern.io/#features?
Also here's their github page https://github.com/theintern/intern.

Haven't tried it myself but it came up in Google when searching for "javascript integration testing".
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-01-2014 , 09:47 PM
I ordered a keycap puller the other day, and look what I stumbled across:

http://www.daskeyboard.com/daskeyboard-4-ultimate/

That looks absolutely amazing, but I'm not really ready to toss mine out.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-02-2014 , 08:31 AM
@suzzer

The 10 in parallel will help the most, in my view, if your framework is blocking for relatively long periods with whatever OS calls. Seems like there is minimal/no thread syncing involved so it is worth a try in my view.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-02-2014 , 11:05 AM
Quote:
Originally Posted by Shoe Lace
suzzer,

Have you seen http://theintern.io/#features?
Also here's their github page https://github.com/theintern/intern.

Haven't tried it myself but it came up in Google when searching for "javascript integration testing".
Thanks that looks very promising. I will check it out. The one thing I didn't see though is native support for running multiple integration tests in parallel.

That's what I really liked about grunt-casper. But it seems to be really flaky about when and how it fails out of parallel tests. And there's no nice clean summary of what failed and what passed at the end. You have to go digging through the results and know what you're looking for.

I'm guessing that syncing up all those results in different threads to get some sort of unified behavior out of them is a fairly tough problem.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-02-2014 , 11:25 AM
Quote:
Originally Posted by suzzer99
Thanks that looks very promising. I will check it out. The one thing I didn't see though is native support for running multiple integration tests in parallel.

That's what I really liked about grunt-casper. But it seems to be really flaky about when and how it fails out of parallel tests. And there's no nice clean summary of what failed and what passed at the end. You have to go digging through the results and know what you're looking for.

I'm guessing that syncing up all those results in different threads to get some sort of unified behavior out of them is a fairly tough problem.
Maybe, depends. Seems like a multiple readers - one writer type problem. Semaphores and critical sections would be your friends here but an off the shelf solution would surely be preferable.

Last edited by adios; 07-02-2014 at 11:34 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-05-2014 , 05:02 AM
For a simple HTML/CSS/JS card game if I have certain slots for cards like flop/turn/river/handcards for player 1..n what are my design options from a highlevel POV?

I was thinking designating the "felt" to be a fixed size and then putting absolutely positioned divs on it (any recommendation on a good default size, was thinking 800x600 range or 960xX). Could save that positioning in a config file/DB for the game i.e. top left of each slot then build the site by reading in the config etc.

Pretty much all graphics will be SVG so resizing shouldn't be too much of an issue.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-05-2014 , 10:56 PM
So, what happens when a "functional programmer" tries on some OO?

Code:
class OrderValues:
    def __init__ (self, days = None, from_date = None, to_date = None, final_value = True, order_status = None):
        self.d = {}
        self.days = {'NumberOfDays' : days}
        self.from_date = {'CreateTimeFrom': from_date}
        self.to_date = {'CreateTimeTo': to_date}
        self.final_value = {'IncludeFinalValueFee': final_value}
        self.mod_from_date = {'ModTimeFrom': from_date}
        self.mod_to_date = {'ModTimeTo': to_date}
        self.order_status = {'OrderStatus' : order_status}

class OrderFunctions:
    def dict (self):
        return self.api_ex.response_dict()

    def json (self):
        return self.api_ex.response_json()

    def xml (self):
        return self.api_ex.response_content()

class GetOrdersByDay (OrderValues, OrderFunctions):
    def __init__ (self, days):
        OrderValues.__init__(self, days = days)
        self.d.update(self.days)
        self.d.update(self.final_value)
        self.api_ex = api.execute('GetOrders', self.d)

class GetOrdersByDate (OrderValues, OrderFunctions):
    def __init__ (self, from_date, to_date):
        OrderValues.__init__(self, from_date = from_date, to_date = to_date)
        self.d.update(self.from_date)
        self.d.update(self.to_date)
        self.d.update(self.final_value)
        self.api_ex = api.execute('GetOrders', self.d)

class GetOrdersByStatus (OrderValues, OrderFunctions):
    def __init__ (self, order_status):
        if order_status in ['Active', 'Completed', 'Cancelled', 'Inactive']:
            OrderValues.__init__(self, order_status = order_status)
        self.d.update(self.order_status)
        self.d.update(self.final_value)
        # self.api_ex = api.execute('GetOrders', self.d)
        print(self.d)
A call:

Code:
days = GetOrdersByDay(5)

print(days.json())
I'm not too sure how bad all of this is to start with. There are a few things that wil have to change. For example, the OrderFunctions class will end up being used throughout the whole program. I get that it probably isn't great to over-ride the defaults, but I have further plans for this stuff, so don't take it at face-value.

The question is: how many LOC will this last before I feel like an idiot?

The real question: How good / bad is this?

Seriously, if it sucks, let me know.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-05-2014 , 11:59 PM
Quote:
Originally Posted by daveT
I ordered a keycap puller the other day, and look what I stumbled across:

http://www.daskeyboard.com/daskeyboard-4-ultimate/

That looks absolutely amazing, but I'm not really ready to toss mine out.
LOL 104-key
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2014 , 12:10 AM
Quote:
Originally Posted by n00b590
LOL 104-key
I actually need every key. Excel would be utterly unusable without arrows and F keys. **** no I'm not holding down a function key with my pinky all day.

I also type 15 string digits.

And I probably touch my mouse 10 times a day.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2014 , 06:45 AM
Quote:
Originally Posted by daveT
So, what happens when a "functional programmer" tries on some OO?

Code:
class OrderValues:
    def __init__ (self, days = None, from_date = None, to_date = None, final_value = True, order_status = None):
        self.d = {}
        self.days = {'NumberOfDays' : days}
        self.from_date = {'CreateTimeFrom': from_date}
        self.to_date = {'CreateTimeTo': to_date}
        self.final_value = {'IncludeFinalValueFee': final_value}
        self.mod_from_date = {'ModTimeFrom': from_date}
        self.mod_to_date = {'ModTimeTo': to_date}
        self.order_status = {'OrderStatus' : order_status}

class OrderFunctions:
    def dict (self):
        return self.api_ex.response_dict()

    def json (self):
        return self.api_ex.response_json()

    def xml (self):
        return self.api_ex.response_content()

class GetOrdersByDay (OrderValues, OrderFunctions):
    def __init__ (self, days):
        OrderValues.__init__(self, days = days)
        self.d.update(self.days)
        self.d.update(self.final_value)
        self.api_ex = api.execute('GetOrders', self.d)

class GetOrdersByDate (OrderValues, OrderFunctions):
    def __init__ (self, from_date, to_date):
        OrderValues.__init__(self, from_date = from_date, to_date = to_date)
        self.d.update(self.from_date)
        self.d.update(self.to_date)
        self.d.update(self.final_value)
        self.api_ex = api.execute('GetOrders', self.d)

class GetOrdersByStatus (OrderValues, OrderFunctions):
    def __init__ (self, order_status):
        if order_status in ['Active', 'Completed', 'Cancelled', 'Inactive']:
            OrderValues.__init__(self, order_status = order_status)
        self.d.update(self.order_status)
        self.d.update(self.final_value)
        # self.api_ex = api.execute('GetOrders', self.d)
        print(self.d)
A call:

Code:
days = GetOrdersByDay(5)

print(days.json())
I'm not too sure how bad all of this is to start with. There are a few things that wil have to change. For example, the OrderFunctions class will end up being used throughout the whole program. I get that it probably isn't great to over-ride the defaults, but I have further plans for this stuff, so don't take it at face-value.

The question is: how many LOC will this last before I feel like an idiot?

The real question: How good / bad is this?

Seriously, if it sucks, let me know.
I found it quite confusing (OrderValues.d and .api_ex could be better named as well) and since all of your classes are very tightly coupled together I think that you could easily make them into one. While in python you can probably get away with this and not have too much trouble with testing as it's easy to mock out, using classes like this in, say c++, is going to be a nightmare. It's a bit hard to tell what you are going after, but in the spirit of keeping your GetOrder___ as a class, have you considered something like:

Code:
class ResultsMixin(object):
    def dict (self):
        return self.result.response_dict()

    def json (self):
        return self.result.response_json()

    def xml (self):
        return self.result.response_content()

class OrderQuery(ResultsMixin):
    def __init__ (self, days = None, from_date = None, to_date = None, final_value = True, order_status = None):
        query = {}
	if days:
		query['NumberOfDays'] = days
	if from_date:
		query['CreateTimeFrom'] = from_date
	if to_date:
		query['CreateTimeTo'] = to_date
	if final_value:
		query['IncludeFinalValueFee'] = final_value
	if order_status:
		query['OrderStatus'] = order_status
	self.result = api.execute('GetOrders', query)
Code:
days = OrderQuery(days=5)
print(days.json())
That smells a bit though, I'm having trouble thinking of a reason you'd want the code to execute in the constructor. I think it's likely you're looking for something like the repository pattern and maybe something like this would be better:

Code:
class APIRepositoryResult(object):
	def __init__(self, result):
		self.result = result
	def dict (self):
        	return self.result.response_dict()

    	def json (self):
        	return self.result.response_json()

    	def xml (self):
      		return self.result.response_content()

class APIRepository(object):
	def get_order(self, days = None, from_date = None, to_date = None, final_value = True, order_status = None):
		query = {}
		if days:
			query['NumberOfDays'] = days
		if from_date:
			query['CreateTimeFrom'] = from_date
		if to_date:
			query['CreateTimeTo'] = to_date
		if final_value:
			query['IncludeFinalValueFee'] = final_value
		if order_status:
			query['OrderStatus'] = order_status
		return APIRepositoryResult(api.execute('GetOrders', query))
Code:
days = repository.get_order(days=5)
print(days.json())
This will allow you to easily mock out your api for testing since all of the calls to it will go to a single location, and should you need to change your datastore, it's as simple as swapping in a new repository and writing a new result class to handle its result format.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2014 , 08:34 PM
Quote:
Originally Posted by daveT
I ordered a keycap puller the other day, and look what I stumbled across:

http://www.daskeyboard.com/daskeyboard-4-ultimate/

That looks absolutely amazing, but I'm not really ready to toss mine out.
Why is the keyboard blank? Is non-blank an option?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2014 , 08:54 PM
Quote:
Originally Posted by suzzer99
Why is the keyboard blank? Is non-blank an option?
133t haxors don't need key caps.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2014 , 09:28 PM
Quote:
Originally Posted by suzzer99
Why is the keyboard blank? Is non-blank an option?
They use a different OEM on the printed keyboards and whatever other justfication I can come up with. I read that the letters rub off after a matter of weeks anyways, which is bull**** considering the price. Even the free Dells are still readable, albeit non-responsive, after a year.

I been using the blank for a year now and I do love it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2014 , 09:37 PM
Quote:
Originally Posted by skier_5
I found it quite confusing (OrderValues.d and .api_ex could be better named as well) and since all of your classes are very tightly coupled together I think that you could easily make them into one. While in python you can probably get away with this and not have too much trouble with testing as it's easy to mock out, using classes like this in, say c++, is going to be a nightmare. It's a bit hard to tell what you are going after, but in the spirit of keeping your GetOrder___ as a class, have you considered something like:

That smells a bit though, I'm having trouble thinking of a reason you'd want the code to execute in the constructor. I think it's likely you're looking for something like the repository pattern and maybe something like this would be better:

This will allow you to easily mock out your api for testing since all of the calls to it will go to a single location, and should you need to change your datastore, it's as simple as swapping in a new repository and writing a new result class to handle its result format.
Thanks for the answer. I'm guessing that if it is bad in C++, then it is bad no matter what language I am using. I know that was pretty awful but when you are drinking...

I reconsidered the design a bit. Basically, I need to be able to construct maps like this: https://github.com/timotheus/ebaysdk...ng.py#L151-186

Which are nested and chained together. I found this from SO: http://programmers.stackexchange.com...a-class-method

And now I'm considering methods that look like this:

Code:
class GetFinalValue ():
    def __init__ (self, final_value = True):
        self.query = {}
        self.query['IncludeFinalValueFee'] = final_value
    
    def v (self):
        return self.query

class GetOrdersByDay ():
    def __init__ (self, days):
        self.query = {}
        self.query['NumberOfDays'] = days

    def v (self):
        return self.query

class GetOrdersByDate ():
    def __init__ (self, from_date, to_date):
        self.query = {}
        self.query['CreateTimeFrom'] = from_date
        self.query['CreateTimeTo'] = to_date

    def v (self):
        return self.query

class GetModifiedOrders ():
    def __init__ (self, from_date, to_date):
        self.query = {}
        self.query['ModTimeFrom'] = from_date
        self.query['ModTimeTo'] = to_date
    
    def v (self):
        return self.query
Which I guess would allow me to create said trees, but I end up with somthing like this:

Quote:
fv = GetFinalValue()
days = GetOrdersByDay(5)
days.v().update(fv.v())

print(days.v())
If I want to call the API, I end up with something like this:

Code:
myCall = api.execute ('GetOrders', days.v().update(fv.v()))
I guess you can see how long that part I linked to would get. Obviously I can iterate, but still feels pretty gross.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
07-06-2014 , 09:44 PM
I bought a refurbished Toshiba laptop for my technophobe dad to replace his XP laptop which is dying. How much hell am I going to have to go through to get Windows 8 to look something like what he's used to? Is it even possible?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m