Posts

Showing posts from 2016

Firebase Presentation

Posting the slides from my presentation about Firebase to the Haystack Group here!

iMessage bug fixed!

Image
This post is just a quick update on the bug I found in iMessage during WWDC a few weeks ago. (UIViews were disappearing in my iMessage app when a user cancels sending a message and transitions back into the expanded view. An Apple engineer told me this was because they were doing some hacky things with Auto Layout and view controllers.) The issue's now fixed in the latest version of iOS 10 beta! (You can find iOS 10 beta 2 at https://developer.apple.com/download/ ) Status: Closed :) 

LevelDB

I've been playing with the LevelDB library recently, so I took some time digging around its source code (https://github.com/google/leveldb) and reading articles/papers. In this post, I’m going to share some things related to LevelDB that I most enjoyed learning about. If you don’t know much about LevelDB, here’s a quick overview: LevelDB is a C++ library that stores key value pairs of byte arrays sorted by key. Operations include Put(key, value), Get(key) and Delete(key). It’s called LevelDB because it is arranged by levels: cache, log, level 0, level 1, level 2 … In general, after Level x reaches a limit of 10^x MB, one of its files gets compacted (merged periodically) into Level x+1. Level 0 is a special level: when it hits its limit of 4 files, at least one of its file gets compacted into Level 1. Furthermore, the files in Level 0 can contain overlapping keys, whereas the keys in the files in the other levels cannot. One of the things that interested me was the underlying d...

iMessage Apps: A More In-Depth Look

Image
This post includes some FAQs about iMessage and tips for developers who are interested in building interactive iMessages and iMessage apps. Click here for an overview of the additions to the iMessage app and WWDC 2016 in general. What does using an iMessage app look like?  Users get to your app by swiping through their Messages App Drawer   They can see both compact and expanded views of your app, and have the ability to switch between the two whenever they want. (You are provided with willTransition and didTransition methods, which you can override to be prepared when users switch between the presentation styles.) Compact view Expanded view How can people get my iMessage app? From the app store dedicated to iMessage apps - your iMessage app doesn't need to be attached to a separate full app.  If someone's friend sends them an iMessage through your app, they will see a link at the bottom of the iMessage where they can download your app.  ...

WWDC 2016

Image
I just wrapped up my second year at WWDC! It was great meeting so many people, making new friends, and talking to Apple engineers in the labs. Some things I thought were especially noteworthy: iMessage . Apple completely revamped their iMessage app to include recorded handwritten messages that you can play back, bubble and screen effects, music sharing, reactions, and more emphasis on emoji, including suggestions and 3x larger sizes. However, I'm most excited about iMessage apps! Not only can non-programmers now quickly make sticker packs without writing a single line of code, but also developers can create interactive iMessages. People can download these apps from an app store in their iMessage apps. Furthermore, the messages can be saved in sessions, so people can save screen space - this is especially useful in group chats. For example, in Apple's demo iMessage app, you see just the final ice cream and the history ("we added scoops") instead of a bunch of...

Fast Fibonacci

My 6.006 TA mentioned a quick way to calculate the nth Fibonacci number that I thought was really cool! It's more efficient than recursion (exponential), memoization (linear), or looping through/keeping track of the previous two numbers (linear). The O(log n) method combines matrix multiplication with repeated squaring. It's based on the fact that [[1, 1], [1, 0]][a, b] = [a+b, b]. I wrote three possible methods in Python, which I copied below this post (full code on Github ). When calculating the millionth Fibonacci number, loopfib took 16.5753660202 seconds, and matrixfib took 0.820223808289 seconds, roughly 20x faster. Side note: Python automatically converts 32-bit ints to bignums, so this code can handle calculating the millionth Fibonacci number. def matrixfib(n):  a = [[1, 1], [1, 0]] t = [[1, 0], [0, 1]] b = [1, 1] while n > 0:  if n % 2 == 1: t = dot(t, a)  n /= 2 a = dot(a, a) return t[1][0]*b[0]+t[1][1]*b[1] def na...

ihtfyp | 6.148 (web programming competition)

Image
January 2016 has been a month-long 6.148 hackathon - my friend and I often worked on our web app until 4 am! We're hosting it at ihtfyp.herokuapp.com . Currently, we made the semi-finalist round of the competition! (We'll find out how we did tomorrow!) You should also vote for us for the Webby awards at  http://6.148.scripts.mit.edu/2016/webby/ihtfyp :) :) :) The theme of this year's 6.148 was "remember the future" so we created an app that would be the future "lost and found box" for the MIT community. As of now, if you lose something, it's hard to know what to do: do you dig through physical lost and found boxes around campus? Do you ask your friends on facebook to look out for your lost item? Do you post a wanted poster? We wanted to build a reliable, universal way of matching lost and found items, so we made ihtfyp. (We were in a punny mood when we came up with the name - our team name was MITeam) We learned how to use a lot of ...

My First q Program

I recently wrote my first q program as part of the US Constitution Word Count challenge !  It was cool seeing how much terser the q program was than my Java program that did the same thing. 4 lines and 188 characters of q...  strip:{x except "[]():,;.-0123456789"} us: strip each lower raze " " vs/: read0`:input.txt s: desc count each group us except enlist "" `:solution.txt 0: (key s) ,' "|" ,' (string value s) and 50 lines and 1067 characters of Java... import java.io.*; import java.util.*; public class wordfreq { static class word { String w; int c; public word(String w, int c) { this.w = w; this.c = c; } public String toString() { return w + "|" + c; } } public static void main(String[] args) throws Exception { HashMap<String, Integer> freq = new HashMap<String, Integer>(); Scanner s = new Scanner(new File("input.txt")); while (s.hasNext()){ String str...