Daw-Ran Liou

Software Developer, Clojurist, Pythonista @ SF

Inspect Java Objects with Clojure

2019 February 9

The more I work with Clojure, the more frustration I found to work with Java objects. Mostly, it feels an unnecessary process to go through the class definition to find the getter methods to access the data I want, especially when the data is buried under multiple layers of classes deep.

In this article, I’ll explain a recipe to create a graphical inspector UI to explore Java objects, frustration free! The key is to use the clojure.inspector for the visualization and clojure.org/java.data for recursively converting Java beans to Clojure data structure.

Read more…

Tachyons CSS Framework / Library Review

2019 February 2

I’ve tried to learn many CSS frameworks (Bootstrap, Foundation, and Bulmar) over the years. They never really clicked and styling felt just as painful as ever. But this has changed since I learned about Tachyons. First introduced by Martin Klepsch (thanks Martin!), I learned and started to use Tachyons since late 2018 for the Cljdoc.org project [1]. This is the only CSS framework / library that fit my brain and my workflow. If you are struggling with learning any CSS framework, I hope I could shed some lights by introducing you Tachyons.

Read more…

Interop legacy Java project with Clojure

2019 January 31

Recently I got the chance to work on a new feature for our existing Java project. The feature itself is a project that set out to be a general-purpose asynchronous data logging library that can be used company-wide, shared with other projects. I was very into Clojure these days. Learning Clojure has this side effect of mutating your brain to view programming difference. At the meanwhile changing your taste of choosing a programming language. (Please be Clojure!)

Read more…

Decode your phone number with Clojure

2018 April 30

The original article was shared on my Medium

The inspiration of this article came from the Cousera course, Functional Programming in Scala. I basically translate the Scala program in section 6 into the Clojure version you’re about to see. Kudos to Martin Odersky.

You might have seen ads with interesting phone numbers like: 1–800-FLOWER, 1–800-FREE-411, or 1–800-GOT-JUNK. Those are called phonewords, or mnemonic phone numbers. It’d be awesome to have a memorable phone number like 1–RANDY-DA-MAN. However, maybe your phone number already has a meaning. How cool is it to figure it out, well, using Clojure?

Read more…

What is it like to start a study group at work

2018 April 24

Have you ever had the feeling that you got so passionate about something that you have to share it to everyone around you? You gotta force people to be passionate about it, am I right? I was so thrilled about Python two years ago, on the day I finally understood what list comprehension is. I had never knew programming could be so… enjoyable. Gradually from chit-chatting with colleagues, to going to a local meetup group and writing blog posts, I wish to find yet another way to share this amazing technology and to help people. So I thought about starting a Python study group in my workplace..

..And I started a Python study group in my workplace 30 minutes later. This is what happened in the 30 minutes:

Read more…

Don’t think. Just write the code!

2018 April 2

Imaging you are given a brand new web project, some vague requirements, and a ton of freedom to choose the technical stacks, will you take it? My answer while a couple of months back was… “Hell yeah!” Even though I had never really worked on a real-world project except the blog app that was taught a thousand times from online tutorials.

It had been a wonderful journey, with struggles, of course. I would love to share what I learned. Hope it sheds some lights on your coding journey too. To set the expectation right, let me give you some idea of my experience level before I started the project.

Read more…

Composing namedtuple from namedtuples

2017 November 2

The problem:

One namedtuples is great, two better. But how do I combine the two namedtuples to get the best nametuple of all?

For example, how to combine the Square class with Color class?

Square = namedtuple('Square', 'x0 y0 x1 y1')
Color = namedtuple('Color', 'r g b')
# The opposite of DRY principle - WET (we enjoy typing) principle
ColoredSquare = namedtupe('ColoredSquare', 'x0 y0 x1 y1 r g b')

Read more…

Writing descriptors in Python 3.6+

2017 September 23

Special thanks to Luciano Ramalho. I learned most of the knowledge about descriptors from his workshop in PyBay 2017

Have you seen this code or maybe have written code like this?

from sqlalchemy import Column, Integer, String
class User(Base):
    id = Column(Integer, primary_key=True)
    name = Column(String)

This code snippet partially comes from the tutorial of a popular ORM package called SQLAlchemy. If you ever wonder why the attributes id and name aren’t passed into the __init__ method and bind to the instance like regular class does. , this post is for you.

Read more…

Getting Started with Python Internals

2017 February 20

This article is a summary of what I learned from Philip Guo‘s CPython internals: A ten-hour codewalk through the Python interpreter source code. I highly recommend you to go through his course. He go through great materials in his videos. You can think of this article as a companion text version of his course, so you can come back for your own references. The only major difference between Philip Guo’s course and this article is the Python version. In his course he was using 2.7.8. This article I’m using the 3.6.0 code. In this article, you’ll know the very basic things about Python internals, and, hopefully, be able to explore the Python internals on your own.

Read more…

Page 1 of 3

Next page >>