Monday, October 22, 2012

Unwaitlist v1.0 at HackOlympics

Unwaitlist is my first app. Currently, the cron jobs are disabled because enrollment period is closed, but the signup, introductory status checking and email/ text works.

I made it at my first hackathon last Saturday. HackOlympics. It was just two blocks from my apartment, and had I think 40 people at least. Didn't know most of them, but met this guy called PA who was really friendly. Among the projects, there was a tutorial aggregation social site TUTE, a text message help site TextGuru that crowd-sources advice, a site that crowd sources for chefs to cook and deliver to you Let Me Cook That For You, and a site that takes your background image or video, then scrapes Google Image search for content-related and color-correct images and makes a collage from those images. RedBananaPenguin.

The winner, music++, was a Tap dance like music game that only uses javascript "because HTML5 is the future, not flash", where the programmers determined the movements captured on the laptop's webcam by comparing frames. They won the Tech award and Grand Prize Winner.

12PM : 12PM

I signed up solo, and there were 4 only other solos, but before the hacking began we had to pitch ideas to each other or get pitched to by teams, because the organizers preferred it. And I agree. So much more can be accomplished. But generally the vibe was either, "I really want to get my idea off" or "I code a lot better than any of you so I wanna do my own thing." A senior teamed up with me. It was also her first hackathon. She didn't know higher-than-C++-level languages, but did a couple of databases classes, so she wanted to make one. I didn't know anything about databases. Unfortunately, she left later without leaving a db, so we didn't mesh our code together.

Anyway, I planted a bug that was very lame when I rooted it out later. The things is, the user inputs a url, and the app parses the html for stuff. But instead of opening the correct page, we were going to a general page. Think of it as searching for 'X' in google, and coming up with 'www.google.com/?=X' but being re-routed to 'www.google.com'. I thought it was redirecting to the main site and taking away my query string. Finally, I suddenly realized that I'd been cgi-escaping the ampersands in the url I was passing, mucking up the url.

After this bug, things went fast. I read up some on NoSQL, but the GAP Datastore was exceedingly easy to use for basic stuff, so I had a database up in like two minutes. Then I wrote up two Cron jobs, one to periodically check for whether or not the class status' hand changed, then to text/email the user; one to clear out the database before and after enrollment period.

Unfortunately, I didn't have the app done by the demo pitch, but I couldn't stop working on it and it pretty much finished itself at home.

Future

The only thing is that I need to see how this app works when enrolling actually happens, because now that enrollment's over, we don't have classes changing from 'Closed' to 'Open' or vice versa. What happens when there are many users? How efficient is my database querying, and Cron jobs? I know that the status-checking, user-input, and text/email functionality is working. I also wish that the user didn't have to paste the url over. While I have a couple of checks to hopefully prevent breakage, it's not the most user friendly implementation.

Sunday, October 21, 2012

Getting started on Heroku with python for Mac

Was trying to get Heroku up and running, but ran into some trouble that's not documented because my Mac >= 10.7. This may be useful for beginners.

To make a heroku app, you need virtualenv, which you need pip to install easily. To get pip:
1. Install homebrew (the instructions provided by heroku's link to installing python for Macs (which have a weaker version of Python) is outdated)
- scroll all the way down to copy and paste the CLI text from the 'Install Homebrew' box
- you may need to run '$ brew link python' if there was a warning saying that it was not linked
-- if prompted to force link because some files already exist, do so:
$ brew link --overwrite python
- run '$ brew doctor' to check your homebrew
- if there is the warning that your PATH prefers 'usr/bin' to 'usr/local/bin', run:
$ echo 'export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"' >> ~/.bash_profile
then Quit and Open Terminal again, run '$ brew doctor', and the warning should be gone.
- The message 'Your system is raring to brew' would be the most optimal setup of homebrew, but you may have macports and stuff that gets in the way. That's OK, you can still install virtualenv
- This is a great intro to homebrew
2. Install pip
$ brew install pip

Logging into heroku on the CLI with Credentials, throws error 'Cannot allocate memory...'
- Reinstall the heroku Toolbelt. You don't have to uninstall or remove the toolbelt because heroku takes care of it for you.

Setup a virtualenv in your app's folder
- If running '$ virtualenv --distribute venv' outputs that the command virtualenv doesn't exist, it's because virtualenv is in the python package that pip installed.
$ python2.7 ~/../../usr/local/lib/python2.7/site-packages/virtualenv.py --distribute venv

Activate the virtual environment to run your app, which you need to do everytime you open your app for development.
$ source venv/bin/activate

As per the Heroku guide, make your dependencies text with '$ pip freeze > requirements.txt' and  Procfile (file name must be 'Procfile')  with 'web: python <your_file>.py' inside the text editor.

$ foreman start
- Say you have 'import jinja2' but it can't find the library. In your application, if you import libraries like jinja2 or webapp2, run '$ pip install jinja2' in the application folder.
- If using Python, and after '$ foreman start' you don't see anything after 'started with pid XXXX', create an '.env' file with 'PYTHONUNBUFFERED=TRUE' inside.
- Everytime you update <your_file>.py, Ctrl-C, '$ foreman start' to restart the process. The debug log will change on the local site, but not the actual code running underneath. It's not Google App Engine where the dev app is actually live.

Thursday, October 4, 2012

Interesting Sig12 papers

This week, I read almost all the Siggraph 2012 and SigAsia 2012 abstracts. My goal was to get an idea of what good research entails (i.e. the scope; detail), and what areas of computer graphics are exciting. I then filtered for the most interesting papers to read.

Reading the papers, it occurred to me that maybe animators today subconsciously limit their imagination because of present day tools. While there are mind numbing breakthroughs in every movie, I think that just as if you limited an artist to charcoal he wouldn't think in color, similarly an animator would have a limited mindset. That's why it would still be exciting to see animation 10 years from now, when a new generation of animators have grown up on a new wave of production technology.

Here's the list. It is a fairly broad variety:

Cloth
Stitch Meshes for Modeling Knitted Clothing with Yarn-level Detail
Identified the basic stitch types and how they fundamentally are stitched together, then reduces each stitch quantum to a cell. A lot of details about real-life knitting informs their modeling, although the computer can produce good looking but physically impossible stitches. To generate the model, there's an interactive UI where the user inputs info on the stitch patterns. The whole cloth model (e.g. a sweater) is sectioned into clickable faces for individual modification. Now, the mesh faces are relaxed, which is to curve around the body wearing it realistically, and the cells are constructed on each face, relaxing with them. To complete this, there is then the yarn-level relaxation, which makes each knit stand out like a real sweater. The relaxation converges around the wearer until the rate of change hits a threshold.
Comics, Texture and Scribbles
Digital Reconstruction of Half-toned Color Comics
Digitizes paper-printed comics by using algorithms to separate black ink from the colors which are screened dots in CMY. The black lines must be unscreened and are recovered as a binary file. Grids are used to approximate the dots. These elements are then vectorized as parametric models and quite slowly rendered in a highly compressed file. Because the black lines are separated and sharp, the comic panel can easily be layered for parallax viewing.
 - Their method:
  1. Estimate the primaries for the Neugebauer trilinear model and compute a CMY color separation by inverting the Neugebauer equation.
  2. Detect the dot grid for each of the CMY channels.
  3. Use optimization to jointly recover a binary black ink mask and the individual dot shapes.
  4. Vectorize the black ink mask and filter the color channels.
Materials and images
> (paper not avail yet)
Lighting Hair From The Inside: A Thermal Approach to Hair Reconstruction
Skinning
Elasticity-Inspired Deformers for Character Articulation
Control Deformables
Deformable Objects Alive!
Uses rest poses to direct object motion. Deformable objects are actively and autonomously animated. It's not the usual passive case where something like jelly would be constrained to flop through a crack in a certain way, but in which the jelly would hop and jump.
Fast Simulation of Skeleton-driven Deformable Body Characters
Sketching
Three-dimensional Proxies for Hand-drawn Characters
Noise and Texture
Structure-aware Synthesis for Predictive Woven Fabric Appearance
Particles
Ghost SPH for Animating Water
Versatile Rigid-fluid Coupling for Incompressile SPH
Found a nice intro to SPH. I'll probably have to read a lot more simulation papers, not just SPH, to understand the significance, and the 'this' in general. Actually, this applies for all the papers. For Ghost SPH, you basically have namesake particles which are invisibly applying thousands of little springs to the real water particles to keep them in a certain form.
Collisions
Efficient Geometrically Exact Continuous Collision Detection
Mathematics and Physics of Light
Physically-based Simulation of Rainbows
All about images
What Makes Paris Look like Paris?
Mesh Based Fluids
Langrangian Vortex Sheets for Animating Fluids
Discrete Viscous Sheets
-- Discrete Viscous Threads (2010)

Tuesday, October 2, 2012

Simulated Annealing prototype

One of the grad students here gave me his Siggraph 11 paper on optimizing automated arrangement of furniture models in real world settings, and told me to write a version of simulated annealing however I wanted. At the time, I was more comfortable with Python, so I did that.

What I had was a red triangle, and a blue triangle, that were randomly placed on a plane in a random direction. They were supposed to use Metropolis Hastings simulated annealing to point to each other and have a minimum distance (i.e. 0) between each other. The thing about simulated annealing is that instead of falling into a local success solution, probabilities are factored into the algorithm so that the triangles can move to worse positions at the moment, but later on find a global optimum.

Here's how it would look if the program ran:
before SA: random position and direction

after SA: minimum distance apart; faces each other