This sort of automagic refactoring/editing wizardry is also easier to pull off in a statically typed language like C++.
The Community Edition has 99% of what you probably would want to do anyway, looking at this comparison: Compare Visual Studio Product Offerings | Visual Studio
Pythonās flickrapi is pretty good. I trimmed my flickr photos down to 1000 using my own criteria rather than SmugMugās most-recent hammer. It wasnāt so much a script as an interactive python session.
The engine used to make Wargroove is now open source.
So I actually ran into a ārealā coding problem at work that activated the Zachtronics area of my brain. It seems so simple on the surface that it should be trivial. There should just be some easy trick to make it happen, especially in Python. Yet, it actually took me like 20 lines and two recursions, and that feels wrong. There should definitely be some easier way to do this. Anyone want to try?
Ok, so there is a tree, but you donāt have to worry about the whole tree. We only have to look at one branch of the tree. We start with a single node and just follow its parents to the root of the tree and we get a single branch, which is now represented as a dictionary like this:
{'a': 1, 'parent': {'a': 2, 'parent': {'a': 3: 'parent': None}}}
For any such given tree branch, remove all the āparentā keys and instead replace them with āchildā keys, basically reversing the dictionary so that the root of the tree is the top level dictionary. Preserve all other keys and values on all the dictionaries. In this case, the only other key is āaā. This must work for any branch that is within the recursion limit. The correct output for our test case would be:
{'a': 3, 'child': {'a': 2, 'child': {'a': 1, 'child': None}}}
Here is the code I have written to do this that I feel is far from perfect:
def parent_to_child(tree):
def recursive_dict_to_stack(rdict):
stack = []
parent = rdict.pop('parent', None)
if parent is not None:
stack += recursive_dict_to_stack(parent)
stack.append(rdict)
return stack
stack = recursive_dict_to_stack(tree)
stack.reverse()
def stack_to_newtree(stack):
top = stack.pop()
if stack:
top['child'] = stack_to_newtree(stack)
return top
return stack_to_newtree(stack)
As you can see Iām basically recursively traversing the branch to push every node onto a stack. Then I peel them off and recursively build a new branch in reverse.
Can you do better?
Donāt bother with recursion.
def invert(tree: dict):
curr = tree
stack = []
while curr is not None and 'parent' in curr:
stack.append(curr)
curr = curr.pop('parent')
root = stack.pop()
curr = root
while len(stack) > 0:
curr.pop('parent', None)
curr['child'] = stack.pop()
curr = curr['child']
curr['child'] = None
return root
Copyright me, all rights reserved
I mean, yeah, thatās good, but itās basically the same solution, only iterative instead of recursive. You got one loop to fill the stack and one loop to peel it off. Iām looking for a solution that is structurally different.
So not recursive, and not iterative? Some itertools or zip type fancy two liner or something?
Yeah, thatās what I was hoping for. Or at least one loop instead of two.
How about a single recurse?
def invert2(tree, child=None):
if tree is not None and 'parent' in tree:
parent = invert2(tree['parent'], tree)
tree['child'] = child
tree.pop('parent', None)
return parent or tree
return tree
After so much searching I finally found a 2D game engine that is exactly what I want. Itās free. It is primarily for 2D games. Itās easy. Itās not super crazy fancy with all this stuff I will never use. Itās not super limited to just small games. It can make games for all three major desktop OSes, both major mobile OSes, and also just HTML 5. Itās made by the people who make Candy Crush. It is called Defold
I am going through all the tutorials, which is going very quickly since I know how to code already. I got plans to make some tiny games. Anything bigger would be shit-talk.
What language do you write in? Cursory look doesnāt say.
Itās lua, but I think there are ways to use something else if you really want. I donāt see the point of that, though.
My webhost updated their server and the old version of Python was no longer there and so I had to update everything including Django and whatnot. 4 hours later, itās all good.
But now, back on my laptop, the database population stuff isnāt working and itās all come down to a fucking circular dependency between a Django app models page importing the main appās admin page that also imports classes from the appās model page.
Iām sure thereās some really obvious fix for this, but after 2.5 hours itās not cracking through my brain. I understand the problem, but I canāt retrace the steps to how this became a problem now and was never a problem before. I hope itāll come back to me in the morning, as for now Iām missing a step.
That sounds like a strange situation, but Django has some magic where you can often use a string of the thingās name instead of the thing itself.
class MyModel(models.Model):
foo = models.ForeignKey('OtherModel') # If this was OtherModel the class, not 'OtherModel' the string, this would be an error
class OtherModel(models.Model):
bar = models.IntegerField()
etc...
This is awesome:
Use numpy et al. in the browser!
Just learned about whitenoise.
Apparently itās ok to serve static files directly out of Django now? At least Mr. Django says so, and I take his word for it.
I guess if your app is really small and insignificant, then this is fine. But seriously, the bare minimum of having nginx serve the static files is super easy and also a perfectly good architecture for even quite large sites.