### I got 99 problems…

Ooooh boy. This is gonna be huge.

It’s 2 am in the morning and I’ve just decided to try solving the 99 Haskell Problems. I’ve tried to grok Haskell on and off for at least three times now and I still haven’t gotten as far as monads. That’s a great thing, because I’m getting fed up at not being able to code every day and Haskell is as good as it’s gonna get.

So let’s get started.

### Problem 01 (2016-04-28 02:07-02:40)

The first problem is to return the tail of a list. Armed with:

ghc main.hs
./main

…I get to work. Now I haven’t seen Haskell in n years so it’s gonna take me a while to do this. Let’s see:

main = do
print (last [1, 2, 3, 4]) -- 4
print (last ['x','y','z']) -- 'z'

That gave me a headache. Moving on…

### Problem 02 (2016-04-28 02:40-02:47)

runhaskell main.hs

…and will be using it for the remainder of this post.

Anyway, the current task is to get the penultimate element from a list. Let’s see:

main = do
print $last$ init [1..4] -- 3
print $last$ init ['a'..'z'] -- 'y'

…and we’re done.

### Problem 03 (2016-04-28 02:47-02:56)

The current problem is indexing a list (starting from 1). Let’s see:

main = do
print $[1, 2, 3] !! (2-1) -- 2 print$ "haskell" !! (5-1) -- 'e'

This is borderline cheating but, hey, whatever works right?

### Problem 04 (2016-04-28 02:56-03:09)

Okay, let’s try and shake things up. From now on, I am restricting my use of Prelude to the following functions: map, filter, foldl’ (the non-lazy version of foldl), and foldr. Hopefully this teaches me integrity and character. The current problem is to find the length of a list. This should be easy:

main = do
print $(foldr (\x acc -> acc + 1) 0 [123, 456, 789]) -- 3 print$ (foldr (\x acc -> acc + 1) 0 "Hello, world!") -- 13

My time is wasted editing things.

### Problem 05 (2016-04-28 03:12-03:15)

The current problem is to reverse a list:

_reverse [] = []
_reverse (x:xs) = (_reverse xs) ++ [x]

main = do
print $_reverse "A man, a plan, a canal, panama!" -- "!amanap ,lanac a ,nalp a ,nam A" print$ _reverse [1,2,3,4] -- [4,3,2,1]

That was longer than expected. I wonder if this can be done using anonymous functions. Hmm…

EDIT (2016-04-28 03:18):

main = do
print $foldr (\x acc -> acc ++ [x]) [] "A man, a plan, a canal, panama!" print$ foldr (\x acc -> acc ++ [x]) [] [1,2,3,4]

Uses anonymous functions but a bit shorter than the original one.

I’m going to take a nap and resume this later.

### Problem 06 (2016-04-29 08:27-08:31)

Slept in yesterday. Still feel like crap. Anyway, the current problem wants me to decide whether or not a given string is a palindrome:

main = do
print $[1,2,3] == (foldr (\x acc -> acc ++ [x]) [] [1,2,3]) -- False print$ "madamimadam" == (foldr (\x acc -> acc ++ [x]) [] "madamimadam") -- True
print [1,2,4,8,16,8,4,2,1] == (foldr (\x acc -> acc ++ [x]) [] [1,2,4,8,16,8,4,2,1]) -- True These lines are getting longer. ### A quick aside Haskell on Arch Linux is hell on Earth. There exists something called “cabal dependency hell” which I will neglect to explain because I don’t really understand how one of the most sophisticated group of hackers on Earth has not yet engineered a package manager that Simply Works. Lone wolf syndrome? Not qualified enough to comment on it. Nevertheless, there’s a way out of the pit and it starts when you cd into your project directory and do: # Generates .cabal file used by cabal build cabal init # Initialises sandbox, installs necessary # packages, and builds your project cabal sandbox init cabal install --only-dependencies cabal build And when you want to install a particular package in the sandbox, just do: cabal install --require-sandbox <package-name> ### Definitions Palindrome a word/string/list that’s the same forwards and backwards; e.g., “timtom motmit” Advertisements # Hall of horrors: GearVR The GearVR is a fantastic VR headset. It’s mobile, it’s got really good rotational tracking (in that I’ve never noticed it lag) and its screen blows away the DK2. So what’s this page for? Well, I bought SQRT(72)’s GearVR Innovator Edition for the S6 last Christmas, 2015, and did diddly-squat with it since then. Nevertheless, I’ve learned a few things about it which might prove useful to readers from the future like you. Here I used the following: • Unity3D 5.3.4f1 • Android SDK Tools 25.1.3 • Android SDK Platform-Tools 23.1 • GearVR Service 2.4.29 • GearVR System 1.0.10 • Android Marshmallow 6.0.1 Hopefully that covers everything. ### In which they think they know better than to let you know what’s wrong [insert app name here] has closed unexpectedly. I harbor a disproportionate amount of hatred for people who do not explain what’s wrong in error messages. How difficult is it to tell you something you can Google at the very least? Anyway, to rectify this we have to do a couple of things. One of the greatest invention of mankind is the read-print-eval loop. Having to build your project in Unity, putting the resulting .apk in your phone, putting your phone on your GearVR, then wearing it gets old pretty quick. So what we want is get out of paper-tape-land and remove the middleman. How do we do that? 1. In your Android device, go to Settings -> Application Manager -> Gear VR Service -> Manage Storage. 2. Tap on VR Service Version repeatedly until the Developer Mode option appears. 3. Enable Developer Mode. You ought to see your screen flicker. Why is this so? It seems the S6’s screen has a low-persistence mode and this option enables it amongst other things (including CPU/GPU throttling issues1). Nevertheless, you will find it wonderful that you can now deploy to your S6 directly from Unity! Just hit File -> Build & Run and (assuming you’ve got your settings down pat) it will update the app on your phone for you and launch it in stereo mode without the GearVR. [insert adb stuff here] ### In which you must sign all papers In my short stint pushing things to the GearVR, this probably counts as the most common — and most annoying error — I have found. Thread priority security exception. Make sure the APK is signed. What this means is that you haven’t configured your “osig” properly. What is an “osig”, you ask? Fig. 1: Nightmare fuel (though the background has improved). An osig file is what you get when you put your phone’s serial number here. It’s something you have to put in your app so that you can use your GearVR with your phone. Now I don’t know what the hell Oculus was thinking when they designed this system but this osig business means you can’t show your own apps to your friends without ruffling through their phones first. Only they have the power to make your .apks run on any GearVR device. What’s up with that? ### Definitions DK2, Oculus Rift the second Rift development kit from Oculus GearVR the first decent mobile VR headset by Samsung Hall of horrors series where I figure out others’ abominations (as charitably as I can wince) Read-print-eval loop an interactive I/O session with your favourite programming language S6, Samsung Galaxy Samsung’s flagship phone from 2015 March to 2016 February Samsung a South Korean tech chaebol — probably THE South Korean chaebol as of 2016-04-29 Stereo mode the iconic fisheye splitscreen found in early recordings of VR SQRT(72) see A self-centered history of neo-VR 1. See this post on Reddit. # On keeping things I have a wiki. Yes, the same kind you used in high school to populate the bibliography section of your paper on 17th-century perfumery. But mine’s about — well, me — and it saves me a lot of time and effort keeping track of all the things I want to do, all the games I want to experience or the things I want to pawn off some store’s grubby shelf. We make a lot of bits just moving around by ourselves everyday and it’s a darn shame we don’t use that data as much as it should be. Your life has more regularity in it than you think. Think about this: how do you brush your teeth? Do you brush your front teeth first or your molars? When was the last time you shuffled that order? Humans are creatures of routine but that isn’t necessarily a bad thing. The way you learn things is that an activity naturally has to take up space in your short-term memory the first few times you do it. You have to be aware of the little things, the motion of your fingers, the flow of the argument. But after doing it a few times, something called “automaticity” takes over and things become less involved. At this point you are now able to talk a bit while driving or tell a joke while playing the horrendous part of Chopin’s Minute Waltz1. I’m a huge fan of spreadsheets so I pour as much of my life into them as possible. In my wiki I have spreadsheets for the following: • games I need to play before I die • films and series I need to see in order to become a Cultured Citizen • textbooks/monographs written by smart people, usually dead ones • books about building societies or destroying them …and a few things that ought not be seen by the public. In fact, I’d wager the spreadsheet-to-page ratio of my wiki is very close to one. Habits, wants, principles — all these regularities are points on our map of ourselves. And therein lies the advantage of having your life on paper: you can see your life from above. You can plan routes, mark dangerous spots, and if need be tear off a few parts to make way for new territory. Collecting data about oneself and splaying it out on a table (or in my case on scriptable, 21st-century ones) is the modern fulfillment of Socrates’ examined life 2. But something’s amiss about my wiki. Very early on, I made the decision of using Google Sheets to power my hard-on for tabulation. This was a matter of convenience over posterity: it’s almost never a good idea to introduce external dependencies on long-term projects. And so I worry that when Don’t Be Evil falls, my entire map will slide off the table. ### (I) Jason Scott is a modern-day hero. On the 15th of August 2015, he drove 230 miles to a warehouse to save 25 000 manuals3 from the dump. In a world where more information is generated every second than can be read in one’s lifetime [citation needed], posterity is a mere afterthought. The firehose of information that violates our tiny mouths every day is hard enough to deal with, so it’s not a surprise that only very few people are able to think about where and how to keep it. Going completely digital is a black hole waiting to happen. Electrons can only stay in the bits of hard drives for so long and, in the flash memory that is trying to replace them, even shorter. And physical decay is not the only problem. We put our data in fragile boxes, file formats that seldom describe themselves 4. If everyone suddenly dropped dead right now, the (decidedly non-human) archaeologists of tomorrow would be flabbergasted of the civilisation that suddenly started talking in code around the same time it invented plastic. I mentioned Jason Scott because a similar bomb dropped near me and I wasn’t able to stop it. As a part of the oldest academic organisation in University X, I had a harrowing experience trying — and failing — to save a couple of important documents from the shredder. You see, the problem with all student-run organisations I know is that they’re always a few years away from the gutter. Three or four years isn’t enough to pass on all the aspects of a culture. Unless its founders had enough foresight to put a system in place to ensure its complete transmission, it is bound to get lost, decay or otherwise morph into an unrecognisable entropic mess by the time they invite you to their homecomings. One aspect of Organisation X that has survived the second law of thermodynamics is the keeping of almost-verbatim meeting notes in log books. It’s the job of the secretary to record every nook and cranny of discussions during assemblies. We had a cabinet of such records up to the 80’s and it contained, amongst various doodles and runaway calculations, a record of who votes what on which issues. And what can you use that information for? That’s right. Making lists of your members throughout the years. So what happened to those logbooks? Well, every first Monday of the month, Organisation X requires its members to reduce the entropy of its club room. In University X, Mondays mean lab class so I had to fidget in a dark room for three hours straight while they were forming dead skin cells into mounds. An observation was made that the cabinet used by the people who get to decide on matters of membership was almost full due in great part to the presence of a couple of cough-inducing notebooks. A quick round of discussion later and those notebooks were put on a bus to the wonderful land of Your Local Scrapyard. I had plans for those notebooks. I was going to hack a makeshift scanner and learn how to digitise an analog corpus. It would have been a fun project for the school break. But no. I must have made a few CO2 particles near-luminal because I heard loud and angry explosions behind me. When I arrived at the scrapyard, it was too late: the shredder had won and the annals of Organisation X was headed to the mills to become some sweaty old man’s porn mag. ### Definitions Automaticity the phenomenon where doing something repeatedly makes you have to think less in order to do it Cultured Citizen you know what this means Don’t Be Evil Google’s official motto Jason Scott archivist who’s part of the venerable archive.org Organisation X the only school organisation I legitimately joined in college University X the university I went to 1. Not a pianist but Chopin is famous for being difficult. 2. Don’t take my word on this. Take Wikiquote’s 3. This post, from the man himself. 4. There has been some progress on this front in the form of PDF/A, NetCDF, and HDF5 (sans how monolithic it appears). # A self-centered history of neo-VR ### On the 9th of May 2015 …my stomach was grumbling. Thirty-one people, plus or minus twenty, had just been assaulted by funky-looking boxes and I still hadn’t gotten myself a slice of that goddamn pizza. I removed myself from the GTX 970-powered terminal in front of me and waited to get a word in edgewise with a particularly candid personality. Let’s call him SQRT(72). I stood there, anxious to shake hands with a person I should have met a year before then. On the head of the person he’s talking to was a GearVR: Fig. 1: The Samsung GearVR Innovator Edition. Credits to Katie Collins 1. The GearVR came out with nary a moment of calm, particularly because Midas (i.e., John Carmack) himself gave it a personal touch. [insert brief GearVR history here] So there I was, talking to SQRT(72) about all the fun things we could have done if we had met each other offline sooner. SQRT(72) and I met on Reddit with two other folks, whom we shall call The Non-Orbiting Rodent and Pomade Power. Let me tell you a few things about them: • SQRT(72) is the most financially astute businessguy I know. He’s the sort of person who would count the scratches on his phone so he can sell it near its original price later on. Plus he’s a Virtual Boy and Apple II veteran. • TNOR (for short) was the first one to nab a DK2 in the Philippines. Accordingly, he claims to have demoed the darned thing at ToyConPH 2014 to “around 300 people”. • Pomade Power is the only actual game dev in our ragtag. He’s also the first one to have put on the PSVR, which I still haven’t tried as of this writing (2016-04-05). These folks and I comprise Pinoy Rifters, one of the earliest neo-VR groups in the Philippines. So where were me and SQRT(72) on that 9th of May? We were attending this event: Fig. 2: VR/AR Manila Meetup. Sorry for the compression artifacts. VR Philippines asked to borrow my DK1 and I happily obliged. I wasn’t prepared for the barrage of demoees, however, since before the meetup I’ve demoed my DK1 to perhaps less than ten people. Little did I know it was an omen of things yet to come. ### A nexus of sorts I liked the atmosphere of that first meetup so much I joined its organisers. VR Philippines was the brainchild of people whom we shall call Will It Blender (WIB) and Chromolungma (Chromo). Back then, they were really the only ones actually doing things at VRPH. I figured they were a decent set of folks so I took the plunge with them. We met a few times at CBTL to talk about what we’re doing and where we’re headed. One of the things that came out of those conversations was the idea of becoming a nexus. Here’s the thing: people remember only the firsts and the bests. We certainly weren’t the first, so we were left with no choice. VRPH had to become the center of activity of VR/AR in this country or else we will become dust in the wind. It was an incisive existential point that takes a bit of neuroticism to come up with: after all, you don’t take the driver’s seat if you trust in others’ ability to drive. So what exactly does becoming a nexus entail? For starters, Chromo and I share a decent amount of aesthetic sense. And that sense is a constant ringing that tells us to keep looking for a coherent style we can call our own, kind of like how the French have their own way of making films. Being at the center of it all allows us to follow certain kinds of content and promote them according to our own tastes. It also carries another important advantage: it keeps us in the loop. If you’re the center of everyone’s conversation, then you’re bound to hear about everything. In a race as fast as this one, a four-month hiatus is the same as being in the sidelines. We’re not the only ones in this race, however. On the 25th of July 2015, the Asia-Pacific Virtual Network held a synchronised meetup spanning eight cities from Istanbul to Brisbane. ### Alien blue, or how to sell VR on TV Our local version was well-attended, with over 100 folks having come and went. It’s interesting to note that even this early on in our timeline, game studios here such as Synergy88 were already trying to get their grips on VR. I am Cardboard (the folks who sell those elegant black Cardboards) was also there, as was Narra3D (a co-founder of which will become important later on in our story). But the most interesting project shown then was from a person we shall call The Shopkeeper. The Shopkeeper is a stout fellow with deep green eyes and he was the reason Chromo and WIB met in real life. He brought with him a pair of haptic gloves, something that no one else in the country seemed to be doing at the time. This is an interesting point because electronics here is cheap. Manufacturing anything here, from wood to plastic to metal is dirt cheap compared to other countries. So why the dearth of hardware projects? I don’t know why that is but I think it also has something to do with white-collar jobs being the default choice of almost everyone. Here, anyone with half-decent schooling wants a desk job with bosses to please while the rest are either left to tinker with cars or washing machines or are busy cooking themselves to death in a gimmicky pop-up restaurant. Anyway, The Shopkeeper was put on the spot by a group of journalists and reporters from national TV. However, his prototype was still very rough and the IMUs and servos were yet to come. So when it was time to shoot a reel of the gloves, the hostess of the show (i.e., the trope-namer of this section) had no choice but to fake it, which I think was quite unfair to The Shopkeeper. Fig. 3: Alien Blue, which upon further inspection turns out to have been black. Also shown is an I Am Cardboard headset. Credits to VR Philippines[2]. Fig. 4: The Shopkeeper’s NeoHaptic Gloves, one real, one digital. ### The Great Depression Chromo, WIB, and I went home in a taxi with HMDs and hulking PCs in tow. In our CBTL meetings, we promised ourselves an event at least as big as the APVRN meetup every quarter. I had other ideas for VRPH (in fact, it’s my job to have other ideas for VRPH). People here have to make things, not just try them on. In fact, I recall Chromo having a rather heated exchange with someone about the fact that we didn’t restrict our VR showcase at the APVRN meetup to local content. How the hell were we going to do that if the vast majority of local content back then were 40-minute Unity3D prototypes that look and run like your dog hooking up with a tree? I think it’s high time I misquote Hermann Weyl here: “We have always tried to unite what works with what was made here, but when we had to choose one or the other, we usually chose what works.” Not saying his/her game was shitty though. In fact, it was one of the better games out there. Perhaps he/she was just mind-projecting that everyone else must have approached their game with the same guile he/she had shown. After APVRN, we were invited to a STEM fair in UP Los Baños. I don’t have a story to tell you because I wasn’t there, but I do know two things: First is that a person whom we shall call The Giving Tree was a student in UP Los Baños then. This, coupled with the fact that he was one of the most active members of the group, led to him being roped into helping Chromo and WIB during the STEM fair. Second is this: Fig. 5: Queing VR. Everyone and their mother loves children. Because of the overwhelmingly positive response of kids to being shown VR in Cardboard and the DK1, we were invited to TV segment which I’ll talk about later. ### Definitions APVRN Asia-Pacific Virtual Reality Network DK1 Oculus Rift DK1; the headset that started it all (or neo-VR, at least) DK2 Oculus Rift DK2; the first neo-VR headset to have proper positional tracking CBTL The Coffee Bean & Tea Leaf; the de facto VRPH meet up venue Chibot Delfin Joseph Baylon, organiser at VR Philippines; 3D artist extraordinaire Chromo Chromolungma/Cristopher David, co-founder of VR Philippines; so named for his excellent colour sense and his quirky username (which I shall omit for privacy reasons) Giving Tree, The Adrian Vincent Tayag, organiser at VR Philippines; so named because he has given more demos to people than anyone in VRPH Haptic gloves gloves which allow you to touch and feel objects in-game Mind projection fallacy when you confuse what you think with what there is MTBS3D Meant to be Seen 3D, a message board on stereoscopic 3D gaming and VR that’s dead to most of the neo-VR community Neo-VR the history of VR starting from the moment John Carmack noticed Palmer Luckey’s VR headset prototypes on the MTBS3D forums Pinoy Rifters one of the oldest neo-VR groups in the Philippines Pomade Power Matthew Valeriano, CTO at Figment Games and moustache enthusiast SQRT(72) Rene Canlas, master of everything that computes at Pointwest Technologies and hardcore early adopter Shopkeeper, The Guido Stercken, founder of NeoHaptic TNOR The Non-Orbiting Rodent/Lance Ong, first DK2 owner in the Philippines Unity3D the most indie-friendly game engine back then VRPH VR Philippines WIB Will It Blender/Gabriel Enriquez, co-founder of VR Philippines; so named for his Blender skills and iron will 1. From Wired Magazine. # Things I don’t understand: Bayes’ theorem ### In which I lay down foundations Probability is interesting to me for two reasons: • It’s useful. • It’s a generalisation of logic1. The problem is, I have never had any formal training in it. Not even in high school. So that leaves me in a bit of a limbo because I see understanding probability as one of the cornerstones of Good Thinking. This is my attempt at curing that. What I shall do is start from the axioms then prove theorems as I tackle classic problems. Which means three things: a) this page will be a work-in-progress indefinitely2, b) the vocabulary I will build here may not correspond to the standard one, and c) I’ll probably get things wrong a lot of times so this may not be the best page to cite in support of your Internet argument. Before we start, I’d like to introduce a rule and a notion. I won’t start from the very foundations of mathematics because that will just waste everyone’s time. But I really admire the rigor of the Bourbaki school (in great part because I’m still in my “rigorous phase”3). So I shall follow a simple rule: every assertion must have a proof or a reference to one. And to do that more efficiently I’ll borrow a notion from programming and “import” complete mathematical objects in this manner: IPT 1: (the algebra of sets) see Wikipedia Eventually, those external links should become internal ones. Right. Let’s get to work. Here are some definitions: DEF: (data point) a value (e.g., “red”, “42.4 seconds”) DEF: (data set) a set of data points DEF: (universe, the Universal Data Set) $\Omega$, or the data set containing all data sets DEF: (probability) the probability $P(E)$ of a data set $E$ is a real number associated with $E$ These are the basic building blocks of probability theory. As far as I know, probability theory is then completely axiomatised by the following three axioms (which come from A. Kolmogorov, according to Wikipedia): AXM 1: (“All probabilities are non-zero.”) $(\forall S \subseteq \Omega)(P(S) \geq 0)$ AXM 2: (“The probability of the Universal Data Set is 1.”) $P(\Omega) = 1$ AXM 3: (“The probabilities of disjoint data sets are additive.”) $(\forall E_1, E_2 \subseteq \Omega)( (E_1 \cap E_2 = \emptyset) => (P(E_1 \cup E_2) = P(E_1) + P(E_2)) )$ Using these we can already say a few basic facts about probabilities. THM 1: “The probability of the empty set is 0.” ($P(\emptyset) = 0$) \begin{aligned} &\rightsquigarrow \emptyset \cap \Omega = \emptyset \\ &\implies P(\emptyset \cup \Omega) = P(\Omega) = P(\emptyset) + P(\Omega) \\ &\implies P(\emptyset) = 0\\ &\Box \\ \end{aligned} THM 2: “The probability of the complement of a data set is one (1) minus the probability of the original.” ($P(A^c) = 1 - P(A)$) \begin{aligned} &\rightsquigarrow A \cap A^c = \emptyset \\ &\implies P(A \cup A^c) = P(\Omega) = 1 = P(A) + P(A^c)\\ &\implies P(A^c) = 1 - P(A) \\ &\Box \\ \end{aligned} (Can I just say how awful and tedious it is to write multi-line $\LaTeX$ in default WordPress?) What we have though is still too bare. It lacks flavour. So let’s define a few more things: DEF: (reduced universe) the reduced universe $\Omega_E$ of a data set E is the subset of the universe $\Omega$ where $E$ is true DEF: (joint probability) the probability $P(A \cap B)$, or the probability of both A and B being true DEF: (conditional probability) the probability $P(A|B) = \frac{P(A \cap B)}{P(B)}$, or the probability of A being true given that B is true DEF: (independence) two data sets are independent if $P(A \cap B) = P(A)P(B)$ What are these definitions for? • We defined the reduced universe as such because we want to be able to say, “In the universe where data set A is true…”. • What do we mean by a data set being true in the first place? Say $A = \{\text{Alice is a big mouse.}\}$. Then in a particular universe, $A$ is true if Alice is a mouse and if she is big and not otherwise. The truthiness of $A$ is the truthiness of all its conditions. • Why the definition of conditional probability? We want to have a way of saying, “The truth of A depends on the truth of B by this much.” • In this vein, saying that two data sets are independent is saying that whether or not B is true does not affect whether or not A is true: $P(A \cap B) = P(A)P(B) \implies P(A|B) = \frac{P(A \cap B)}{P(B)} = \frac{P(A)P(B)}{P(B)} = P(A)$. ### Definitions Good Thinking following what works; see the Twelve Virtues of Rationality, particularly the twelfth virtue Things I don’t understand series my own mental models of things, organised as best as I can 1. E. T. Jaynes. “Probability: The Logic of Science.” 1995. Print. 2. See the About section of gwern.net. 3. See Terry Tao’s post. # Spelunking series: React Native ### In which I try to avoid Hell as much as I can I’ve heard a LOT of things, good and bad, about React Native (or RN for short) so I have decided to do a bit of prodding. I’m going to start with this tutorial and hopefully it will take me to a place I didn’t know I wanted to be in. #### 2016-03-22 17:47 Around four hours in and I’m still not done setting things up. I don’t really have a clue why it’s taking me so long (or why the errors are so arcane to me), but it’s understandable given that the RN project is just over a year old (This is actually one of the reasons why I’m so interested in it: it’s still possible to make a mark.) #### 2016-03-22 17:56 Fig. 1: My first successful React Native app is a blank canvas (which means, it’s full of possibilities, eh?) I ran: react-native run-android …and it worked! Let’s see what we can do here. #### 2016-03-22 18:13 Fig. 2: Spoke too soon. That was kind of embarrassing. I really thought everything was going well until this popped up. But then it turns out if you shake the screen, you get this: Fig. 3: Progress at last. I googled for answers and put [insert my ip address here]:8081 (which is the default port of the server RN uses) under Dev Settings -> Debug server host & port for device and hoped for the best. But it turns out that this wasn’t the problem at all. You see, I have just committed what seems to be a very common rookie mistake in using RN: I didn’t start the goddamn Node.js server! So I ran: npm start And reran the whole thing to get this: Fig. 4: Sweet, sweet hello world. And yes, I know the times are wrong. I took Fig. 3 after I got it working. I’m going to take a break. I sure as hell deserve it. #### 2016-03-22 23:20 As far as I can tell, this is how you get RN for Android to work on an Arch installation. This process will probably still be valid in the next few months. ##### Step 1: Setup the necessary things # Install Android dependencies from the AUR (I use pacaur as my AUR helper) pacaur -y android-sdk android-sdk-platform-tools android-sdk-build-tools android-platform # Add the following to your ~/.bashrc export ANDROID_HOME=/opt/android-sdk # Make an sdkusers group so that you can build without root # This is needed because /opt requires root access groupadd sdkusers gpasswd -aUSER sdkusers
chown -R :sdkusers /opt/android-sdk
chmod -R g+w /opt/android-sdk
newgrp sdkusers

# Make sure to install the ff. packages:
# * Android SDK Tools (latest)
# * Android SDK Platform-tools (latest)
# * Android SDK Build-tools, revision 23.0.1
# * SDK Platform Android 6.0
# * Intel x86 Atom_64 System Image, Android API 23
# * Intel x86 Atom System Image, Android API 23
# * Local Maven repository for Support Libraries (latest)
android list sdk -a
android update sdk -a -u -t

# Install JDK, gradle, and watchman
pacaur -y watchman

# Install node.js
pacman -S npm

# Install react
npm install -g react-native-cli
##### Step 2: Make react run on your Android device
# Make a project directory
react-native init SampleProject

# Start the node.js server inside project directory
cd SampleProject
npm start

# Check if device is recognised by OS
# You should see "device" beside your device's serial number
# If not, make sure USB debugging is enabled and
# run the command "adb version"; something will
# pop up on your device. Pick OK or whatever is
# the most sensible option.
# Note that only one device should be connected at a time

# Expose Node.js server to device # AFAIK Node uses port 8081 by default

# Install app on your device
react-native run-android

##### Step 3: Sit back and relax.
# If you run into problems, you may open the developer menu
#  on your device by shaking it (no kidding) or via:

#  Dev Settings -> Debug server host & port for device


### In which I explore this brave new world

#### 2016-03-23 00:10

Fig. 5: Can you guess what my opinion of Insurgent is?

I got as far as making the GeoCities part of building the UI. Still trying to make sense of the syntax though (and fighting Emacs over indentation). I will continue this for breakfast and will probably finish by noon. Hopefully.

#### 2016-03-24 10:44

Fig. 6: Finally got everything working.

• If you’re using Emacs, you will have a hard time with indentation if you use the default JS mode. So do yourself a favour and do a M-x package-install RET js2-mode (available in MELPA).
• Enable hot reloading. It’s hands down the best feature of RN compared to native Android coding (at least, based on the sprinkle of what I know about Android development in general).
• In retrospect, I should have dived into the docs instead. I really have little patience for copying example code, especially if my goal is to become the person who can write it.
• I haven’t watched Deadpool. Is it as good as they say it is?

I’m going to take a quick break, get some grub, brush my teeth, that sort of thing. Afterwards, I’ll probably review JS off-screen and maybe delve into the React.js docs. You know, sit down and actually, properly learn things.

#### 2016-03-23 17:39:

If you’re itching to try a new language or are otherwise interviewing for a position you have to bullshit your way through in less than an hour, then Learn X in Y Minutes is a very useful resource.

Still need a few more pumps to get my play-with-and-break-things learning style so I’ll be going through another tutorial (this one). The twist? This tutorial was written for iOS. Hopefully by the end of this one I’ll know enough of the general landscape to anchor myself while I bungee-jump into the wilderness that is RN (and Android development in general).

#### 2016-03-24 23:38

Fig. 7: The fruit of many man hours forever lost, like tears…in…rain.

It has taken me most of today to get to this point and most of that was spent on trying to understand the Navigator class. What the flying funk were they thinking?! And the official docs were of little help to novice me either.

A couple of things I discovered:

• Handling the back button is a mess on Android (and I still have yet to make it work to satisfaction).
• I should probably misquote Feynman on this one: “If you think you understand JavaScript’s this, you don’t understand JavaScript’s this.”
• With that said, JavaScript Garden has a nice snippet on it, plus on a whole lot of useful gotchas when coding in JS.
• May I just say what a god-send the app ADV Screen Recorder is? It’s probably the most elegantly designed app I’ve ever used. It just overlays a four-button toolbar on your screen when you want to record something and the layout of its options are to die for. It’s as crisp as fresh baguette.

I’ll post more screens of experiments and probably upload some code on my GitHub next time but for now I want to break things! TTFN.

#### 2016-03-25 01:47

I have just discovered how to get rid of those pesky null is not an object errors. Put those goddamn values inside a constructor:

class SomeClass extends Component {
...
constructor() {
super();
this.state = {someVar: "someText};
}
...
}

Hopefully I don’t commit this mistake ever again.

### 2016-04-13 08:08

After nearly a month of delay, I finally made headway. I’ve been trying to get a grips on Realm (a database whose reason for my having picked it has died to entropy) since my last post and only now have I grokked how to get values from its darned [object Object] types.

I went from this:

Fig. 8: If I see one more of this…

To this:

Fig. 9: Yes, I followed React’s your-first-baby-steps example to the t yet it still took me until now to get it working.

So what happened? I neglected the fact that this:

// var realm = new Realm({...})
var something = realm.objects('someString');

…returns a list. So all I had to do was access its elements and shoehorn it to a string so I can wrap it under <Text> tags:

class someClass extends Component {
someFunction(object_realm) {
var string_out = '';
for(item in object_realm) {
string_out += item.someProperty.toString();
}
return string_out;
}

render() {
return (
...
<Text>
{this.someFunction(something)}
</Text>
...
);
}
}


So there you have it. I can finally get values from a database. How funky is that?

### Definitions

Spelunking series
in-depth guides about other people’s things
SR2
my Android phone’s name (yes, I name my devices)
RN
React Native
TTFN
ta-ta for now, i.e. one of the most memorable catchphrases in my childhood

# The SAPA Project

### The Ghost of Testing Past

The SAPA project is a personality assessment tool. It has “synthetic aperature” in its name because its brainparents thought, “Hey, what comes to mind when you combine little things to yield a single big thing? That’s right. Radio astronomy.” The VLA looks like this:

Fig. 1: The Very Large Array. Photo by John Fowler.

And so I hope you can imagine what the test is trying to do. You get a huge number of questions, show a random subset of them to multiple people (so that data is missing at random), and combine them to get facts on the entirety.

I first took SAPA on 2015 June 04, around 290 days ago. And look how shortsighted I was then! Why? I goddamn neglected to save the link to my report! How dumb can I get?

Fig. 2: My SAPA results on 2015-06-04. I show this instead of their bell-curve graphic because this is a prime example of pie charts done right. Two ticks of the radius corresponds to a standard deviation. The mean is 5 ticks away from the center or exactly halfway to 9. Please excuse the quality of this image and the next. I promise the newer ones are better.

Fig. 3: My 2016-06-04 SAPA “personality signature”. Serves as a legend to Fig. 2 above. Also shows a big, fat cognition band. Yes, I’m boasting about it here.

But words are mere pointers. What do these factors mean? Well, I like lists so let’s make an outline. The six factors SAPA uses are based on the Big Five and HEXACO tests. They are:

• Extraversion
• Openness
• Agreeableness
• Integrity
• Emotional Stability
• Conscientiousness

These factors are then further divided into two aspects:

• Extraversion
• Sociability
• Assertiveness
• Openness
• Intellect
• Openness to New Experiences
• Agreeableness
• Compassion
• Politeness
• Integrity
• Honesty
• Humility
• Emotional Stability
• Balance
• Boldness
• Conscientiousness
• Orderliness
• Industriousness

(I really ought to get JS working on this thing.)

SAPA gives me a lot of predictions on each level so let’s break them down into bite-sized chunks. Here I shall write for a person who gets a high score on a particular aspect:

• Extraversion
• Sociability
• is positive, energetic, warm, talkative
• is easy to get to know
• engages in idle chit-chat
• Assertiveness
• is often described as having a strong personality
• see themselves as quick-thinking, effective leaders
• is rarely at a loss for words
• is not wary about influencing others
• Openness
• Intellect
• is willing and capable of reasoning and engaging with complexity
• Openness to New Experiences
• appreciates art and/or music on a deep emotional level
• is open-minded
• desires new experiences
• has a vivid imagination
• spends more time with abstract ideas
• is often described as odd or strange
• Agreeableness
• Compassion
• is capable of recognising the emotions of others
• usually comfort others around them
• inquires frequently about the well-being of others
• Politeness
• tolerates the inevitable “annoyances” of interacting with others
• rarely feel anger or frustration with those around them
• is patient and rarely complains
• Integrity
• Honesty
• adheres strictly to behavioural “rules” (from rules about stealing to rules about dealing with interpersonal affairs)
• is less likely to deceive others or cut corners when consequences are minimal
• feel badly when they fail to uphold these rules
• Humility
• does not care about impressing others
• does not desire power
• Emotional Stability
• Balance
• is not bothered much by “annoyances”
• is able to recover from setbacks quickly
• not moody nor unpredictable
• is considered impassive or aloof by others
• Boldness
• is less fearful of unknown situations
• invests little time in worrying about unlikely outcomes
• Conscientiousness
• Orderliness
• tends towards organisation, cleanliness, and predictability
• at extreme levels, may represent underlying mental disorders
• Industriousness
• is hard-working, efficient, and reliable

These aspects are further correlated with each other according to the table below:

Fig. 4: Correlations of the various factors1. Note some of the more interesting ones such as Assertiveness vs Intellect (+31), Industriousness vs Balance (+31), Compassion vs Boldness (-12), Intellect vs Honesty (-1).

Do I agree with these results? At the risk of committing the omnipresent sins of Selection Bias and Confirmation Bias, I shall mention the two aspects which I found to contradict my mental model of myself.

First is Honesty.

A couple of years ago, I came across this Esquire article, I Think You’re Fat. Being a wee lad then, this was a revelatory article to me. I didn’t always have my extreme aversion to lying. Once, I went on a school trip on an ill-gotten signature from my dad (under the pretense, of all things, of a date) My mum didn’t talk to me for a week straight.

Lying felt dirty, however. I don’t have lossless access to the memories of my twelve-year old self anymore but I can guess that he must have felt bad about it (and I’m not saying this just to elevate the darned kid). Lying is taxing. It’s stressful. You have to carry two, three, n different versions of reality inside your head and nowadays I don’t know how people can cope with it. Radical Honesty is liberating because it makes for a contradiction-free mind. It set me on a path to the Way (but more on this later).

According to SAPA, however, I am less honest than the average Han2.

This to me is absurd. I have made it a strict rule in my life to detest and expunge any contradiction that pops up in my mind. In fact, I’ve found that the more I strive to be consistent, the worse I become at lying. Playing as the enemy in Werewolf3 is almost impossible to me now. So what gives?

The other aspect is Openness. My objection to this is a bit less severe because I think this admits a partial explanation. I like working out the consequences of things. In fact, I like it so much that I can’t turn it off. If I fear mosquitoes, it is because I fear needles. If I fear stray dogs, not being fit, being part of a car wreck, flying out of the country, etc. — same thing. But it seems these otherwise benign refusals completely overshadow my extreme tolerance of ideas. So there’s a lot of work to do before my mental model of how open I am can match my test results.

### The Ghost of Testing Present

To get rid of these bothersome thoughts, I took the test again. The figures below show all that you have to know.

Fig. 4: My SAPA results on 2016-03-21.

Fig. 5: My 2016-03-21 SAPA “personality signature”.

The first interesting thing here is that I have become more rounded, more average. That isn’t a bad thing in and of itself. But my Conscientiousness, Integrity, and Openness — traits which I most identify with — have all but decreased. Now, it’s wrong to read too much into these results (especially since I haven’t found a meta-analysis of SAPA), but even so this is a direction I don’t want to go towards.

### The Ghost of Testing Yet to Come

SAPA says that one’s personality is “stable, but not static”. If so, then my current results are bound to change. Whether from external factors such as relationships with other apes, minor brain injuries, the available lighting or from the inherent measurement error in the test, it’s interesting to see what comes after. Here’s what I want to see next year:

• Assertiveness and Sociability should jump upwards to the 50-60th percentile.
• Humility should stay within 5 percentiles of its current value. Honesty should jump to >50th percentile.
• Cognition should stay at 16/16 +/- 1.

I’m straddling the line here by deliberately using a construct model to make predictions. But having no formal models at all is the worst option. So let’s allow ourselves to have a bit of fun, even if only in making weak, self-absorbed statements about ourselves.

### Definitions

Bias, confirmation
what you get when you choose your samples (consciously or not) in such a way as to favour your pet hypothesis: Death by Straying from the Way
Bias, selection
what you get when you don’t properly randomise your sampling: Death by Systematic Error
Model, construct
a model which aims to make sense of a thing without having the pretense of being a scientifically measurable theory
Model, event
a scientifically measurable theory; asymptotically speaking, all formal models should be considered event models
a movement that stresses the importance of not lying EVER, not even when it costs you social brownie points
SAPA
Synthetic Aperture Personality Assessment; a personality test that’s been making the rounds on the Internet these last few years
Stanine
Standard Nine, or a “nine-point standard scale with a mean of 5 and a standard deviation of 2”; first use commonly attributed to the US Air Force4
Test-retest reliability
the property of your answers not changing when taking the same test under the same conditions
VLA
Very Large Array, or what you get when you combine 27 telescopes in a Y-shaped configuration, mount them on special train tracks, and use Fourier nonsense on them to effectively get a single 36 km-wide telescope
WP
WordPress, but you probably already knew that

1. Condon, D. M., Revelle, W. (2013, July 30). Temperament Correlations. Retrieved from http://SAPA-project.org/info/temperamentCorrelations.html
2. A reference to the fact that 19% of the world is Han Chinese, more than any other ethnic group.
3. From Wikipedia
4. According to Wikipedia