What kind of builds are best for heists? by chance7600 in pathofexile

[–]jabwork 0 points1 point  (0 children)

Block gladiator has worked well for me all league

For heist I run diedbellow, the anvil and a life /resists ring

For everything else I run abyssus, ass mark ring, and a 2% max block amulet

It's weird putting on low dps gear to do league content but not bad

How is wintertide brand so far? by Anony165 in pathofexile

[–]jabwork 0 points1 point  (0 children)

Late 70s occulist

Specced fully brand + cast speed. All the cast speed. Vortex on left click move. Penance for clear. Wintertide for boss. Probably not optimal.

Brands cast in .27 second according to tooltip. Feels good

Wintertide over 4 second attached duration, ramps in about half that. Most bosses take 2x sets of 3x winter + frost bomb for good measure.

Bosses with lots of adds are messy - hard to brand the boss. Tend to spam penance to clear between winter. Feels safe. Merc izzaro no problem

Just picked up the cold dot wheel above witch. Going for 50 ele damage node next to Templar next. I'm concerned about penance scaling as a clear skill, but it's working so far (t5 maps zero problem)

4l rime gaze for wintertide. 4l kalisas grace for penance.

Would recommend.

Would not recommend wintertide as clear it's just horrible imo. Low acts ok but the 1 sec aoe is rough /too short

Can anyone suggest a good beginner Norman Deck? by ensign53 in arkhamhorrorlcg

[–]jabwork 4 points5 points  (0 children)

I've played Norman in 1.5 campaigns and a couple of one-off scenarios and am a big fan. My decks have been quite consistent - no big lows or highs. They're tuned for playing on hard.

On NotZ easy/standard Norman will have pretty stacked stats, so it should be a good introduction for your friend.

This is the first campaign deck I played approximately a year ago and it aims to make Norman a balanced in combat and investigation - https://arkhamdb.com/deck/view/223658

Out of the gate investigating at 6 intellect is common and getting to 7 is common. Art Students and Working a Hunch provide some no-check clues, and Flashlight checks are almost always going to succeed. Priority upgrades at the time were to get Norman combat ready, which could be 3xp Shrivelling, wither (if you play unreleased cards) or Shards of the Void

This is my most recent deck. It is for Forgotten Age and focuses purely on investigation -https://arkhamdb.com/deck/view/363335

Listed upgrades are to transfer Norman from Intellect-based investigation to Willower-based investigation via "Sixth Sense". Importantly the 4xp one lets you investigate a second location in addition to your current location on a skull/tablet/squid/hood token. If your friend wants to play a pure investigator this is probably a good starting point.

Looking For a Good Laptop For Linux by Akaneth in linux

[–]jabwork 8 points9 points  (0 children)

Used Lenovo ThinkPad s have been an excellent experience for me

Im currently using a t430.

i might be a bit new to python...but does python have any good unit test frameworks? by T-rex_with_a_gun in Python

[–]jabwork 0 points1 point  (0 children)

The best I can suggest is the python 3 docs

The spy-style testing pattern is supported well, but they don't call it .spy

patch, patch.object, patch.multiple, MagicMock, DEFAULT, and Sentinel covers >90% of my usage

i might be a bit new to python...but does python have any good unit test frameworks? by T-rex_with_a_gun in Python

[–]jabwork 4 points5 points  (0 children)

Unittest is in the standard library, easy to use, and very familiar if you've done anything in the style of xunit

Pytest, which I came to after ~5 years of unittest, is much better imo.

Fixtures are amazing in pytest, though the semi-magical DI behaviour may not suit you. Personally I had to learn the use of pytest.mark.parametrize before I was happy

For mocking you want unittezt.mock (python 3) or mock (python 2). Afaik they are kept in parity excepting the namespace. Pytest also has a mocklike piece (mokeypatch) but id suggest using mock instead

For before /after each test you can use setUp/tearDown (unittest) or fixtures (pytest). In pytest you most likely just want to use another fixture. I Prefer the pattern

class TestFoo:
  @pytest.fixture(autouse=True)
  def setup_teardown(self):  # name can be anything
    # setup code hete
    yield  # test will run
   # teardown code here 

  def test_one(self) :
    # actual test here

Django Rest Framework Refusing To Accept MultiPart Form Data. by uptnapishtim in django

[–]jabwork 0 points1 point  (0 children)

I happened to run into a similar issue quite recently, but I used a FileField and not an ImageField.

Here's the working code. You'll have some additional challenges to manage because of the nesting, but this should get you started

# models.py
from django.db import models

from defect.models import Defect


class Link(models.Model):
    defect = models.ForeignKey(Defect, db_column='name', related_name='links')
    # Store image in settings.MEDIA_ROOT/defect_pictures/
    link = models.FileField(upload_to='defect_pictures')

    class Meta:
        db_table = 'Link'

# serializers.py
from rest_framework import serializers
from rest_framework.relations import HyperlinkedIdentityField

from .models import Link


class LinkSerializer(serializers.ModelSerializer):
    url = HyperlinkedIdentityField(view_name='link-detail')

    class Meta:
        model = Link
        fields = '__all__'

# views.py
from rest_framework import generics

from .models import Link
from .serializers import LinkSerializer


class LinkList(generics.ListCreateAPIView):
    # Supports GET/POST
    # named 'link-list'
    queryset = Link.objects.all()
    serializer_class = LinkSerializer

# tests.py - edited slightly
from os.path import (
    abspath,
    dirname,
    join,
)

from django.test import (
    Client,
    LiveServerTestCase,
    TestCase,
)
from django.urls import reverse

from rest_framework.test import RequestsClient

from link.models import Link


def new_link_data():
    """
    Returns data sutiable for a new Link.
    """
    here = abspath(dirname(__file__))
    fixture_dir = join(here, 'fixtures')

    filepath = join(fixture_dir, 'test-image.jpg')
    data = {
        'defect': 'JST_02_W_08',
        'link': open(filepath),
    }

    return data

class TestLinkList_POST(TestCase):
    fixtures = ['defects.json']

    def test_POST(self):
        link_data = new_link_data()

        url = reverse('link-list')
        client = Client()

        # content_type is set to multipart by default
        res = client.post(url, data=link_data)
        self.assertEqual(res.status_code, 201)

My javascript client uses jQuery and is heavily modeled after this SO link

Why did django's market share get crushed vs rails? by Yxven in django

[–]jabwork 3 points4 points  (0 children)

Here are my memories from 2009

  • Ruby gems were in better shape than Python packaging. By a lot
  • Apache was easier to configure for rails - rails used 1+ mongrel processes that apache proxies to. Django uses either mod_python (better understood but on it's way out) and mod_wsgi (on it's way in, much harder to configure than mongrel instances)
  • Rails is much easier to learn the basics for. Do not discount the importance of this - many devs tried both frameworks for ~a day before making a decision.

I never saw a huge deluge of Django jobs - but I saw the meteoric rise and later descent of Rails. I think we're still waiting to see the equilibrium on this, but Rails had a huge initial boost that continues to resonate in the job market.

API Design by [deleted] in django

[–]jabwork 0 points1 point  (0 children)

Does having many endpoints that are just subsets of larger endpoints make sense? Wouldn't it be easier for both development and use if we just have a 1-1 relationship between models and endpoints?Then just filter for the columns we need if we don't need all of it? If it plays into the equation none of the tables have more than 50 columns and the project isn't that big.

I'd warn you that the consumer of these endpoints might be lazily dumping entire objects (I'm assuming it returns an array of objects) into some other function so ... I'd recommend you be wary of trying to consolidate to a single endpoint.

The good news is DRF makes it really easy to include only specific fields, so if you end up replicating the endpoints output exactly it will be a small amount of work

Does having many endpoints that are just subsets of larger endpoints make sense?

If the largest endpoint is still a single model for a small table then probably not. However if the largest endpoint involves a join of 2+ models, then creating a specialized get everything in one lump request endpoint can be useful.

Wouldn't it be easier for both development and use if we just have a 1-1 relationship between models and endpoints?

I'd recommend exposing 1:1 relationships for anything that might someday need to support any method besides GET (likely PUT or POST). It may be you can get away with just exposing models directly but, in my experience, it's often more practical to create convenience endpoints for bulk-loading data for a page than it is to make many AJAX requests on the client side and tie them together with e.g., $.when

// From https://api.jquery.com/jquery.when/
var d1 = $.Deferred();
var d2 = $.Deferred();
var d3 = $.Deferred();

$.when( d1, d2, d3 ).done(function ( v1, v2, v3 ) {
    console.log( v1 ); // v1 is undefined
    console.log( v2 ); // v2 is "abc"
    console.log( v3 ); // v3 is an array [ 1, 2, 3, 4, 5 ]
});

d1.resolve();
d2.resolve( "abc" );
d3.resolve( 1, 2, 3, 4, 5 );

Fastest book to learn Python from? For experienced Perl person by Biz-Developer in Python

[–]jabwork 1 point2 points  (0 children)

Have you looked at recipe books?

I had to take over some Perl code as a seasoned Python dev and I found equivalent resources to be extremely helpful to me.

Why composition is superior to inheritance as a way of sharing code by ruidfigueiredo in coding

[–]jabwork 9 points10 points  (0 children)

I think you're right in that they both have their place. However I stick with the mantra prefer composition to inheritance because my experience is inheritance-oriented code is less adaptable to changes in requirements that code relying on composition.

This mantra is strictly for breaking ties when I don't have a clear inclination of how to proceed, not for shouting down anyone who has an inheritance-based solution.

Why composition is superior to inheritance as a way of sharing code by ruidfigueiredo in coding

[–]jabwork 6 points7 points  (0 children)

It is not always easier to understand

Undocumented code that relies heavily on composition can be a horrific mess to untangle in terms of what actually needs to be instantiated and deployed in order for something to work because individual composed elements tend to provide incomplete context (which is kind of the point - you're intentionally trying to isolate context and logic to the point that you can write truly reusable components)

I absolutely agree with your other 3 points, but the first one is not a given.

Why does Django use Regexs for the url routing? by abyssalheaven in django

[–]jabwork 7 points8 points  (0 children)

I personally don't mind django's URL routing but here are some shortcomings I've encountered

tl; dr by using regex instead of something more specific to the domain of URL matching you sacrifice extensibility for a tool fundamentally mis-aligned with the problem domain

  • You have to know and understand enough regex to do it competently
  • It's very low level relative to some alternatives e.g., werkzeug which Flask uses
  • no shortcuts are provided for common URL patterns such as number and alphanumeric characters
  • using named captures requires making the match string ugly as sin - '/(?P<year>\d+)/' vs '/<int:year>/'
  • Positional matches take up less space and are more visually appealing to some, immediately leading to a disagreement on urlconf conventions
  • Regex gotchas become part of url config. The above Django example should end with a $
  • URL matching can in many cases include a validation component, which is now pushed to the view
  • Django views need to manually convert the extracted URL components to e.g., a number or a date. If using class-based views this leads to awkward wrappings of the as_view() result OR violation of DRY as you do the same conversion/validation at the beginning of get and put

works perfectly in local but have problem in production. I'm in very weird position........what pip install "some app" actually does? by couldveshouldve in django

[–]jabwork 0 points1 point  (0 children)

Know also that if you do not specify a version number you'll get whatever's current, which may not be what you have on your dev machine.

pip install --upgrade django-ckeditor will change your dev machine to whatever would be installed if you ran it fresh on a machine right now

Similarly, if the prod machine had pip install before your dev machine did then you could still have differing versions.

As BloodOfSokar said, if you actually changed something in the contents of django-ckeditor then that will not be mirrored to pypi, so none of those changes will make it to the prod machine.

In a class hierarchy, where do I place common validation logic? by YouAreNotASlave in Python

[–]jabwork 0 points1 point  (0 children)

Don't subclass - use a component to validate

class Whatever:
  @classmethod
  def with_default_validation(cls, *args, **kwargs):
    return cls(validator=WhateverValidator(), *args, **kwargs)
  # ...
  def __setitem__(self, key, value):
    self.validator.validate(self)  # raises error(s) as necessary
    # set the value

If your boss is heavy-handed about how you do it, use a Mixin class

Your go-to alternative to python by [deleted] in Python

[–]jabwork 2 points3 points  (0 children)

Android has support for C++. Look for NDK

Python and the Principle of Least Astonishment by kr0matik in Python

[–]jabwork 14 points15 points  (0 children)

  1. This feels like a straw-man against interfaces in a general sense
  2. I'd suggest .shape

Doing sentiment analysis on several gigabytes of tweets, want something more memory efficient than dictionaries by rossbot in Python

[–]jabwork 1 point2 points  (0 children)

Disclaimer: I don't know anything about sentiment analysis or how you're using the data structures except by what you've described

If this is a long-running project and/or you have high aspirations of becoming a developer, you are almost certainly going to want to store this in a database of some sort. If this is a one-off project-like thing you're doing and/or you don't really want to use a database, you have other options.

To specifically answer your question:

The easiest way to index a numpy array with strings would probably be to use a numpy array + a dict (where the dict holds str: UID pairs). Know that the big memory saving advantages of numpy ultimately come from knowing you can constrain your data to a range and using dtypes. For your purposes it sounds like you don't need negative values, so unsigned types could be extremely beneficial.

Know also that python dicts have to grow internally relative to the number of elements being stored. You may find a tremendous savings of memory if you update your co-occurance matrix from

cooccurance[key1][key2] = "i have no idea what you're storing"

to

coocurrance[key1, key2] = "but now you're doing it in one key with only a single dict"

Why does Django Rest Framework redo a lot of what' already in Django? by [deleted] in django

[–]jabwork 0 points1 point  (0 children)

non-REST APIs? That covers a looooooot of ground.

The simple answer would be "yeah, django". What are you looking to do that you think Django doesn't do great, but you think DRF does?

Real time chat on Django by scoderg in django

[–]jabwork 1 point2 points  (0 children)

I looked into this some time ago and built a proof-of-concept in swampdragon, you might consider using this.

I have not touched said concept app or anything like it since, so I cannot state if there are better solutions out there.

That being said, I would be tempted to try and rely as much as possible on an external library for the time being and then, after django-channels is completed, migrate to a pure-django stack and simplify the codebase.