The code of Lali

Blog — lalicode

Food Review: Asian Snacks

June 22, 2016

It's important to try new things every now and then to escape from the mundane. So I went to Davis's Ho Ho (好好) Market and got a bunch of snacks!

Hung Fook Tong Longan With Honey Drink

Fun Fact: Longan is very similar to Lychee except for the color (brown vs. red), texture of their skin (smooth vs. bumpy), and subtleties in flavor. The honey in this drink was overpowering for the first few sips but the longan flavor peeked through afterwards. The flavor tasted fairly accurate and the drink was refreshing in the 100F Davis weather. The only thing I didn't like was how overpowering the honey was for the first few sips.

Cost: $1.39
Rating: 9/10

Hi Tempura Spicy Tempura Seaweed

Hi Tempura is a fried version of Tao Kae Noi Crispy Seaweed. The flavor of this tempura seaweed was strange at first but I learned to really like it. It's actually surprisingly spicy. The bag says it serves 8 people but there's really only enough to satisfy the snack cravings for one person. Overall, this is certainly one of the good savory snacks.

Cost: $2.19
Rating: 8/10

Lotte Chocolate Pie

This one is really cool! The box has squirrels everywhere which is legit. When I flipped the box to look at the back I was flabbergasted when I saw that there were Microwave instructions. I poured a bunch of the pastries on to a plate and microwaved it for 35 seconds. The pastries came out warm and the chocolate was slightly melted. It was a unique experience indeeed. The pastries tasted alright and the portions are perfect for sharing or for saving. What I didn't like was the firmness of the pastry shell. I think it would be better if the shell was less thick and if there was more chocolate.

Cost: $2.29
Rating: 6/10

Bourbon White Rollita

The moment I opened the package my nostrils were overwhelmed by a strong sweet scent. The White Rollita is simply a biscuit covered in white chocolate. The biscuits are alright and the white chocolate was pretty good too. However, the flavor really went dramatically downhill after I ate more than one. By the time I had four, the chocolate had the same texture and aftertaste as a crayon.

Cost: $1.99
Rating: 4/10

jQuery Autocomplete and Django

June 15, 2016

In this tutorial we will go over how to use the jQuery AJAX Autocomplete Widget with Django. This tutorial is for those who already have a model and database setup.

First import jQuery and jQuery UI:

<!-- jQuery !-->
<script src=""> </script>
<!-- jQuery UI !-->
<link rel="stylesheet" href="">
<script src=""></script>
In your html template file add the following to your block content. You can replace places with whatever your model represents.
<div class="ui-widget">
  <label for="places">Places: </label>
  <input id="places">

In the same html file setup the jQuery autocomplete function in a script block


  $(function() {
      source: "/api/get_places/",
      select: function (event, ui) { //item selected
        AutoCompleteSelectHandler(event, ui)
      minLength: 2,

  function AutoCompleteSelectHandler(event, ui)
    var selectedObj = ui.item;


The jQuery autocomplete widget does all the heavy lifting for us. The AutoCompleteSelectHandler is called when the user selects an item from the list. The text selection is accessed with ui.item. However, it needs to invoke /api/get_places/. Let's get that set up!

Add the url in your file:

url(r'^api/get_places/', views.get_places, name='get_places'),

Then write up the view in

import json

def get_places(request):
  if request.is_ajax():
    q = request.GET.get('term', '')
    places = Place.objects.filter(city__icontains=q)
    results = []
    for pl in places:
      place_json = {}
      place_json = + "," + pl.state
    data = json.dumps(results)
    data = 'fail'
  mimetype = 'application/json'
  return HttpResponse(data, mimetype)

Here we setup what goes into the autocomplete search terms based on the user's search term, q. The function filters through your database and returns a json file with the correct data to the jQuery autocomplete function.

You should be all good to go now! Special thanks to Flaviu with his tutorial on how to do this.


April 29, 2016

to the lali