Letterboxd
An example of a possibly great movie cut short by a very hard to believe premise.
Letterboxd
An example of a possibly great movie cut short by a very hard to believe premise.
Letterboxd
You know exactly what you are getting. Well done, but nothing you are going to think about after walking out of the theater.
I thought this fight scenes were a little dark (literally), sometimes had trouble making out who is doing what. The monsters were visually fun but were often difficult to discern from one another.
Letterboxd
Whelp. This was worse than I had hoped for. Everything "fits", it is just kind of getting stale.
There was a moment when Roman and Tej were kind of waxing philosophical about how they keep surviving completely absurd things. Like really really really, entirely impossible situations. I was kind of hoping that the plot would go in the direction of:
Yeah, I don't know, when I start daydreaming about directions your film could have taken while the movie is playing... we have a problem.
Letterboxd
Eh, you shouldn't watch it. But I had some fried chicken and a beer and skipped through it a bit and it was... passable. Some of the goofy fight choreography kind of grows on you. Memorable scene at end with Jackie playing Chun Li from Street Fighter.
I made the following script to download all Github projects into a directory. It is fun to see everything you have accumulated over the years. :)
curl -u <USERNAME>:<OAUTH_TOKEN> https://api.github.com/user/repos\?per_page\=100 | jq ".[].git_url" | tr -d '"' | while read in; do git clone $in; done
<USERNAME> is your github username.
<OAUTH_TOKEN> can be created from here. You only need the repo scope for this.
You may need to install jq as it isn't standard.
You will need to be authenticated or the git clone X will fail on non public repos.
API will only download up to 100 projects. If you have more than that you will have to page.
The last 2 months have seen a decline in my output. To combat this, I am implementing a new process that I hereby name the "CAR|CDR" system of productivity. CAR & CDR come from LISP Lore. I picked the name because I like saying CARKIDER phonetically.
It is really quite simple. I have a dynamic list of everything that is important to me. From projects to people to ideas to consumption to whatever. I enumerate every alternating day as either being a CAR (Head of the list) or CDR (rest of the list) day. For instance, this week MWFU are CAR (Head) days and TRS are CDR (Rest) days.
On CAR day, I shouldn't be doing anything other than the most important task on my list. I purposely choose, and in doing so free myself, to ignore all the other task in life that I deem important. It means that I don't pencil in any other things that day, I don't try to squeeze some other concern in there. I also attempt to limit the number of decisions I need to make on CAR days to only things concerning the CAR item. It is a CAR day, that is its all encompassing purpose.
CDR days are for everything other than the head of your list. For this reason I am fairly flexible about what I should do within the rest of the list. Your CDR list should always contain basic things like "exercise", "enjoy life", "have fun", "socialize", as well as directly actionable things like "pay taxes", "study category theory", etc. I really just let whim and urgency dictate what I do on CDR days. CDR days are for inspiration, they should be the opposite of focusing on a singular purpose.
There are so many things going on in my own life and in the world as a whole that I don't have a good why. Explaining why is too big a question, and I suspect I could not do it if pressed. All I am sure of is that I am not able to focus on tasks like I once could. I think partially it is my brain rebelling against the monotony of my current life; the constraint of spending almost my entire day in a 13' x 17' room as we wait out this pandemic. Without a clear path forward, I am trying random strategies I think up and seeing if they help.
As for the question of why this strategy? I think it has to do with the idea of focused vs diffuse thought. I think my mind/personality is being softened as contact with much of my previous environment diminishes. It isn't just the lose of people, it is also the roles and activities and parts that I previously played. The CAR day gives me time to put my full intellect and focus towards a task, shutting out the outside world. The CDR day gives me time to softly adjust to the new world, without having to think about my most important thing upon that day.
I hope it helps me out.

This book, I assume, is supposed to be parody? Right?
I am not sure at what point speculative fiction becomes parody. Similar to the line between erotica and pornography, it may be one of those "I can't tell you what it is, but I know it when I see it" kind of situations.
This book has 2 broad halves, the Chinese half and the Chinese + American half.
Up to the limits of the Chinese half, I was constantly asking myself questions like "Wait, are children really this selfless? Can children really do these things? Are children really this emotionally stable?" I was constantly asking myself if Chinese children are this exceptional compared to American children. The self reflection, maturity, and insight the Chinese children possessed was incredulous. I felt a vague sense of unease that Chinese children might be so superior to American children (my birthplace). What future can the United States have when the youth of other nations are so superior to our own?
The second half (Chinese + American) of the book put those fears to rest... In a big way. I cannot comment on the emotional makeup and resiliency of Chinese children. I can however comment on American children. Yes, I agree, there are broad cultural differences between the two groups. Yes, American culture has its share of problems, same as anybody else. Yes, children are reflections of the culture they were raised in. However, his portrayal of American children paints them as little more than narcissistic conniving psychopaths. It is so over the top that it becomes... I don't know, almost an exploitation of American culture rather than a reflection of it. In short, I felt his generalization of American children were significantly off. So far off that I felt the American children were written as parody.
You start the book thinking that there is only one plot element that you must take as a given, that there could be a stellar event with an incredibly specific type of radiation that only kills people over 13. However, about half way through (maybe sooner if you are less naive than I am) you discover that there are actually three such plot elements. The stellar event itself, the characterization of American Children as little monsters, and presumably the characterization of Chinese children as miniature adults.
With all that said, it was still an enjoyable read. Prose sometimes felt a little "literal" for lack of a better word. It is a quick read, so I would be comfortable recommending it to most.
*** Real Plot spoilers below - Don't continue
Things I really liked or noted:

This book, I assume, is supposed to be parody? Right?
I am not sure at what point speculative fiction becomes parody. Similar to the line between erotica and pornography, it may be one of those "I can't tell you what it is, but I know it when I see it" kind of situations.
This book has 2 broad halves, the Chinese half and the Chinese + American half.
Up to the limits of the Chinese half, I was constantly asking myself questions like "Wait, are children really this selfless? Can children really do these things? Are children really this emotionally stable?" I was constantly asking myself if Chinese children are this exceptional compared to American children. The self reflection, maturity, and insight the Chinese children possessed was incredulous. I felt a vague sense of unease that Chinese children might be so superior to American children (my birthplace). What future can the United States have when the youth of other nations are so superior to our own?
The second half (Chinese + American) of the book put those fears to rest... In a big way. I cannot comment on the emotional makeup and resiliency of Chinese children. I can however comment on American children. Yes, I agree, there are broad cultural differences between the two groups. Yes, American culture has its share of problems, same as anybody else. Yes, children are reflections of the culture they were raised in. However, his portrayal of American children paints them as little more than narcissistic conniving psychopaths. It is so over the top that it becomes... I don't know, almost an exploitation of American culture rather than a reflection of it. In short, I felt his generalization of American children were significantly off. So far off that I felt the American children were written as parody.
You start the book thinking that there is only one plot element that you must take as a given, that there could be a stellar event with an incredibly specific type of radiation that only kills people over 13. However, about half way through (maybe sooner if you are less naive than I am) you discover that there are actually three such plot elements. The stellar event itself, the characterization of American Children as little monsters, and presumably the characterization of Chinese children as miniature adults.
With all that said, it was still an enjoyable read. Prose sometimes felt a little "literal" for lack of a better word. It is a quick read, so I would be comfortable recommending it to most.
*** Real Plot spoilers below - Don't continue
Things I really liked or noted:
The quantum-whatever-star-trek-AI that the Chinese kids had was a bit of a deus ex. Whatever.
With that said, I loved the idea of a "real time chat" between millions of people. Where the AI would summarize the message of a large group of people and split them into separate singular "speakers" in real time. Allow any number of people to communicate but limit the expressive speakers to a number that is human understandable. Why can't we have something like that?
Prove me wrong, but there are many things that children simply can not do. They require emotional maturity, strength, or intelligence that children do not posses. I found the idea that most jobs could be taken over pretty ludicrous.
Maybe, with the help of an all seeing AI and the "best of the best" of China, you could have a functional society as outlined in the book. But I think a big part of this is the AI.
The American child society seemed entirely unstable. I had a really hard time believing that the characters on the American side of things could possibly do anything as complicated as launching a battle fleet, hosting a summit, or even keeping themselves fed. With those sort of characters, you would rapidly devolve into tribalism. Nothing of note could be accomplished with such a society.
I did enjoy the brutality that the children were allowed to express. I think we can all recognize at some level that empathy is something that develops for many people later in life (often around adolescense) . I did appreciate that it didn't characterize the children as being little angels. With that being said, I don't think that the "natural state" of children is even close to as terrifying as that expressed in this book.
I was especially confused why persistent automated monitoring and enforcement was not introduced as a final gift to the children from the adults. If they can build an all powerful AI, why not have the AI monitor what work is being done, chide, scold, punish and eventually exclude children who are negligent. Basically force compliance by pushing out children who choose not to work within the system. Many children would die, but many would choose to work with the AI as it assures stability for them. Seemed like a pretty large blind spot.
I wanted the opportunity to try out Planck (User Guide) (SDK), which lets you write shell scripts in clojurescript.
Wrote a small script to upload my blog into Github hosting.
Like the fact that it mixes the clojurescript code with the shell commands (sh ...). One can use simple shell commands and compose them with clojurescript. Loose the value of pipping and shell expansions, but sometimes that is a reasonable trade-off.
contains? will check (in the case of a map) for a key within a map. (contains? data v) returns true when v is :a or :f. (contains? data :c) will return false as :c is not a top level key in data.
I want to ask "containment" questions about the keys at ALL levels within a map. I want to be able to determine not just that :a and :f are within the map but also that :b, :c, :d, :e, and :g are "contained" as well. Conversely, I want to know that :z is not a key within any map in data.
(defn- add-children-metadata [m]
(->> m
vals
(map (comp :all-keys meta))
(apply clojure.set/union (-> m keys set))
(assoc (meta m) :all-keys)
(with-meta m)))
(defn map->containment-map
"Sets :all-keys metadata for every map in m; :all-keys holds every key in this map and for all submaps"
[m]
(-> (fn [acc k v]
(assoc acc k (if (map? v)
(-> v map->containment-map add-children-metadata)
v)))
(reduce-kv {} m)
add-children-metadata))
(def data {:a {:b nil
:c {:d nil
:e {}}}
:f {:g nil}})
(def contained-data (map->containment-map data))
Note that data and contained-data are equal.
(= data contained-data)
The difference is that contained-data has the :all-keys key within its metadata.
(-> contained-data meta :all-keys)
With this metadata, you can ask containment questions about keys at all levels. Each submap within contained-data also contains :all-keys in their metadata.
contained-data contains the key :f
(-> contained-data meta :all-keys (contains? :f) (= true))
contained-data does not contain the key :x
(-> contained-data meta :all-keys (contains? :x) (= false))
Key :a under contained-data has keys :b :c :d and :e
(-> contained-data :a meta :all-keys (= #{:b :c :d :e}))
That's it. You can use the :all-keys metadata to either:
I need something that converts a particular key/value within a sequence of maps into a single map. this->that will do nicely.
(defn this->that [this that vs]
"Build a map out of sequence vs; taking `this` as the key and `that` as the value from each"
(reduce
(fn [acc v] (assoc acc (this v) (that v)))
{}
vs))
;; -> {:key-1 :value-1, :key-2 :value-2}
Let's create some data for this example.
(def data
[{:id 1 :email "mouse@hanna-barbera.com" :name "Bullwinkle J. Mouse"}
{:id 2 :email "squirrel@hanna-barbera.com" :name "Rocky the Flying Squirrel"}
{:id 3 :email "boris@hanna-barbera.com" :name "Boris Badenov"}
{:id 4 :email "ffetale@hanna-barbera.com" :name "Natasha Fatale"}
{:id 5 :email "leader@hanna-barbera.com" :name "Fearless Leader"}])
With this->that and our data, we can now create a map of :id to :email.
(defn id->email [vs]
(this->that :id :email vs))
(id->email data)
Or :id to :name.
(defn id->name [vs]
(this->that :id :name vs))
(id->name data)
Within this->that the arguments this and that are being called. This must mean that keywords (:id, :email, and :name in our case) are callable as functions! this->that actually takes two functions as the this and that arguments. this->that can take a sequence of any type in vs, provided that you can write functions to pull values from every element in vs.
Let's illustrate the equivalency of keywords and functions below.
(= (this->that :id :name data)
(this->that #(:id %) #(:name %) data))

Trying to get back into the swing of things in terms of writing. It is a muscle I need to exercise and all that. Start easy by just posting a movie review.
I think Hellboy (2019) is the second most frenetic movie I have ever seen (First goes to Crank 2 High Voltage). It is the most "Russian Doll"'ed plot in my recollection; felt like one backstory introduced every 15 minutes. Lots of exposition. Fair share of flashbacks. Narratively, it was a mess.
I could spend time ripping it appart on the above, but why waste both our time? You should know that it has a awful review on rotten; if you are looking for fodder to critique the film, it is available. Let's see if there is anything interesting here.
Watching a movie sourced from comic book material, one of the biggest questions I have is "Why don't they do animation instead?" Budget on this was ~50 million dollars. Spider-Man: Into the Spider-Verse was excellent with a budget of 90 million. How good can an animated movie be with a budget of 50 million? I don't honestly know.
But here is the interesting thing. I suspect that the art assets and know how from doing one animated film also transfer to its sequels. This is of course also true for live action film. But live action films have significant cost that animated films do not. Beyond the cost of getting actors, building sets, equipment, post processing, etc, you have the simple fact that most artifacts built for the film will not be used in subsequent films.
Animation is different. Once you have worked out the software to do character kinematics, once you have the right textures, once you have figured out the proper lighting, you just keep using it. The cost to store the know-how you have accumulated over previous films is negligible. You need to save your software (and yes, even 2d animation is made with extensive software these days) and you documentation. Maybe the first film in a series cost 100 million because of novel development in your tech stack. But the next film can be made for substantially less because you are just going to use the same software and tweak it for every release to use newer (and cheaper) hardware.
I suspect one reason animation is ignored is that animated movies have a low return of a few hundred millions. They rarely generate billion dollar returns. It feels like Hollywood is more interested in making 300M movies that have a 20% chance of making billion than a 50M movies that has a almost 100% chance of making 60M.
It is also the case that Hollywood seems to be obsessed about making franchises these days. I get it, you need something that won't just pay the bills today, but might also keep the lights on tomorrow. Comic book material is perfect for franchises. The material is already so malleable and the constraints of the world are so soft that it is easily and endlessly re-mixable for all of eternity.
Animation & comic book source material are a match made in heaven for diversified risk. When you can make 6 to 10 NEW animated movies for the cost of a single live action movie, you can take a lot more risk.
It is a pretty simple program:
Converting a vector of values to a CSV in pure clojure. Not actually that interesting, just wanted the chance to try out klipse.
(ns example.silly-csv
(:require
[clojure.string :as string]))
(def csv
[["name" "age" "occupation" "gender"]
["Peter Pan" 312 "Lost Boy" "male"]
["Wendy Darling" 14 "Older Sister" "female"]
["Captain Hook" 330 "Pirate" "male"]
["Tinker Bell" nil "Fairy" "female"]])
(defn clean-str [s]
(pr-str (string/replace s "\n" "")))
(defn build-csv [xs]
(->> xs
(map (fn [xs] (map #(if (string? %) (clean-str %) %) xs))) ;; quote all strings
(map (partial string/join ",")) ;; seq of seq -> seq of strings
(string/join "\n"))) ;; seq of string -> string
(println (build-csv csv))
Datastore (Google App Engine) does not let you lock the database. So how do you map across every element in Datastore? Here is a very rough and tumble solution to that problem.
Assume you have a ndb.Model named Widget
Begin pagination using the following (note that Widget is case sensitive)
curl https://example-domain.appspot.com/paginate/Widget
# => {'keys': [<URLSAFEKEYS>], 'cursor': <CURSOR_VALUE>}`.
Use <CURSOR_VALUE> to continue pagination across all Widget's
curl https://example-domain.appspot.com/paginate/Widget/<CURSOR_VALUE>
Him: "Another museum on it's way..."
Me: "What?"
Him: "I mean, if you had an atomic aircraft, where would you park it?"
Me: ... <few seconds of though> ... "Area 51?"
Him: Momentary shock registers on his face, skuddles/crab walks away.
Just a random conversation with some of the fairly obviously tweaking tenants in my apartment...
I have never been much of an academic. In high school, all my friends were accelerated 1 year and allowed to test out of algebra 2; my scores were too low to allow me to skip it. Not wanting to be left behind, I resolved to take algebra II over summer.
That was a mistake.
That Summer I took algebra II with some laughably bad students at an inner city school. It was surreal. We would spend 4 hours a day in class, doing almost no real learning. I believe one kid was actively jerking off in the back of the room. One girl was pregnant and was taking life advice from another teen mother. By the end, we had covered maybe 3 out of 15 chapters. It was a complete failure. Somehow everyone who showed up passed. I later heard that Texas had so many "super seniors" clogging up the system that they created summer classes like this which were guaranteed passes; the goal was not education, the goal was to move people out of the system.
Like an idiot, I then took my "pass" in algebra II to my own school. I was happy, I could stay with my friends! Mathematically, things quickly fell apart. I realized that I was in over my head. The prospect of admitting that I couldn't hack it was even worse than my previous fear of being left behind (teen logic at its finest). For the next 3 years, rather than understand anything, I built elaborate workarounds to avoid exposing my ignorance. I didn't know how to actually solve most problems, I did however understand that my TI-83+ calculator could approximate the solution to most everything. With a little bit of flourish I could provide something that looked like I worked through a problem, despite the fact that the only thing I really had was a solution and an understanding of my calculator.
I graduated missing around 4 years of high school mathematics.
I feel like failing to understand some of the basic concepts in Algebra II substantially retarded my progress in mathematics. I lacked the basics that were necessary to move forward.
The plural of anecdote is not data. With that said, this video resonates with me. I like the idea of mathematics being a small graph of deeply connected nodes. Failing to understand one of the axiomatic/deeply-networked nodes can make understanding the interconnected nodes very difficult.
Contrast this to history with its much larger number of nodes. These nodes are interconnected, but not as dependent on each other. They might provide context or contrast relative to one another, but they are not required for understanding.
I though this was an interesting point.
I found the following intriguing because it unified the notion of habits and the notion of self. I have always viewed my habits as external things, there is me and then then there are my habits. Habits are something external to me. "I am attempting to practice the guitar every day." "I am attempting to give up eating dessert every meal." I view habits as something outside of myself; something I do with willpower.
It is a powerful shift in perception to consider that you are a collection of habits. That the emergent notion of you is a complex interweaving of habits; some so fundamental that you have "subsumed" them into your definition of self.
I find it comforting to consider that all reactions to the world are just a matter of habits. Skills are habits that help you react properly to the world. Addictions are habits that have become too ingrained and lack nuance. All problems can be tackled by thinking of them as habits that need to be internalized (or broken) to allow you to get to your desired outcome.

A "what if" study of a fully connected world.
The central premise of 2017's "The Circle" is that the world has been fully connected through a network of always on, always watching, tiny, cheap, inocuous cameras.
It is technically sci-fi, though all the elements I observed are more than reasonable. More a matter of minitiuarization and falling hardware prices than actual technological breakthroughs.
I am very forgiving of things that cause me to change my perception, or open me to a new way of thinking. Did this movie have flaws? Absolutely. I'll get to those later. Let's talk about what it did well.
Emma Watson went through the stages of acceptance of an omnipotent society in an extremely collapsed timeline. What she did in a matter of months most people in developed nations are still aclimatizing to.
At one point Tom Hanks turns to her and gets her to "admit" that having experiences that you do not share with others is a form of theft. A form of emotional hording. At this moment in history, such an idea seems ludicrous. Almost perverse. Only celebrities and politicians have no right to privacy? Right?
I don't know.
I am not sure people 15 years from now will agree. How would someone from 15 years ago feel about selfie sticks? Snapchats of your dinner? Tweeting by politicians. Sexting. Facebook friends. Online Dating. Etc. Probably seems pretty ludicrous. Inhuman. Disconnected. Shallow. And yet, here we are.
Yeah, a lot of great things could occur. From the trivial to the fundamental.
Immediate reactions as machines watching our feeds recognize violence, injury, and danger and automatically notify and dispatch emergency responders.
Automatically and constantly dealing with fundamental weaknesses in society. Making sure that people don't get too isolated; too lonely. That people who exhibit sighs of mental disorders are regularly visited by health care professionals. Checking in on everyone with the (literal) persistence of a machine.
Violent crime does not make sense. Only physical crime that would still exist would be crimes of passion. Crimes that law enforcement was incapable of negating due to being sudden and unexpected. Although tragic, when a violent crime occurs, it would almost always be evident what occured and who was responsible.
Ask yourself? How much would you be willing to give up for such a world?
Movie makes a big deal about having a open (probably puppet) politician.
Here is one that I fully agree with. Prisons should be places that have cameras literally everywhere. In a high risk environment like a prison, I would happily trade my privacy for the knowledge that I am not going to be raped or assaulted.
This is already occuring. I forsee that in the next decade, the cost of insuring a police officer who refuses to wear (and use) a full body camera will be so high that departments will require police officers to have them running at all times.
Heh, I don't know. It would be interesting. Could most of the goverment be entirely opened? Would we allow "black boxes" like the CIA, FBI, NSA, etc? Would it turn out that backroom negotiations by our nations actually do benefit citizens more than they hurt? Would it cut corruption? Hard to say.
Yes, it has some serious flaws. But it gives you things to think about, and it honestly resolved the ending in a rather novel way. Rather than fighting the system, Emma Watson instead fully opens and embraces it. Basically making the case that if such a system exist, it needs to be placed under open rather closed controlers.
If you are going to have a system that is going to audit the world, then you must audit everyone in control of that system.
I went to clojurewest 2017 in Portland, Oregon. Good conference, lots of good information. Here are my observations, my notes, and a few pictures.
The conference was well managed. The talks were mosty interesting. The community continues to be friendly, open, and inclusive.
I wish there had been a few more "This is something I worked on that is very cool" type presentations, but you can't force those. Maybe there just wasn't as much cool stuff in 2017 compared to previous years. I guess every year can't be a "Clojure now compiles to javascript" or "core.async, use it" kind of year.
Portland is an interesting city. I didn't actually realize how small and walkable the core of the city is. In San Francisco, I have practially forgotten what it is to see families with kids on the street. It is certainly a nice place to visit. I liked the eating, the literary/craft tradition, the beer, and the people. It did have a number of younger homeless (kind of reminded me of Berkeley). It did have the feeling of a place that gets a lot of tourist (that can be tiring when you live there). I could see myself being very happy there, but I haven't heard a whole lot about the tech scene there. The public transportation is excellent and the lack of traffic is a pleasure. I don't know if it is a place to "see and be seen" but it certainly felt like a place to "live and let live". Kind of like the kind of "weird" that Austin aspires to.
solver-aided toolI took a 3 week trip to Japan from January 21 from February 12. I didn't have an itinerary, exploring as I saw fit and moving on when the mood struck me. Through the trip, I stayed in Tokyo, Tanabechuo, Kyoto, Osaka, Hiroshima, and Nagasaki.
I made several purchases before the trip:
The Japan Rail Pass (Green) is a Japan Rail (JR) pass that lets you ride most trains in Japan. My most "Japan specific" purchase that I would recommend to anyone. The (Green) designation means that it is business class (effectively), which means better seats and reservations. I bought the 21 day pass for $700.
Google Fi worked out normally. When I landed in Japan it told me that I would pay the standard $10/gig data rate and I believe $0.20/minute. Use your Wifi call if at all possible. Coverage seemed pretty good everywhere. Was able to use it on most of the high speed trains, spotty between Hiroshima and Nagasaki.
The Tortuga Outbreaker 35L was a altogether worthwhile purchase. Most compeling features is the ability to open it fully (not just from the top) like a conventional suitcase. You don't think about it, but not having to pack and unpack your backpack is a real time saver. I also thought the compartment for the laptop with easy access was convenient, as you will be taking that out on a regular basis throughout the day.
Other feature true of the 35L is that it counts as cary on in all airlines (even small planes). It is convenient not having to wait for any lugage after a long day of travel.
I used hostelworld.com. Easy to use website. Clean interface. I would book my next hostel 5 days before actually arriving. Never had a single issue. They take I think like 10% as deposit on booking, you then pay the rest upon arrival at the hostel.
I recently bought some Bose QuietComfort 35 headphones for work. This is my best product purchase of 2016. They made air travel more pleasant (shut that baby up!). They made watching the landscape flow by on the trains more moody. They gave me a slight taste of home when I am feeling a bit lonely. Seriously. Great. Headphones.
And now, without further ado, I present... a silly number of pictures:
Google App Engine does not allow for a SCAN like operation on a kind. Although this is a hard limit, it can be worked around with some thought. This is my generic solution.
GAE does not allow locking of the database. GAE does not even allow for locking of a kind. Transactions are the only locking mechanism in GAE, and they are limited to the entity groups within the transaction.
The closest GAE has to a scan (a lock of a kind, where every element of that kind is processed) is a GAE Query; which is a filtered iterator. Queries are "best effort" and are not guaranteed to reflect the current state of the database. Still, they are the best you have.
Using a iterator would be a O(N) cost, where N is the number of rows of a GAE kind . GAE is all about scaling dynamically. It would be nice if we could divide up the work of processing every row of a kind.
I have written a system that lets you (probabilistically) process every entity of a kind. It does not hard guarantee that every entity will be processed, but with a sufficient number of retries it does probabilistically guarantee that they after entity has been processed.
scan(
'<kind>', # the Datastore kind that you want to scan
retries=1, # a non negative integer, default 1
retry-fx=lambda i: i**2, # i is the retry count, i=0 is always immediate
max-retries=2, # a non negative integer, default 2
)
The handler-path will be called with the urlsafe() key of every entity of 'kind' <kind>. Specifically /<handler-path>/<urlsafekey> will be called for every <kind> entity. If handler-path returns 2xx, it is considered a success; otherwise it is a failure. Failure will cause the task to be re-enqueued in retry-fx(retry-count) seconds.
Assume there are 3 Dog entities in the database with urlsafekey's of "rottweiler", "poodle", and "dalmation". Then,
from scanner import scan
scan('Dog', "/add/pedigree")
will cause the following endpoints to be called.
/add/pedigree/rottweiler/add/pedigree/poodle/add/pedigree/dalmationThis isn't much of a big deal when we are talking about 3 entities. But it is pretty useful when we are talking about thousands or millions of entities. Thanks to this "soft scan" we have the ability to have a function (a endpoint) called on every item of a particular kind in the datastore.
This week I wrote an addition to
gaend that automatically causes every ndb.Model entity to automagically be persisted to Elasticsearch.
Datastore (the database technology that powers Google App Engine) has a number of great features.
Although datastore is perfect as a Key/Value store that allows transactions and limited queries, it does have its limitations.
One effect of these limits is that it can difficult to do things like aggregation on tables. You should use the proper tool for the desired outcome.
Datastore is great as a key/value store (with transactions).
Elasticsearch is great at doing aggregation.
Datastore is structured (typed) data. Everything that goes into Elasticsearch must be JSON data. Structured data can be fairly easily transformed into JSON data. You see where I am going with this?
This extension to gaend does successfully convert any Datastore data into Elasticsearch. You should look at your table in Datastore and perhaps consider whether you need to submit a custom mapping for Elasticsearch. If unspecified, Elasticsearch will generate a mapping for you based on the submitted JSON document. For tables made up of "primitive" data, the dynamically generated mapping is usually sufficient. Still, know that you can override the dynamic in the event that you have complex, deeply nested, or large types of data.
gaend is a easy way to get Restful endpoints
on Google App Engine for Python. It
builds endpoints directly from your ndb.Model classes.
This is my first Open Source Python library. It was fun to write and it helped me internalize some of the driving philosophies behind Python. Though there were many learnings, I think the thing I got the most was that Python favors complexity being hidden even at the cost of understanding. In reality, most Python code is NOT simple. However, most python libraries go to great lengths to hide complexity from the user. At some level, I feel that this is a disservice as it risks keeping the user in a permanently "infantile" state. On the other hand, it means that things "just work" and you probably aren't going to cut yourself on a sharp corner.
Contrast this to Clojure. In Clojure, a library should ideally be made of a collection of simple parts. These parts should have no state. It could be bias, but it seems like it is usually easier to understand the internal workings of a random Clojure library vs a random Python library.
The difference though comes down to usage. In Python, a library can often be used with one simple function call. Furthermore, there is usually one blessed library for most problems. Clojure however often requires you to put together "found art" from different libraries. Putting together multiple parts of many libraries to get to a solution. This is the ultimate in flexibility and expressiveness, but it also means that it can be comparatively difficult to get started.
Beyond the project itself, I also enjoyed writing the documentation. It can be kind of fun to make believe that you are a user of your software with no context. It can be challenging to try to picture what your own software looks like to a complete stranger. It is actually a rather difficult job and I gained some respect for people who spend most of their lives writing technical documentation.
Your application needs a TOKEN in order to access your Vault server. How do you get the TOKEN to the application server?
From here on we will be calling your Vault-server-in-the-cloud simply 'Vault'
Vault is a tool for managing secrets. Vault act as a key/value store where the keys are paths and the values are dictionaries written at those paths. Vault allows for auditing, roles, authentication, and much more.
Vault application access your secrets through a TOKEN. A TOKEN is built from a tuple of (ROLE_ID, SECRET_NONCE). You likely have a single ROLE_ID per application. Your SECRET_NONCE is a cryptographic nonce that is exchanged with the ROLE_ID to get a TOKEN. As a nonce, your SECRET_NONCE may only be exchanged for a TOKEN at most one time.
Once you application has a TOKEN it may then make request to your Vault server. A TOKEN will expire N minutes from its last refresh or initialization. So to keep a TOKEN valid, the application will need to tell Vault at least once every N minutes to refresh (extend) the TOKEN. Your Token will always have a lifetime of (last refresh time) + N. If your server goes down, the TOKEN will soon expire as the application will no longer extend the TOKEN lifetime.
We have all done it, it is not a good idea. There definitely should be no secrets in your source code. Secrets in your source code means you cannot share your code without a full audit. Ugh
Environment variables are better. It still requires that you ask questions about what secrets exist at what locations when you are considering your infrastructure. Contrast this to having secrets in one place (Vault). If you are considering Vault then you have likely decided that environment variables are not a good enough solution, so I will not spend any more time attacking them.
TOKEN as part of your deploymentThe equivalent of putting ALL your secrets in your application. Anyone who gets access to the TOKEN (through source or environment variables) can access Vault as the application.
(ROLE_ID,SECRET_NONCE) as part of your deploymentThis is sound under some strictly ordered conditions. We must be certain that the application is the first to exchange (ROLE_ID, SECRET_NONCE) for the TOKEN. Because SECRET_NONCE is a nonce, we don't need to worry about subsequent request, only the first one wins. However, if Alice is able to get the SECRET_NONCE and exchange it for a TOKEN before our application, Alice would now have access to all of the applications secrets. Dependent order in security does not sound like a good idea.
(ROLE_ID,SECRET_NONCE) in a application endpointAfter deployment of your app, call an endpoint on it and pass in a (ROLE_ID,SECRET_NONCE). Your application will then exchange your (ROLE_ID,SECRET_NONCE) for a TOKEN. This alleviates the timing concerns of the previous solution while still having zero secrets in code or environment variables. This endpoint can be entirely open. Vault will refuse to provide a TOKEN for a (ROLE_ID, SECRET_NONCE) that it did not issue.
I have written a demo project that implements a (ROLE_ID,SECRET_NONCE) endpoint. After the very first deployment of the app, it requires that you "light the pilot light" by posting a (ROLE_ID, SECRET_NONCE) that may be use to access Vault. So, the steps are.
/vault with your (ROLE_ID, SECRET_NONCE).TOKEN, make another curl POST request with a new secret, expire the old TOKEN.Instructions are provided in the README.
If you find that you're spending almost all your time on theory, start turning some attention to practical things; it will improve your theories. If you find that you're spending almost all your time on practice, start turning some attention to theoretical things; it will improve your practice. - Donal Knuth
I have an addiction to infrastructure. While programing a solution, I eventually find that I am working on things that do not directly contribute to solving the problem. From a rational/detached/post-fact perspective, I know that this is a huge source of waste. Funny, I never seem to notice this at the time.
I do not have a problem with motivation. If anything, I do not value my time as much as I should. Let us leave that for another rant.
I do not have a problem with my programming skill set. It isn't lack of skill that impedes my ability to deliver. Not to say that I have nothing that needs improvement. My mathematics is weak, I never really got SQL, my Git skill are passable but nothing extroardinary, I am average at using the terminal, I type poorly, etc... There are a huge number of things I could learn and improve on, but non of those things stop me from being able to build solutions.
I do spend an embarassing amount of time trying to get things perfect.
I do spend far too much energy trying to deal with eventualities that never emerge.
I do spend mental focus on vanity features that I hope to someday reveal to the world, blinding it with my genius.
Meanwhile, the actual business problem sits untouched.
Speed is king. I am beginning to believe that this may be true of most things in life. I think the shortest way to get good at something is to become skilled enough to do it quickly. This seems to be true for artist and craftmen, so why shouldn't it be true for programmers?
It seems to me that there are at least 3 elements to speed.
Getting seperate works to come together harmoniously. This is one of the main differences between a good cook and a chef. A good cook often does one thing at a time in a linear fashion. A chef is often doing 3 or 4 things concurrently, connecting them so that they are all completed at the right moment.
Actual context switching in programming is almost certainly a detriment. However, the ability to know the order that things need to be acomplished to minimize downtime is a real skill. Huge numbers of books have been written on software estimation. I am not going to say anything about that. I am going to say that if you have done a task 10 times and it took an average of 15 minutes, then you can probably estimate that the 11th time will take around 15 minutes. This means that you can probably fit this task in a 20 minute lull in your schedule. This makes you faster.
People who have speed aren't always fast. Sometimes they are just more efficient. A good example of this is beginner vs advanced guitarist. Beginner guitarist almost always move significantly more than needed to pick a note. An advanced guitarist does a minimal move. Guess who is going to pick faster (as well as tire more slowly)?
A large part of context switching in programming is familiarizing yourself with the codebase. If you are reusing a codebase that you have previously used, you can dramatically reduce the context switch of familiarizing yourself. This makes you faster.
A measure of the number of task you can perform per unit time. This mostly has to do with repetition. You can perform a task more quickly if you have done a similar task in recent memory. Examples of this are evident.
Programmers may relate to this through the notion of Flow. When you don't have to stop and question how to do something, but can focus simply on what you are doing. This makes you faster as well as less succeptible to distraction.
Simple. Don't work on the big until you can quickly do the small. That is all I got.
Note: I am picturing a small project being ~10 hours. A medium project being ~50 hours. A large project being 200+ hours.
I think it is pretty natural to pick similar projects. Especially if you are trying to get "faster". This should allow you to focus on increasing speed (specifically through Actions Per Minute).
Step 3 & 4 are designed to allow you to address persistent difficulties in code by writting infrastructure. This is very different than my current method of writting infrastructure though as:
Being able to do something quickly and well increases confidence. Computers don't care about confidence, but humans do. If you are reading this, you are likely human. As a human you should look after your mental well being. Being confident in a skill could open a lot of doors...