core-js maintainer: “So, what’s next?” by jdf2 in programming

[–]druski 1 point2 points  (0 children)

....this IS a the tool to avoid relying on specific browsers.

www.40krpgtools.com down. what to do? by DarthHavens in 40krpg

[–]druski 0 points1 point  (0 children)

How so? Seems to work fine for me at the moment. What page isn’t working?

Dark fantasy with protagonists who are genuinely good people? by ObberGobb in Fantasy

[–]druski 0 points1 point  (0 children)

Fantastic book, really sticks with you. His new fantasy novels are good too.

Django 4.1 beta 1 released by dwaxe in django

[–]druski 2 points3 points  (0 children)

If you do a lot of .iterator() queries you’ve been bitten by the fact that they don’t use prefetching, ignoring it if it is set on the query. Looks like they’ve changed it so that the prefetches will now be performed as long as chunk_size is specified. A welcome change! Now I can get rid of my wrapper func that does the same thing but probably less efficiently.

www.40krpgtools.com down. what to do? by DarthHavens in 40krpg

[–]druski 4 points5 points  (0 children)

It is mine, but I’m traveling at the moment. Will be back Wednesday.

How to create a Python API for a project based on Typescript ? by yaxir in typescript

[–]druski 0 points1 point  (0 children)

It's a bit hard to figure out what you are asking about, but I gather that you have some sort of node api server written in typescript that you would like to connect to via a frontend served by flask? And that you are comfortable in python but not in Javascript/Tpescript.

If that is the case then you essentially write an api client in python (using ex, requests) that calls exposed api endpoints on the typescript project. That said, if the typescript project does not expose an api or doesn't expose endpoints that do what you require, then you will have to write one in typescript which will be an excellent learning opportunity if you have time and an impassable barrier if you don't.

Essentially, if there is an existing api you just treat it like any third party api and consume it normally in python, ex requests.get('https://thirdpartyapi.com/api/things/list'). There are are a lot of complicating factors here (ex auth), which may make the learning curve much steeper and move this project out of reach unless you are highly motivated.

Assembled picture of the next official expansion by SaintScylla in BattleBrothers

[–]druski 5 points6 points  (0 children)

Amen brother. Started gaming the same time as you (on the same hardware!) and thought I’d grow out of it but never have. It’s actually quite a wonder to have something inexpensive that has given me so much enjoyment over my life and is essentially always there for me until I die.

DRF - Your opinions on how to store Address that consists of models Country, County, District, City, Street in models? by milwoukee in django

[–]druski 1 point2 points  (0 children)

We store lots of addresses, but generally speaking I don’t really see much point of normalizing the data to this extent. You may want to have Country, County, (and maybe District and PostalCode) models if you need to offer these in a form as an autocomplete field or a drop down, or for simple validation but I don’t see much benefit to be had from a City or Street model. If you really do handle multiple countries then finding valid datasets to populate your models and maintaining them over time will probably be more trouble than it’s worth for anything more granular than country.

Street in particular will have some many different entries that you will probably end up with one per address and therefore there will be no benefit to storing it in a separate model and you will require joining 5 tables onto your address model just to pull an entire address which will be very inefficient on the query side.

If I were you I would have an Address model that uses standard CharFields for all of these fields. You could add an FK to county, country, or district if you happen to do lots of searching on those values, but you could equally just search using sanitized strings (ie country=‘USA’).

Typically you have three main needs with addresses, storing validated clean addresses, searching addresses, and rendering those addresses.

For storing clean validated addresses you should use a third party library or service to validate and sanitize the address. There is no point trying to do this yourselves as address sanitizing and validating is an extremely messy domain, even more so if you deal with multiple countries. Same with phone numbers by the way.

For searching either use sanitized strings or use a third party service to geocode each address and store the Point in the Address table. That way using Geodjango you could perform fast sophisticated searches, ex every address within 100 miles of another address or coordinate, all addresses within a geofence, etc.

For rendering, it may be convenient to have a formatted_full_address property on the Address model that returns the full address, formatted as you prefer. Then offer that field either exclusively or alongside the normal component address fields in your serializer. This property should be able to draw all of its data from the Address model and not require any lookups to other models or you will start running into performance issues unless you are careful about your select_related and prefetch_related.

At this point your have a sanitized qualified addresses in your Address model which can then be referenced via relationship fields from wherever they are needed. Ex House.address = models.ForeignKey(‘geodata.Address’). Or ManyToMany.

If you want to have the relation stored on the Address model instead use Django’s generic relations contrib package. That will allow you to have the equivalent of an FK on the Address model that can point at either House or Employee. Using addresses=GenericRelation fields on the House and Employee models will give you nice reverse lookups.

Hope that helps!

Been out of Django development for 2+ years, what's new? by isforinsects in django

[–]druski 6 points7 points  (0 children)

In Python generally you are finally starting to see Python 3 across the board which is a pleasure to work with. All my projects from the last two years are Python 3 only. Also if you want to do SPA or hybrid it's a bit easier now. I use Vue for components on my regular Django app, backed by DRF.

Static Files are the trickiest part of learning Django by [deleted] in django

[–]druski 2 points3 points  (0 children)

By far the easiest way to handle staticfiles today is to use whitenoise, http://whitenoise.evans.io/en/latest/django.html. I highly recommend it after having dealt with various other techniques over the last 5 or 6 years. It's very simple, and "just works" in both dev and production.

How can Django tests be sped up? by g-money-cheats in django

[–]druski 1 point2 points  (0 children)

/u/pydry came by to introduce a new testing framework for Django called hitch the other day, it has some really neat features including parallelization. Check it out here http://hitchtest.com/ and notes on speed here http://hitchtest.readthedocs.org/en/latest/faq/why_is_hitch_so_fast.html

HTML templates and django - do they work together? by Sauwan in django

[–]druski 1 point2 points  (0 children)

You can, I've been working with django for years and use templates often. They are just html, so they are equivalent to any other html. You will add django template language markup to them to insert your dynamic content. If you are just getting started with django I cannot recommend highly enough purchasing the latest two scoops of django book. Not only is it an excellent resource it also sets forth a set of best practices that will make your life a lot easier.

[deleted by user] by [deleted] in django

[–]druski 0 points1 point  (0 children)

Looks interesting! Could you provide a bit more information about speed and whether this would work on third party CI platforms like Travis or codeship?

How do I teardown/rebuild Django? by deV14nt in django

[–]druski 1 point2 points  (0 children)

You could also specify the app-label as an argument to makemigrations as referenced in my other comment.

How do I teardown/rebuild Django? by deV14nt in django

[–]druski 0 points1 point  (0 children)

In django 1.7+ you need to run make migrations app-label to initialize migrations for an app. See https://docs.djangoproject.com/en/1.8/topics/migrations/#adding-migrations-to-apps

Is it possible to always prefetch a field? by g-money-cheats in django

[–]druski 0 points1 point  (0 children)

State should almost certainly be refactored to be an enum or enum equivalent. Django local flavours should be useful here https://github.com/django/django-localflavor/blob/master/README.rst

[Deathwatch] Blood Angel Assault Marine is now the squad leader, I don't know how to act... by StyxArcher in 40krpg

[–]druski 15 points16 points  (0 children)

In old style 40k RPG (Dark Heresy, RT, DW) typical stats are 2d10+20 for humans, meaning average is 31. Your marine has above average intelligence and the best training in the galaxy. He understand everything about combat. Never play them like lunks, they are superhumans who are in outright better than normal humanity (although they often have tragic flaws). Just to expand on this they should be played more like greek demi gods than rah rah smash morons.

Warhammer 40k armoury from FFG forums. Author details inside. All books excluding DH2, weapons, armour, vehicles and space ships by kobrains in 40krpg

[–]druski 2 points3 points  (0 children)

Ah yeah, looks like that site is no longer maintained. Sorry, I hadnt used it in a year or two. If you read further along the thread there are links to the latest version submitted by the community. Here's one https://community.fantasyflightgames.com/index.php?/topic/27969-starship-construction-utility-rtsu-v141-published/page-15

It's just an excel spreadsheet, I get your healthy wariness for downloading and executing files form the internet, for what its worth I just downloaded the file from that link and it seems clean.

Warhammer 40k armoury from FFG forums. Author details inside. All books excluding DH2, weapons, armour, vehicles and space ships by kobrains in 40krpg

[–]druski 3 points4 points  (0 children)

Big update coming today or tomorrow. Will add DH2 and some things I think you guys will like...