18th: Moodger – A device may change your mood

I started with “A device that changes your mood”. And then I paused a while. It sounds like a medical device and may even feel a little deceiving, so I later change it to “A device may change your mood”.

This is not a lie. It is just another useless idea.

Is it though? Hear me out.


Inspiration

Yes, most people know about Nest.

It’s a device that connects to the thermostat at your home, and lets you remotely control the temperature. Big deal, right? What makes people fall in love is that it will learn from human input and eventually starts adjusting itself.

In addition to that, it also has some nice features for energy efficiency. It generates a report, of course, every one loves reading a report and feel good about how much energy they have saved after using the device.

I have no objection that features in Nest should be considered as parts of the future smart home. Nowadays, we have all sorts of “smart” devices at home: smart light bulbs, smart monitors, smart fridge, smart microwave, the list goes on.

Yes, people in the future might really want to tweet from their fridge. But I am not falling in the same trap, only staying in the fixed mindset of “connection with machines”. Human, we should connect with human, device that connects people, that is the direction I want to go.

What brings human together?

  • money? hell no
  • food? maybe
  • the answer is laughter!
    • a smile on anyone’s face brings a stranger closer
    • an innocent laughing can even melt the vicious enemy’s heart

If you don’t believe me, try this:

A brief history

Many years ago, I wrote a small program called Jok4U. It can still be found in Wayback Machine. The idea was it randomly popped up a joke in your computer. It was a very naive program and did not do too much. But I tried…

A modern version

Now what about this?

Instead of having a program installed in your computer, what if there is a small device, just like Nest, which is mounted on a wall. When you pass by, it will randomly ask you if you want to hear a joke. Something like what the following:

That user figure is passing by the device. The device has a motion sensor, so it knows someone is nearby. It asks “hey, do you  to hear a joke?”. If the user answers, “yes”. The device will tell a joke.

Brilliant!

Feature List

There are more, of course! The device support:

  • can be configured to have different level of jokes: kids-friendly, safe for work, or adult-only
  • can learn from the human answer, eventually it will automatically tell joke instead of asking question first
  • can learn from the human response and adjust the joke selection algorithm
  • can learn from the human response and adjust the way of telling jokes, it will start with the cold machine-like voice, but slowly, it will adjust itself using Adam Sandler or George Carlin’s voice.

Moreover, we have to have this feature

  • can collect your laughter and then generate a report, which analyzes how much laughter you have and how much calories you have burnt from laughing.

This device will of course have to connect with Internet, so it can also download the jokes accordingly and upload the data for machine learning purpose.

Is it really a stupid idea?

If anyone is reading this idea, let me tell you why this is not a stupid idea, and also let me confirm you that I have been serious the whole time.

Use Case 1: Ease the tension

First, I love my kid.

But I admit some times it may get heated at home, especially, when

  • teaching her math…
  • asking her eat vegetable, 20th times during one meal time…
  • telling her the same thing I have told her 100th times…

many other cases. I told myself I would not yell at my kid before she was born. But what I learn is, yelling at your kids does not make you a bad parent and does not mean you don’t love them (Murray Goldberg may not be a good dad model, but he loves his children).

Sometimes you just do what you have to do.

So, imagine when you are yelling at your kids, the device can sense the pitch hike and say “Knock Knock”. Both you and the kid will probably stop, and answer… “Who’s there?”. Now the tension is cool down.

Use Case 2: Change the mood

Being a grown-up sucks. Work is hard, traffic is bad, greedy banker and incompetent politicians never stop screwing economy up. It is difficult enough for people to laugh more.

What if when you open the door of your home, the device will take an image of your face and analyze your mood, and then respond accordingly.

Using thermal image to understand human emotion is definitely not new, see these paper:

The device will be capable of detecting the user current emotion: angry, or depressed, or sad. The device then reacts different by using different type of jokes, or maybe just play baby laughing. The idea is trying to change the mood of the user at the right time.

I am not a psychology expert, so I cannot say this will really work. More research may be required to validate this intention and use.

Use Case 3: Ice Breaker

Now imagine if you have a party with some guests in the house. The device can detects more than usual amount of people passing. If the human voice level suddenly drops, this device can jump in to break the ice by telling a joke.

I cannot imagine how useful this device can be when a socially awkward person brings a date home. It is like a little wing man.

Who am I kidding, a socially awkward person never gets a date.

What is the name “Moodger” from?

It stands for “Mood Changer”. I actually like this name.

Basically, the idea is building a robot that tells jokes, reacts to human, understands human, and more importantly, alter the mood such that a human can still have a feel with other human as well as the world.

Many people may underestimate the power of laughter.

Building a robot telling joke is not really novel. In fact, back in 2010, researchers had already started this. See this article: Joke-Telling Robots Are the Final Frontier of Artificial Intelligence.

However, the novelty in “Moodger” is not really just a robot telling jokes. It’s a sensible helper. Just like Nest, it will learn from human command, human response, and ambient atmosphere to react accordingly.

 

 

17th: A comics about a cat adventurer

I was watching secret life of pets 2 with my kid in the movie theater, and then I suddenly had this idea: I want to draw a comics about a cat adventurer.

I always want to draw a comics, but I never have a good topic. Now I find it!

No, this is not a normal cat story. I came back home and wrote down the script of the pilot plot.

Unfortunately, I can’t share it here. But I really did write it down.

I also did some research online, there are tons of comics using cats as characters:

https://en.wikipedia.org/wiki/List_of_fictional_cats_in_comics

http://www.catmuseumsf.org/comics.html

Good that I haven’t found anything similar.

My idea is not like this one either:

Nor is this one:

But I need to be careful about the story. At least I did some research about similar story.

Now I need to learn how to draw cats, many different cats.


I know, but no one says I have to know how to do a thing before deciding to do it.

It’s more important if I want to do it, and then is how much I want to learn to finish it.

16th: Interview for a city leader

This is part 2 of my previous idea, 15th: Running a country is the same to running a big corporation

The more I think about it, the more puzzled I become:

Why can’t a city elect a leader in the way like a company hires a new chief officer?

Let’s assume we have a city called: Domino, where it needs a new mayor.

Step 1: Job Posting

The HR department posts a new advertisement, something like

Mayor Needed

Job Description

  • normal mayor stuff
  • stressful
  • deal with multiple city departments
  • deal with residence
  • make city Domino great!

Qualifications

  • minimum: bachelor degree
  • must have over at least 5 years of work experiences
  • must have been a lead in a team
  • outstanding public speaking
  • must have experienced different fields
  • never feel tired

I don’t know, I just make those things up.

But here is what I think it’s important: a city leader should have least had some experiences in different fields, like working in an industry or a school or technology field, etc.. This person should not have a single source of experience, say, have been solely worked in an insurance company. Then it is very hard to convince me this person understand people in all other fields.

One exception may be someone who is a journalist, especially field journalists, who must go to different sites to interview all sorts of people, write stories about real life, and see everything happening in different places.

Step 2: Screening

I have done a few hiring events in couple companies. After job posting, normally recruiters will gather hiring manager and the team, present all the candidates, select a group of them, and then move to phone screens.

In this case, the hiring manager will probably be the city council, and then some key members of the city government. They arrange some time to conduct a phone screen with candidates. Those candidates could be recommended by the recruiters or nominated by the city members, as long as they have enough qualification, any resident of city Domino can apply too.

Once the screening (including background check) is completed, the best candidates will be invited for onsite interview.

Step 3: Onsite Interview

This will be interesting process. I suspect there will be no more than 3 or 5 candidates in this step. They will all come to city building on the same day to have a full day interview with minimum 5 rounds of interviews.

The interview could have:

  • behavioral questions
  • scenario questions
  • simulation, like going to a scene with some actors playing a story, then asking the candidate how to respond. It’s like behavioral/scenario question, but more realistic
  • knowledge-based questions: to verify the candidate’s background/degree/knowledge, e.g. if a candidate claims to know budgeting, we should verify it’s true.

Of course, there will be a question about what you will do after you are selected.

Each round of interview will be recorded.

Step 4: Decision

The decision is based on the interview, qualification of the candidate, and references provided by the candidate. Once the final decision is made, the recorded interview videos will be public on all TV channels. It is a way to show the selection process is fair and justified.


That is it. This is how city Domino finds its next Mayor.

Most public companies elect their CEO through board of directors. Only a small subset let all shareholders vote, even when that happens, the candidates are nominated by a group of major shareholders.

The key is, the candidates have a proven history of experiences in some fields, to demonstrate she or he can be qualified for running the mayor. If after the onsite interview, the hiring manager(s) and the team do not agree, then try again with another set of candidates.

Once a perfect candidate is hired, this person will stay in position and continue working as a mayor, until she or he decides to step down (or look for other challenges), or city decides to let her/him go. The city will provide help and training to make this person a better mayor, while this new mayor will have a sense of responsibility building a better city for the residents.

This is more important compared to must have one candidate from each party, and then everyone must be able to vote.

Honestly, who cares? When normal people don’t have food, when people don’t have a place to live, when a city can’t have roads, we need a strong leader to make it right, not everyone arguing what to do. Think about any team projects you have worked in. However, I cannot emphasize enough, this is NOT equal to saying: no one should raise their voice; this is ONLY saying: any group needs a strong leader to make the right/determined decision.

 

 

15th: Running a country is the same to running a big corporation

First, before exploring this idea, I would like to invite people to watch this video:

In this video, Graham describes an example of the bridge at the campus took   a few years to finish the repair. This is really common in United States. Another typical example is the light rail at Seattle. 21 miles was planned and approved in 1996. 23 years later, 2019 now, this city still hasn’t finished.

Why is that?

There are two reasons:

  1. Leader: the leader of the city is elected. He or she does not care too much the long term goal. In a few years, another leader will take over. Why bother? There is no need to be determined, to finish, to accomplish anything once elected.
  2. So-called “democracy”: most people think they have a voice, which has nothing wrong for sure. People should be able to express their opinion. However, people need to realize that a group needs a strong leader. If everyone keeps arguing, raising opinions, a group gets nothing done. I am not saying people should not raise opinion, I am saying someone in a group needs to be directing.

Then how a normal person’s voice bubbles up?

This leads to today’s idea:

Running a country/state/city is the same to running a corporation.

Why a company can succeed but other fail? Because of the decision of the leader, which is the CEO. Let’s use some positive examples: Steve Jobs, Howard Schultz, Satya Nadella. Those people lead the company to a right direction.

Of course, there are many negative examples as well: Steve Ballmer, Carly Fiorina, Eddie Lampert, and many others. Those people not only failed to deliver good influence to the company, but also put the company to a wrong way.

Are CEO elected. Sure they are. However, not directly by employees. And each leader (most of them) has a long history of outstanding performance and then gets nominated in the board meeting. Once the CEO is there, he or she stays until something bad really happens, or board votes to let him/her go.

This is applied to the leader of a country.

Let’s take Rodrigo Duterte as an example. Personally, I consider him as a strong figure who is very determined to do the thing he believe it’s right.

I am not going to debate if we can go with a different way. But he carried on his method as a leader.

Another figure is: Lee Kuan Yew.

Here, we are not talking about dictator. We are talking about the leader who is determined to execute actions for the group he/she is leading, because he/she believes the action is right.

A dictator is someone who does not care about his/her people, only sinks in the fulfillment of the power, temporary treasure and all kinds of other lures.

A leader is different.

Let’s use Seattle as an example. Why would any mayor bother solving the homeless crisis? Why can’t someone stay in position long enough to have a long-term plan, which makes sure he or she has enough time to solve anything? This person will have a sense of responsibility, not a short-term dummy because some companies sponsor the campaign. This person should have a proven history solving hard problems and long-term vision. Yes, give the person an interview, broadcast it to public, and let citizens know why he or she is chosen.

Maybe that will work.

That is just my opinion, and this week’s idea.

14th: Reading other people’s code will always be a bad user experience

First, my bold statement is this: reading other people’s code will always be a bad user experience.

The reason is simple: code readability is mostly subjective.

In year 2000, I had to set up Mailman for the company I was working and maintained the application for a few months. I remember when I first read its source code, I was so amazed how beautiful and elegant the code were. Today, I just tried reading some of them again, I was like, “that is not easy to read at all”.

This week’s idea is: I am making a list of standards when reading other people’s code.

(1) The reason of reading

I was exhausted when I tried to read the source code of Mailman again.  More importantly, I no longer have any need to understand it and I also do not remember how to write Python.

The motivation of reading the source code is probably the first important element. If I don’t have to run it, test it, and even maintain it, it’s unlikely I will ever like it.

The take-way message is:

Do not judge other’s code when you don’t have enough context unless you are going to take responsibility with it. 

(2) The stage of the project

I will give an example of this point. The example is written in Scala. Let’s say I have an entity like this:

case class Entity(field1: String, field2: Int)

I would like to validate the fields, so I can start with this simple class:

class Validation1 extends Logger {
  def validate(e: Entity): Option[Entity] = {
    if (e.field1 == "hello") {
      logger.info("I say hello")
      None
    }
    else if (e.field2 == 10) {
      logger.info("10 is a bad number")
      None
    }
    else
      Some(e)
  }
}

I hope it’s easy enough to understand. The problem of this version is: I have to do if-else statements and when I have more validation logic, this function will become very ugly.

Therefore, I can refactor it to the following version:


class Validation2 extends Logger {
  def validate(e: Entity): Option[Entity] = {
    for {
      _ <- noHelloRule(e)
      result <- noTenRule(e)
    } yield result
  }

  private[this] def noHelloRule(e: Entity): Option[Entity] = {
    if (e.field1 == "hello") {
      logger.info("I don't say hello")
      None
    }
    else
      Some(e)
  }

  private[this] def noTenRule(e: Entity): Option[Entity] = {
    if (e.field2 == 10) {
      logger.info("10 is a bad number")
      None
    }
    else
      Some(e)
  }
}

What I am doing now is: each rule becomes a function so I can use a for-comprehension to connect them together.

However, the problem of this version is: the class has 2 private functions and all of them have to be invoked inside the main validate function. If I need to add more validation logic, I will add one private method, and then update my main function. It’s annoying.

Hence, I can refactor one more time.

trait Rule[A, Result] {
  def validate(e: A): Result
}

trait EntityRule extends Rule[Entity, Boolean]

case class NoHelloEntityRule() extends EntityRule with Logger {
  override def validate(e: Entity): Boolean = {
    if (e.field1 == "hello") {
      logger.info("I don't say hello")
      false
    }
    else
      true
  }
}

case class NoTenEntityRule() extends EntityRule with Logger {
  override def validate(e: Entity): Boolean = {
    if (e.field2 == 10) {
      logger.info("10 is a bad number")
      false
    }
    else
      true
  }
}

class Validation3 {

  private[this] val rules: List[EntityRule] = List(NoHelloEntityRule(), NoTenEntityRule())

  def validate(e: Entity): Option[Entity] = {
    if (rules.forall(_.validate(e)))
      Some(e)
    else
      None
  }
}

In this version, each validation logic becomes a single class with a single purpose because it represents only one rule.  The Validation3 class has a local variable holds all the rules. I am hard-coding the instance of the concrete rules, but later I can use different approach to inject rules dynamically. For example, I can use config file or attribute decorating a rule class, and then use reflection or meta to discover them.

Now, the question to ask is: why the heck I would do the third option at the beginning of the project, or with only a few validation rule and each of them is just a simple if-else?

Wait, some smart people might interrupt me. The third option is not Scala, or not pure functional at all. They are probably right. However, the take-away message is this:

It’s better to avoid over-engineering at the beginning. Instead, focusing on how to get the requirements right and readable, as well as validating the implementation with stakeholders, as opposed to overly generalize or optimize the implementation in the early stage. 

(3) the context of the product and the company 

As I mentioned earlier, code readability is highly subjective. However, my personal belief is: all programming languages are the same fundamentally. Proper choice of algorithm and data structure, separation of concerns, and SOLID (or following some similar principles)  are more important than particular language syntax.

This should be particularly true when building commercial software. Writing pure scientific applications could be a different story. The reason is: after the product is launched, 6 months later, people might not remember what the code is about. Because of all kinds of staff turnover, for example, original dev team has been switched to a different department, or external team has finished contract, some new people will end up maintaining the code-base they have no idea of. Those poor guys could be as dumb as me, or they could be any level, but they need to be fast enough to debug and enhance the application.

Here is a bottom-line, especially for people do not believe it: business software needs to be maintainable and enhance-able by any software developer, as long as they know how to compile, code, and test. Therefore, the take-away message here is:

Depending on the type of the project and the company you are working for, simplicity is always the key. We are never writing code for ourselves. We are writing code for, one day, another person has to add a new feature to it or debug why it fails. Always KISS (Keep it simple and stupid), but flexible (so other people can easily change).


In conclusion, I believe we should refer to at least above 3 points before judging people’s code. However, as a software engineer, I know no matter what I say, people will always have this expression when they read other people’s code.

 

 

13th: Hunter’s Feeder for cats and dogs

I have a Siberian cat. She is beautiful, but like most other cats, she is a pain sometimes. For example, she refuses to eat wet food, unless I hold the wet food in my hands. I also have to try many types of dry food to finally settle down one brand.

I use this auto feeder. It dispenses specific amount of food at a specific time. The timer is defective, always moves slower. Other than that, it works well. In terms of dispensing,  it basically drops the food in a bowl.

PetSafe Healthy Pet Simply Feed Automatic Pet Feeder

Unfortunately, my cat is not really into this feeding style. As I mentioned, she loves to eat when the food is in my hand. But I am not really a big fan of that. She will still eat from the bowl, but usually she will meow a while, see I am not going to feed her with my hand, and then finally she will go eat them. She seems to be more happy when she can eat in her favorite style.

There is, however, another way she loves to eat her food. It’s easier to show what it is than describing it:

Food hunting

Basically, I glide a dry food on the floor, and she would chase it and stop the food, then eat it. It may be difficult to see the food in the GIF.

My cat loves it.

I think deep inside, she still has the hunting instinct. Siberian cats are said to be dog-like and love chasing small animals.

I hate to let her go outside, because of her long fur, which attracts a lot of mud and leaves, very difficult to clean. I guess that is the main reason of me feeling guilty and letting her to eat from my hands so many times.

But you see, I have to stop doing that. Then I have to do something with the other option. Chasing food down reminds me of this:

iFetch Interactive Ball Launchers for Dogs
iFetch Interactive Ball Launchers for Dogs

This is a little machine that launches a ball for dogs to chase.

Yes, we need a similar machine to let cats or dogs to chase food.

This machine, I name it:

Hunter’s Feeder

I am going to learn how to build something like this, but here is a list of features I am thinking:

  • shooting food in at least 2 different ranges, i.e. short distance and long distance.
  • alarm mode: rings to prepare dispensing food so the pet can learn the time is ready.
  • user setting: user can select when and the amount of food to launch.
  • rotating shooting head: the launch angle can be 360 degree.
  • visual detect: the machine will detect if there is any obstacle ahead before launching and automatically select a direction to launch.
  • self-learning: it can learn how to train a pet to start chasing the food further or to a different direction, always keeps the pet interested. Say if a smart cat realizes the machine always just launch food to one direction, she just stays there and waits, instead of coming closer to the machine and then chasing. The machine needs to have algorithm to avoid this behavior.
I don’t have to do it again

OMG, I love this idea.

Now I really need to learn some mechanical engineering.

12th: Another way to buy used cars and more

Here is this week’s idea: why are all websites sells used cars the same?

They all have something like this:

from https://www.autotrader.com

They all have this kind of control for the users to filter what they want. It is a reasonable assumption. This kind of control is used by the potential buyers. However, has anyone thought of: this kind of website is actually initialized for the sellers.

By that, I mean: a seller will have to first go to that website, enter the selling vehicle’s information, as detailed as possible. Of course, it is also possible that a web crawler can do this job. It pulls the information from all sorts of website and extract those data from the description.

Therefore, a website that sells used cars must first have used cars to sell, and then when potential buyers come, they will be able to search.


E-commerce Websites are the Same

In fact, not only used car websites, all other E-commerce websites are the same. They first have things to sell, and then they attract buyers to find them. They all start from the seller’s perspective.


Another Perspective

What if a website starts from buyers’ perspective?

Let’s use cars as an example again. Here is a potential user flow:

  • A user enters some basic criteria on what used car he/she wants to buy: the type of car, mileage, budget, etc.
  • Sellers who think they have the possible used cars this particular user likes will submit an application, almost like submitting a job application, including what his or her car is and why the buyer should pick his/hers.

You may say, isn’t it the “WANT” option on craigslist?

True.

But there are more.

  • The website then uses algorithm to pick a few most likely to be sold cars (the number is user configurable) and then presents to the buyer.
  • The buyer can choose to pick one from the list and contact the seller directly. They are free to complete the transaction with each other offline.

You may ask: hey, where is the revenue stream?

Here it is.

  • The buyer can opt in a service that assists you to complete the transaction. The assistance could include
    • legal assistance: help finish all the paper work
    • mechanic check assistance: help inspect the car and provide accurate estimate and negotiation
  • The seller can also opt in a service that pre-inspect the selling car, which will show a proof that the car has been inspected (on what date). This can increase the likelihood that the car gets picked by a potential buyer.

I think it will work.

Unlike the bidding from eBay, which must have the sellers first. This idea serves the buyers first. The sellers must “sell”. Every seller is like a salesman on this website.


Extend Further

Let’s go further from here.

What if every E-commerce is like that?

Here is a use case.

I want to buy a book case. Traditionally, I will go to Google to find what website sells book cases. I examine all different websites for all the book cases, and read the reviews of the book case, and then read the review of the website (unless it’s a big trust-able seller).

That is totally waste of my time.

What if I enter briefly what I want in the book case, say, I want 4 levels, wood, with a stair. It should be A meter wide and B meter tall.

Now, all the sellers to submit an application of their book cases. Sure, you can argue this will only work if the sellers (human) are actively monitoring the request. But think about the possibility that we can build a robots pulling the information from all sorts of website and then intelligently select the most possible items I will be interested.

I will be given, say 10 different book cases. I am free to click the item and go to that website to complete the purchase. However, I can opt in a service that uses machine learning to tell me if those items are priced accurately. This will be useful, especially if some of those items are second-handed.


Conclusion

The idea is, a website serves from a buyer’s perspective, reduces the noise the buyer could receive from traditional E-commerce approach, and offer intelligent service to facilitate the buyers to find the things they most likely fall in love with.

I seriously think it might work.

 

11th: Street Food and Thoughts on Homeless Crisis

Street Food

I watched a few episodes of Street Food on Netflix.

Very interesting to watch. I recommend it.

I grew up with eating street food. After doing dumb things (like doing karaoke, playing Mahjong or pokers with friends), we went to have late night feast. Street food vendors usually opened late, could go all the way to next morning. Even after midnight, I remember still seeing street filled with people dining.

It becomes rare these days now, because government starts to have regulation. Some streets still have it, but not the same as before. It was a very special age. The fragrance, the people, the sounds, and the lights, all of those complete a very unique dining experience, which cannot achieved from eating in a restaurant.

Just like the trailer says:

“If you want to taste real food, it has to be street food”


Seattle’s Homeless Crisis

On a total different topic to street food, Seattle, is infamous for its homeless crisis. Because of some special policy of this city, it’s said some other cities bought one-way bus fare for their homeless people to come to Seattle.

Fair enough, I am not against homeless, everyone has a bad day. I truly believe parts of homeless population end up in the situation due to a serious of unfortunate events, and they actually want to change, like having a home again.

This city government has been discussing again and again on plan for homeless. Some city councils just want to tax more to the rich people to solve some problems those city councils have no idea how to solve… every time I hear that again on the radio, this is my reaction.


The Connection

People still need to eat.

People have memory.

People also have skills.

For some people, they remember the food they have had; maybe it’s a food they love, or may it’s a food they remember from someone else.

Like I said earlier, I believe some of the homeless people really want to change the situation, and they probably are working hard on it.

Here is my idea: can this government allocate some funds that provide training and necessary resources to those people who want to change? For example, train they how to cook with a food stand, provide some tools and resources for them to prepare, and then lower the bar for them to run business.

In some areas, this city could open an area for night market. It is opened to public. Have some police watching as well, maybe at the beginning. It does not have to be limited to street food, it could be anything else. Maybe some homeless people love to make arts, or play music, or crafting. So the night market, by homeless people, sponsored by government, is not only a way for people who want a home again, but can also become a celebration of folk culture nightly and connect people together.

Of course this idea is very naive. From the bottom, the government is investing on people who want to work and contribute; instead of charging more from the top. Yes, the world is unfair: a small group of people appear to own large portion of the fortune in this world. But some of those people really worked their ass off to reach that point. They just happened to have the right idea at the right time, with the right vision and enough courage. We should not lay here and ask them to give us money, simply because they have more than enough. How is that fair?

The same thing is applied affirmation action bill. It is basically a legalized racism. Because Asians are over populated in many schools and work places, they want a law to enforce admission in school or hiring in work places must have even ratio of races. It implies they don’t even want to give a chance to people who are willing to work hard, or who have better qualification.

That, is why this city government does NOT want to invest in homeless people who want to change the circumstances.

10th: How cars talk to each other?

I came out with this idea while driving the other day.

The car ahead of me drove me crazy that day:

  1. It did not close the gas cap, so the cover was dangling, very uncomfortable to watch;
  2. It did it twice, NOT just once —- changing lane without using the signal. Once it cut me through, the second time it cut another car to different lane.

I was literally doing this gesture, twice!

So I was thinking: how can I communicate with another car, but the driver is a complete stranger?

I guess I could use hand gesture, like waving, which most people do when the car behind let us cut in. But in this case, I need to transmit more information.

What about something like this: Led Programmable Sign Board for cars?

car mounted rear LED message
car mounted rear LED message

I suppose it could work; however, I would have to first drive in front of that car, and then quickly punch the message I want to say, and then I have to make sure I stay long enough before the target car, so that driver can finish reading my message, since the message will be scrolling.

Honking, seems to be the only option left. But it will not be easy to reveal the message. For example, I believe we all have seen some cars forget the changing the turn signal back, or turning off the emergence light, or even in this case, leaving the gas cap dangling.

In the future, cars can probably talk to each to exchange information such as speed and distance, but without consent, cars can never forward a message from the driver, so humans in different cars can never really communicate.

I feel this is a problem…

 

9th: The Honesty Game – Part Two – the support and punishment social system

This is the part two of 8th: The Honesty Game – Part One – the game

Part one discussed a gaming system relies on aggregating social data from the player to grow the game character. It assumes the players opt in to share their personal information, so they gain the benefits like, growing their game characters with the player’s real-life activities, and exploring more interesting plots in the game depending on what the player does in real world.

There is always debate in how much personal data we are willing to sacrifice.

Big Data

In case you haven’t heard this buzz word enough, we can now process more data than ever.

A few years ago, some universities use big data to provide financial support to poor students. It does make sense, for a few reasons:

  1. Universities are relatively closed. They are like individual communities.
  2. Poor students are likely to dine in school’s cafeteria more than rich students.
  3. It is not hard to use data-driven analysis to understand which students are more struggling financially than others.

Can we go further?

Social Support

I don’t really want to talk about the depressing topic about homelessness.

However, imagine a city, where everyone has to use a card for anything, such as buying groceries, taking public transits, and using any public service (like libraries, or going to a shelter).

It will be very easy to understand which family spends more and which family needs more help or doesn’t. Won’t it?

Hang on, I know some people will want to say something. Allow me to finish next section.

HOV/bus-only lane cheater

If you lived in Seattle, you would probably have seen HOV or bus-only lane cheaters, a lot! The government has decided to raise the fine for repetitive cheaters. However, even radio show had discussed people would not care, if they value the time more than getting stuck in traffic.

The solution? Personally, I feel it should be proportion based fine.

For example, the first violation fine will be a fixed number. The second violation fine (say within a year) will be all of the money this person has in the month. Let’s say we collect the monthly income and spending data of a person, so we can get an estimation of this person’s monthly spending amount. This person’s fine for second violation will be the entire estimated monthly remaining, which should already exclude the spending on food and living expense.

To be more precise, let’s say someone usually has $1000 income, which needs to pay $500 for rent and $300 for food. The fine will be $200. Now another person usually has $20,000 monthly income, $5000 for mortgage and $1000 for food, so this person normally has $14,000 monthly remaining. Then this person’s second violation fine will be $14,000!

I guarantee no one will violate second time.

Socialism, Communism, or what?

Now go back to the previous section, if we really collect everyone’s data and provide support accordingly, is it socialism, or communism, or some-ism?

I don’t know and I don’t really care.

As a normal citizen, I probably share the ideas with many others. I am guessing most people want:

  • living safely in this world, with food and a place;
  • raise a family, protect our children;
  • make sure our children and their children have a home to live;

People questioning what kind of -ism are the people who have been living way too happy and comfortable. In the time people have no food or no home, who would ask those questions?

Honesty Game, or the social credit system, will it really happen?

Will such a system really happen?

Will our data all be monitored and analyzed by the government one day?

Actually, I am not sure if it has happened already or not. Some people may think it’s already happening, and it’s not just in China.

I lean to believe we will eventually enter an era of no more personal privacy. Maybe in a long time, maybe in just a  few years. It will be a game changer (pun intended).

 

8th: The Honesty Game – Part One – the game

This week I am off, so I decide to probably post 2 ideas, which actually source from the same origin. This is the part one and part two is coming shortly.

In 2012 after I left Price Industries, I spent roughly a year on thinking about my life. I built a website, went back to school and participated some researches again, and talked to a few investors about my bullshit ideas. One of them is this idea called: The Honesty Game.


The Game

I did’t really have a story outlined clearly. But this game is like Diablo or Warcraft. It’s typical that a player can choose strength-based, agility-based, or intelligence-based character, kill monsters and collect treasure. Of course there will be a story line why doing so, I haven’t figured that out yet. However, what makes the game special is how the character grows.

Small portion of growth is through the game playing, like gaining experience by finishing a task (inside the game). But large portion of the growth can be dictated from outside of the game.

This game allows the players connect their additional social accounts with the game. Those accounts will aggregate all data in real life to improve their game characters. For example, if a fitness account shows the player has done a run in real life, the game character will gain some strength; an aerobic exercise may gain some agility; sleeping well will gain some stamina; finishing a book, or even checking in at a bookstore may gain some intelligence.

There are so many things we can link from real life to the game, like where does the player go to (check in), what does the player buy, what does the player post in social network, even if this player has been paying his/her debit, all can not only impact the growth of the game character, but also impact the story line.

Privacy?

I don’t think I was the only person who came out with such an idea in 2012; I like to think there were many people way ahead of my crazy nonsense.

The whole idea is a little like Black Mirron – Nosedive, aired in 2016. But with more!

That’s why the game is called: The Honesty Game.

Everything you do in real life, needs to be honest, and will change how you proceed inside the game.

But of course, people will ask, where is the privacy?

I will always think this way:

  1. Do we really have privacy nowadays, or do we just have an illusion of having privacy?
  2. Are people willing to sacrifice their privacy, in exchange of benefits or convenience?

I give away my personal information (to a certain degree) when shopping on Amazon; so is using any other website, in exchange of the service I am receiving.

History tells us, shutting down the border of a country with other countries would not help growth (yes, I may be hinting something). I was referring to the Qing dynasty in Chinese history. They were so ignorant at the time and eventually got invaded by Western Countries hard.

Maybe today, people will still try to fight to protect privacy, actually they just try to fight to have the illusion longer. Eventually, maybe no one will care any more. Or maybe, one day, the controversial Social Credit System will be implemented. Even many Internet discussion are still laughing at it, it may not be a very bad idea after all. I will elaborate another idea related to it in Part Two.

But here is the thing:

Privacy or not?

We should always be allowed to have a choice.

People can choose to live off the grid, in a cave, social-account-less, or not to have any service, such as playing The Honesty Game.

Or they can choose to be enrolled.


Conclusion

I actually went back to China and presented The Honesty Game to a few people. They all liked it. Interestingly, they did not consider privacy as an issue. It’s China after all. Most companies are collecting people’s data already, and China is now almost a cashless country, which means many people rely on their smart device in daily life already.

The biggest issue, however, is having strong connection with the big player in the market, such as Tencent, Alibaba, etc.. Those companies control most people’s data, and then it’s the Internet censorship in China. We discussed how government will have to allow the game to be connected with all other data providers, and what type of challenges we may encounter. Not very straightforward unless we have big players involved.

The second issue was: I was not a game developer. I don’t really have any prototype or design to show. I only have a pile of BS.

Anyway, I still like this idea. I read a story a few days ago, and came to realize that this idea could actually be used in a different way. Check the Part Two.

BTW, if you are looking for a laughter. I just rewatched IT Crowd and found this episode about “Friendface” very hilarious. Kind of related to this topic.

 

7th: Can kids write a book?

I want to say the answer is definitely yes.

Totally biased opinion: I can’t describe how creative my little one can be. She is truly remarkable.

The other day, I told her I will be working in a different company. BTW, today is my last day of working at Starbucks. Enjoyed my years there, but ready to move on the next chapter.

I told her, the cafeteria in my new company serves unlimited pickles. I can bring you a pickle when I pick you up. (context: I am usually the one picks her up from school and she always wants a small piece of snack after school).

Next, she started talking non-stop with pickles. She always talks too much, which is annoying. People always say it’s better than a kid does not like to talk to people. I guess it’s right. She started talking pickles, making up conversation between two pickles. Yes, you read it right. She was using two different voices talking,

“hello, I am a pickle, my favorite food is pickle”;

“I have a sister and she is a pickle too”;

“you are a pickle, can I have a bite?”

Pretty much like that, non-stop. I was driving at that time, it’s hilarious and I told her, “you should write a book about it”.

I almost immediately regretted it, because she started making up background of the story and more pickles coming up.

It was annoying, but still hilarious; OK, I admit it, it was pretty awesome.


The Pickle Family cover

Once we got back home, she started her project. First, the book cover. It was very impressive, I particularly love the black dots she used, over the green color she chose. It is very pickle-ry.

The Pickle Family – first page

She tried to introduce the background of the main characters, i.e. the pickle family, who live inside a pickle house. Hmm, I don’t know how that will work, but it’s kind of interesting.

Then she made additional 4 pages, so basically it’s a book with 5 pages. The story is about the two little pickles go to school and then get a detention, after home, their parents are mad… but overall, the plot is completely not making sense. Every time we go to a trip and live in a hotel, she loves watching Disney channel (we don’t have cable at home), some of those shows on Disney channel are very off the chart. We just came back from a trip, it must be influenced by one of those shows she watched.


Anyway, now it’s the core of this week’s idea.

I love what my little one has done. It is very rough, strange, and the story is boring; however, I love it. I want to make it a real book.

There are apparently many companies doing it, of course

Interesting stuff. But I notice something: all of those providers are designed for adults. They all just offer the users to upload a picture, and then select materials, finally pay. These are all adult activities.

Of course, there are some other tools seem to design for kids:

But after I gave them a little try, ugh… not sure any child will really fall into it.

When I look at my kid’s book, I can see she put the most effort in her cover page, and then the first page. Later pages became more and more scribbled. It’s easy to understand: kids can be easily distracted, become inpatient, and lose focus and interest. I want to say most kids are like that, except some gifted ones.

The question then is: how do we keep the kids feeling intrigued during their work?


I  am a big admirer of Bret Victor. He is super smart and chill.

His this talk was my favorite:

Two take-away from this talk:

  1. We should have a principle for ourselves, believe in what we are doing and keep doing it.
  2. Seeing what we are working on is very important, because it provides instant feedback.

Both points have made a big impact in how I work.


When my kid was “writing” the book,

  • she was not receiving the instant feedback;
  • she had to do too much: thinking, writing, drawing and coloring;
  • she became tried (aka, bored) quickly after just couple pages;

That is it, we need an application for kids, which will provide instant feedback and keep the kids feeling interested!

I am calling it: I can draw a book

You can tell I am not very creative.


Application: I can draw a book

Settings

  • tablet;
  • stylus;
  • physical keyboard (very important, so kids can learn how to type);

Target Users

At least older than 6 years, who can spell some simple words and use stylus to draw.

Design

The application is designed to allow anyone to create a drawing story book with computer assistance. By computer assistance, I mean using artificial intelligence to help create characters when typing or drawing.

If you haven’t seen it, try something like this first:

https://www.autodraw.com/ 

https://quickdraw.withgoogle.com/

https://magenta.tensorflow.org/assets/sketch_rnn_demo/index.html

Basically, we almost have a certain level of intelligence to understand what the user tries to draw, or predict what the user wants to draw based on text.

Now imagine my daughter is writing a story about pickle family. She is typing (yes, her school is teaching them typing, she seems to like it):

“There is a town called pickle town…”

Computer will try to generate a small model of town, which matches the concept of pickle town, say having a flag with a pickle in it, or the town is all green, and so on.

When my daughter is writing down:

“Papa pickle….”

Computer will generate possible model of a pickle that looks like a man.

If the user likes the computer generated model, they just drag to use it in the book. Or the user can draw a shape of something, computer will generate what this shape might be. The prediction can change if the user keeps adding details to it.

Every model the user has used in the book can be saved to be reused later in another page. In the case the user wants the model to have a different gesture, the user can drag the existing model, starting draw shapes around it, the computer can try to predict a drawing with the existing model.

A quick mock-up may look like this:

If this application is initially designed to be used by kids, it needs to be very simple. It seems to be an interesting idea to run a user study with it.

 

6th: House hunting with matching furnitures

We have been house hunting lately, because I am about to switch job, hopefully we can move to somewhere in the middle of where my wife works and where I work. If we stay where we live now after I switch, both of us will be driving almost 2 hours a day. Sigh…

We have been seeing houses over a few months now. We both hope this next house will be our home for at least next 10 years, so we really want something perfect and give us a homey feeling. It will be OK to be less ideal or require some work, but we still have our visions and would need the bone of the house meet our expectation.

There are a lot of house listing website, such as Redfin, Zellow, or even MLS, they just give you a set of pictures. Most of those pictures are photoshoped, or taken from an angle giving the best impression. Once you are there physically, you will realize it’s actually smaller, or the layout is completely off the chart.

Some websites do provide a 3D walkthrough view, which is very nice. It does help us to understand the layout before going there. However, I always feel something is missing.


I think most house buyers will share the same intention:

We want to see ourselves living there.

But it will be dumb to put our pictures or hologram inside the 3D viewer. I am going to make this statement here: if technology is really evolving to a point that a home user can do a full body scan to generate a hologram, don’t use this technology to sell houses. That’s dumb.

What I want is: if I put our ideal stuff in the house, will it look like my home?

For example, I really want a pool table and a bookcase with ladder, such as this one:

Quick question: Has anyone else notice something annoying when looking for furniture, the furniture is never placed in your home?

Right, that’s why there exists AR application helping furniture buyers to place the furniture digitally in their own home to experience it. It is close to what I am looking for, but this requires the user must physically be there and own the place.

Now, I want an AI to fuse the house picture and the furniture picture together, using the data of both items, intelligently place the furniture at the most ideal room.

More exciting features are:

  • the AI will recommend if I should change the color of the wall, or choose a different color of the bookcase;
  • the AI will detect there is no room fits the bookcase I select, but will try to recommend a similar style bookcase (with a ladder) that is smaller and will fit in the house I am looking at;
  • the AI will recommend other furniture that can match the bookcase I just pick, with the understanding how much space I have in the room; for example, recommending a piano in a big room with such a bookcase is acceptable, but it will not do so if I move the bookcase in a small room intended as a library. And also, it will never recommend a dining table under this context.

I am actually not a big fan of houses with all the staging furniture. They usually look very nice, and once I move my own stuff in, the house suddenly is not so pretty (don’t judge my taste of furniture, if I know how to stage a house, I am not writing this idea at this moment).

This engine (fusing an empty house with furniture) will significantly improve the buyers’ experience (mostly, me). I will see how the house look like if I put my ideal items in it, can I see myself living there?

Of course my wife has some her own flavor as well. She also wants a study place for our kid. And we have some existing furniture. So the engine will allow users to upload some custom picture with dimension attribute (or hologram scan furniture, now this use case will not be dumb), and smartly place them in the house.


You may ask, wow, it sounds cool, but who would invest building such a thing? I believe home builders, real estate companies, or even designers, contractors, furniture companies all of them can benefit from such an application.

From my superficial understanding of AI and 3D rendering, this application sounds very complicated, but should be still feasible to do. I will leave this idea for other people to do. I was going to call this application “HomeFusion”. Ugh, the name is taken!

5th: Save my car

This is one of my old ideas.

In a nutshell, it’s like Uber of roadside assistance.

I once experienced a dead battery on a highway. After I called my roadside assistance service, who generally dispatched the request to a near towing provider. It took over 5 hours for the tow to come. We could not do anything but waiting under the sun and busy highway.


The idea is very simple, first, for the user, there will be a smartphone app.

The app is used to send request for assistance to a server, information include:

  • car model
  • problem description
  • photo
  • auto GPS location

The app will show how many providers nearby, accepted the request, and provided a quote to provide the service.

In the car service provider side, there will be a tablet placed in the shop. It will display a request sent to the shop with all the information. It will ask the provider to bid, or decline the request.

The service provider can offer an estimate based on the limited information, the bid could be a range, but must include how long it will take them to reach the client.

Once the provider starts leaving the shop and heading to the client, the feedback will be provided to the client so that the user knows the help is coming.


The benefits of this idea could be:
– save time to make phone calls (did I mention I had to wait for the phone to connect with the service provider?)

save time to describe problem and location (we could potentially use AI to determine what the problem is and sen save time to describe problem and location d the request to the service provider)

know who is coming (feedback is very important, did I mention when I was waiting, I had no idea how long it would take and if the help was coming?)

offer multiple providers (because the request is sent automatically to the nearby shop, we are not relying on a single point of provider. In fact, I would be so happy if a help could come earlier with some extra cost at that time).


Honestly, this sounds like a good idea. Unfortunately, I never get the chance to implement it. The real issue is, chicken and egg problem. How do I convince car shop to participate when I don’t have any client? How do I convince user to join the program when there is no provider?

I guess the most important problem is: I don’t have any funding to support this idea.

4th: My idea of presenting functional programming

Today I want to talk about programming, particularly, programming paradigm.

A quick background

I spent a year learning and writing Scala, which is a fascinating language. But I could not get my head around why we wanted to write functional way. And Martin Odersky even said this in one of his talk:

“if you have to inject dependency to your code, something is wrong”.

Probably not exactly the same words, but close enough.

After that year, I switched back to writing C#. Then I suddenly got a hit about why writing functional is such a joy. The code can be much more concise, so easy to write test, and naturally supports concurrency without using lock because no state is shared. Everything starts making more sense.

Give a talk about it

My current director asked me to give a talk about using functional in the project I have been working on. I told him yes, but I am not sure when I will have the time to do so. I actually like giving talk to the team. It feels like sharing your thoughts and learn from each other.

I did it on a few different topic after I joined Starbucks. I gave a presentation about my research long time ago in front of couple hundred people, I enjoyed it. Unfortunately, I always find it challenging to make the commitment  to become a regular speaker in conferences. I admire those people who can.

But how do I really talk about functional programming to the people who have never done this before, when myself is not even a guru of functional programming?

The other day when I was running, a few slides came up in my head. So my idea is using them, hopefully.

My potential slides

It is just a tool

First, forget about the word “functional programming”

forget about the word functional programming
forget about the word functional programming

It is possible that some people will be offended. So I have to make the claim that this is only my personal opinion.

Second, it is important to remember, “functional programming” is just another programming paradigm. It is a style, and it is a tool to write code.

We use the right tool at the right time for the right job.

It is the same idea that I will probably not use a hammer to mow lawn, even though it might work. I will use a knife to chop vegetable or meat, not a scissor, even a scissor will definitely do the job as well.

Choose the tool wisely.

So choose functional paradigm when the situation is right.

I particularly like  Anjana Vakil’s talk about programming across paradigm, if you never watch it, I strongly recommend it:

Different perspective

The following is how I believe most people consider a good software product:

If you Google “characteristics of good software”, pretty much the same thing.

  • Workable: the software is usable, in a working state, and it can realize business values;
  • Scalable: the software can be scaled in terms of performance, the number of users, as well as the number of business cases.
  • Testable: the software can be tested from the unit level.
  • Changeable: I like to say the word “changeable”, which means the team (not just the individual who originally writes it at the first place) can comfortably make change to the code. Others may prefer “extensible”.
  • Readable: The code is readable and understandable, or the software itself is well documented on the business case.

Note: extensibale and scalable are 2 different things here. If you notice, scalable is referred to the software can scale to more business cases, while extensible is referred to any developer can make change to the source code.

There is a reason a triangle being there.

The bottom is always “workable”. A software must work. If a software does not function, constantly crash, or does not deliver business values, nothing else matters.

Therefore, from a company’s perspective:

It is paying for a workable software that can deliver business values and meet business requirements. The biggest expectation from a company’s perspective is “it works”.

Next expectation from company’s perspective is, “can the software scale to meet more requirements”.

Generally, a company cares less everything else in the source code, unless that is a software company (maybe, hard to say, we all have heard how poor Oracle is written anyway). Therefore, no one will care how beautiful the code is written, or if it is using functional, procedure or imperative.

Only developer cares.

Actually, I probably should say only developers with self esteems care.

In contrast to the previous slide, the following is from software developers’ perspective:

Developers still care about the final product work. But we all know how easily a developer can be distracted in his/her own interest:

In the reversed order, developers care more about the things like how beautiful the code is written. Interestingly, the more ego the developer has, he or she is likely more focusing the things on top of the triangle.

Having developer ego is normal, in fact, it may be a good thing sometimes. It may not be sometimes though.

The funny thing about those things are important to developers, are naturally supported by functional paradigm:

  • Readable: small and single purpose functions, easier to reason the code logic, thanks to deterministic fashion.
  • Changeable: this may not be true for someone is new to functional programming; however, since FP advocates function composition, it is actually true that it is easy to make a change to composite existing function to make a change. Additionally, because it is designed to have no state shared and ideally each function is pure, it is less likely to impact existing business logic when making a change.
  • Testable: I did not believe this before, but it is definitely true that writing unit test for functional code base is way much easier and faster than writing unit tests for imperative style. No mocking framework is needed, and property-based testing is supported.
  • Scalable: One big advantage of functional paradigm is its strength in concurrency handling. Because it is so easy to make change, the source code can also be scaled to meet different business requirements.
  • Workable: nah, who cares if it works, it is beautifully written.

Not: functional code is generally/arguably considered hard to understand. That is actually caused by developer ego. As I mentioned earlier, it may or may not be a good thing. If the ego is too high, abusing functional style can be intimating for others to read. But it does not have to be that way.

What does it mean?

So we see company and developer have different perspective when looking at a software and its source code, but what does it exactly mean?

Of course, writing a workable software is the most important thing, because that’s what developers are paid to do. Also, because developers have ego, and different people like to use different paradigm, how do developers work together building a workable software product?

The answer is: modularization.

Other people may see it as Microservice architecture.

What?

Yes!

No matter we are building a client application, or a backend application, we will write it into small modules. Each module represents a business feature, and then we stitch them together.

Each module is communicated through contracts, i.e. events driven. Now each module can be coded in different paradigm.

Some module may be good to use functional paradigm because it has a lot of asynchronous processing, another module might be better to use imperative. It does NOT matter. A paradigm is just a tool. Use it in the right situation. I recommend to adopt functional paradigm in pure business logic.

Conclusion

This is an angle I haven’t seen very often:

  • writing modularized application so developers can avoid paradigm difference….

3rd: A painting in my dream

Only the 3rd idea in my journey, and I missed the date.

Initially, I planned the posting would always happen in Friday, so it would not interfere with my weekend activities. I guess I should now remove this rule. Friday I was busy in working out another idea at work, which seemed to be more important at that time. Saturday I was with the kid all day, since my wife had to work.

It comes out, it is actually a good thing.

Earlier I was going to post an old idea if I did it on Friday, but today (Sunday) I have a different idea.

I had a dream last night. A dream about a painting. I don’t know why I had such a dream, and I am also less interested in understanding what it implies. But it is an idea, which is, I should try to paint it in my later stage of life.

The painting in my dream is much sophisticated and complete. But overall, it looks something like this:

the painting in my dream
the painting in my dream

Basically, it is a person with a huge head, but very small body. In my dream, the person is simply just thinking. Yes, something like the thinker. But the illustration is much exaggerated (expanded). Unfortunately, when I sketched it, I had to put a desk and a computer in front of person, otherwise, it looks very weird.

The painting should be in oil. I am not sure if it is really the case in my dream, but that is what I think I will do.

The background, I am thinking I can use different shade of blues. I also want to make it a little more interesting. Maybe I first use light grey to carve some text first, and then on the top of it, I put the blue color. So through the shade, I can still see the text. Regarding the text, all I was thinking (at the moment I woke up and decided to put this as my 3rd idea) was the lyric from this song. However, to be further interesting, I want to have one line of the lyric, and then another line of source code in either Scala or F#. Random code, or real code from a real project, haven’t decided it yet. Or maybe just Javascript, which may expose more pain points.

A very close painting (I quickly search on Internet) is probably something like this one:

Unfortunately, when I showed my sketch to my wife. She asked if I was trying to draw this guy:

It gave me a double face palm.

Anyway, that concludes the idea of this week.

2nd: An App just pretends interacting with you

Ever since I decided to have this 1000 unrelated (aka useless) ideas, I was really looking forward to it. But then when Thursday comes, since I need to put one up on Friday, I get a little nervous, because I don’t know which one I should write.

So I dug my idea folder. I used to have a folder storing all those useless ideas. I found something laughable.

The original idea was:

An app similar to Slack. You create a channel in it. Next the app pretends many users joining your channels. But those are just bots. Now every time you (the owner) post anything, those bots will add reaction to your words, some bots will post a meme to the thread, and some bots may even post a comment to the thread.

However, it is important to note, all those bots will respond positively, such as “LOL”, “that is awesome”, “you are the best”, etc.

This app is called “Feel-Good-Channel” – an app with encouraging bots.

I even made a mock up of it:

Features

  • Any user can create a new channel anonymously.
  • Any user can enter an existing channel to see (but no right to post anything).
  • A channel is automatically deleted after the owner leaves.
  • A channel can only be persisted if the owner is a registered user and chooses to do so.
  • A channel will automatically attract bots to join.
  • A registered owner can configure if the channel allows other real users to post.
  • All bots will make only positive comments, reaction, or memes.
  • The owner will be given a short survey to rate his/her happiness level when exit the channel.

Additional Features

In my original notes, the bots will slowly learn from what the real users post and then improve the “feedback” style. Once the bots become mature, the bots may even leave if the owner does not produce enough information or does not appear to require encouragement. Finally, the bots could learn from multiple channels, and find people with similar problem and connect them, if consented by the users.

Why is it interesting?

I still find this idea interesting because it touches 2 intriguing areas:

  1. Natural Language Processing
  2. Artificial Intelligence

NLP is always a hard problem to tackle. I am guessing with the Cloud-based machine learning, at least now we have more choices and tooling.

AI plays a key role in this app. If you think about it, we are building a robot that can understand natural language as well as human emotion. That is pretty interesting and challenging.

In fact, there are studies and discussion around the world

I also remember when I was working in the HCI lab, I helped research on a project that uses computer game to track and improve children’s emotion.

Many paper focus on facial recognition to determine the emotion. It is relatively easier than relying on only text. However, there are some old studies in psychology talking about how to do so with people’s handwriting:

Pretty interesting read.

Is it really useless?

After I expand this idea a little bit, is it a really useless idea? I am not too sure now.

First, we know in modern age, people are more inclined to text instead of face-to-face communication. Second, we know teenage suicide rate has been increasing.

And teenage feel more comfortable to use app and text.

Assume a user really feels down and start using this app, and assume we have an engine that highly accurately interprets the user’s emotion through wording. Due to the privacy agreement, the app will not know what this person is and where he or she is. However, if the app is able to derive the emotion level and the user’s physiological state, maybe we can do something:

  1. The bots can determine this user needs a listener or not, if yes, respond accordingly.
  2. The bots can determine the right moment to be funny to cheer the user up.
  3. The bots can connect another user (if there is one) with the similar problem and prompt to connect them.
  4. The bots may send an alert to someone to monitor the scripts.

How can such an app really help? I am not sure. But hey, I can only put that much nonsense at a time.

1st Idea: 1000 unrelated ideas

For years I have been trying to write a blog. However, I was never able to find a topic and stick to it.

Sometimes I want to write about coding as that is really primary daily activity. Unfortunately I am really not a very smart programmer. After all, there are way too many of these blogs all over the places and they are way more helpful.

Sometimes I want to write about user experience, as that is what I studied at grad school and my passion. I once even came out this idea that I would take photo of every poor experience I encounter in the real world and share in my blog. This is definitely not a novel idea, because I am pretty sure I have seen someone’s website exactly like that. Later I realize that I will have to be a person who constantly travel the world to make that blog work.

One night, for no reason I suddenly woke up around 4AM. I checked my phone. In retrospect, it is probably a better idea not to put your phone near where you sleep. I noticed the phone recommend a post about Howard Shultz’s president run. I opened it and read it (again, didn’t know why I even did that). I felt pretty disappointed after reading it, so I seriously made a comment. If anyone is curious, here is the link to the comment and the post.

After making that comment, I closed my eyes, but all I was thinking was to say something about what I would do to the health care if I were the president of United States. Can you believe that?

Also, guess what, no surprise, I lost the sleep for the rest of that night.

The good news is, the very next day, I realize that who kind of person I have always been. I am a:
– day dreamer
– fantasizer
– unrealistic-er (?)

Basically, I am very good at nonsense, exactly just like my 7-year old daughter!

I should write a blog with nonsense as the topic!

I used to have so many nonsense ideas, some totally useless ideas, some Startup ideas, some funny ideas, maybe some even good ideas. I should put them together and write them up!

So here comes the first idea:

Writing a blog with 1000 unrelated ideas.

From 2019, March 1st, each week I will try my best to write up 1 idea (either I used to come up, or I will come up in the future), to 1000 of them. This should be fun. It serves no purpose or any intention, simply just want to see what I would gather in the end.

A simple question: how do I execute a command every minute?

This sounds like a trivial question, using a Timer of course.

However, here is a caveat: whenever the timer starts, we want the command to happen exactly at the beginning of a new minute.

This means, if the application starts at 10:30:05, we want the command to execute at 10:31:00, NOT 10:31:05. The next command should execute at 10:32:00.

Therefore, we cannot really just start a Timer with interval of 1 minute, because that does not really meet the requirement.

In this case, Observable.Generate comes to rescue.

 

DateTime previousExecute = DateTime.now; // initial time
var end = previousExecution.AddMinutes(3); // this is just a dummy end

	var obs = Observable
		.Generate(
			previousExecution, // initialState
			x => x < end, //condition 
			x =>
			{
				var diff = GetSecondsToNextMinute(x);
				var y = x.AddSeconds(diff);
				return y;
			}, //iterate
			x =>
			{
				previousExecution = x;
				return previousExecution;
			}, //resultSelector
			x => TimeSpan.FromSeconds(GetSecondsToNextMinute()) //timeSelector
		, TaskPoolScheduler.Default.DisableOptimizations(typeof(ISchedulerLongRunning)));

obs.Subscribe(i =>
{
    i.Dump("Triggered");
});

double GetSecondsToNextMinute(DateTime curr)
{
    var diff = (60 - curr.Second);
    return diff;
}

The above code will calculate the difference between the previous execution time and the next minute. The scheduler of Observable will tick after the selected time passes until the stopping condition is met.

Why is it useful?

This is interesting because we can now create a scheduler in code to execute a command exactly at midnight.

Here is the complete code:

        public static IObservable DynamicDaily(DateTime startTime, IScheduler scheduler = null)
        {
            double d = GetSecondsToNextDay(startTime);
            Log.Debug("Daily Observable starts at: {StartTime} and waiting for {Tick} seconds from next day", d, startTime);

            DateTime lastExecutionDateTime;
            IScheduler sc = scheduler ?? TaskPoolScheduler.Default.DisableOptimizations(typeof(ISchedulerLongRunning));

            var obs = Observable
                .Generate(
                    startTime, // initialState
                    x => x < DateTime.MaxValue, //condition
                    x =>
                    {
                        double diff = GetSecondsToNextDay(x);
                        DateTime retval = x.AddSeconds(diff).Date;
                        return retval;
                    }, //iterate
                    x =>
                    {
                        lastExecutionDateTime = x;
                        return lastExecutionDateTime;
                    }, //resultSelector
                    x =>
                    {
                        double diff = GetSecondsToNextDay(x);
                        return TimeSpan.FromSeconds(diff);
                    }
                    //timeSelector
                    , sc);

            return obs;
        }

        private static double GetSecondsToNextDay(DateTime dateTime)
        {
            DateTime nextDay = dateTime.AddDays(1).Date;
            double diff = (nextDay - dateTime).TotalSeconds;
            return diff;
        }

We can use a TestScheduler to test the above function.

The difference between Immutable and Readonly Data Structure

Persistent Data Structure

A persistent data structure is referred to a data structure whose underlying structure cannot be modified. Every modification will result in a new instance of the type with the updated values. In another word, such a data structure is immutable.

Why do we care?

In short, it’s all about parallelism. Google and read why we want to write code running in parallel.

Because immutable objects cannot be modified, it forces each thread of the program uses its own copy of data, which facilitates safe, correct, and concurrent code support parallelism.

Shared and mutable data structures, on the other hand, require synchronization, which is accomplished by locking the object, and normally has the following challenges:

  • very hard to reason about what will happen in run time;
  • very hard to debug and write unit test;
  • potential race condition;
  • possible deadlocks;

What about Readonly Collection?

In C#, Readonly Collection, is a wrapper for the underlying collection type. For example, ReadOnlyCollection<T>, which is a wrapper of List<T>. The ReadOnlyCollection will prevent being modified; however, if the underlying collection is modified, the ReadOnlyCollection is changed too. The following code snippet shows how to update a ReadOnlyCollection (run this in LinqPad):

List dinosaurs = new List();
dinosaurs.Add("Tyrannosaurus");
dinosaurs.Add("Amargasaurus");
dinosaurs.Add("Deinonychus");
dinosaurs.Add("Compsognathus");
ReadOnlyCollection readOnlyDinosaurs = new ReadOnlyCollection(dinosaurs);
readOnlyDinosaurs.Dump("Readonly Dinosaur");
dinosaurs.Dump("dinosaurs");
dinosaurs.Add("Gozilla");
dinosaurs.Dump("modified dinosaurs");

// this so-called readonly collection is now modified
readOnlyDinosaurs.Dump("Readonly Dinosaur");

In contrast, ImmutableList is a Persistent Data Structure. It will return a new instance of a list with the updated values, but the original list is intact.The following code snippet shows what the difference is:

List dinosaurs = new List();
dinosaurs.Add("Tyrannosaurus");
dinosaurs.Add("Amargasaurus");
dinosaurs.Add("Deinonychus");
dinosaurs.Add("Compsognathus");
ImmutableList immutableDinosaurs = dinosaurs.ToImmutableList();
immutableDinosaurs.Dump("Immutable Dinosaurs");
dinosaurs.Add("Gozilla");
dinosaurs.Dump("modified dinosaurs");

var modifiedImmutableDinosaurs = immutableDinosaurs.Add("T-rex");
immutableDinosaurs.Dump("Immutable Dinosaurs");
modifiedImmutableDinosaurs.Dump("Immutable Dinosaurs");

What about performance and memory space?

Since updating an immutable list returns a new list, does it mean it will take more memory space? Not really. To understand this, the best way is going through the implementation of ImmutableList at here: https://github.com/dotnet/corefx/tree/master/src/System.Collections.Immutable/src/System/Collections/Immutable

Internally, ImmutableList is a LinkedList with a strategy called “Shared Structure” or “Structure Sharing”. Basically, it means, all (Immutable) copies of the original list  share some nodes. In the above example, immutableDinosaurs and modifiedImmutableDinosaurs share 4 nodes, but modifiedImmutableDinosaurs has one additional node. The variable of an immutable data object is just a reference of the head of the linked list. Therefore, there is really no significant extract space allocation.

How can it be thread-safe if we can actually update it?

You may notice that multiple threads can access the same immutable object. Because it always stays the same, “updating” it from multiple threads is safe with requires no lock. After all, all threads will simply perform just read operation. However, when a new list is constructed, a technical called Compare-and-Swap (CAS) is used. This operation is atomic and the outcome is either done or not done. CAS is a machine level instruction that requires no lock using a shareable object. Google for more details if interested.

Other Thread-Safe Data Structure?

.NET has many other data structure support thread-safe processing, including Concurrent Collection (ConcurrentBag, ConcurrentDictionary, etc), which is designed to work better in concurrent computation.

Concurrency vs Parallelism

To understand those 2 concepts, we first should understand what sequential computation is. Actually, I believe everyone can easily understand what a sequential computation is:

Concurrency, on the other hand, is referred to 2 or more tasks are executed at the same time. Using Barista taking orders at a coffee shop as an example:

The barista can perform grinding bean and boiling water those 2 tasks concurrently, and then move to next task(s). Those 2 tasks are independent to each other.

Finally, Parallelism can be seen there are more than 2 baristas, so we can server more customers in parallel.

Final Words

In sum, using immutability offers

  • lock-free and thread-safe implementation;
  • enabling shared structure to minimize GC effort, resulting higher performance in parallel computation;

C# has mutability as default behavior, but interestingly, the implementation of string, is actually immutable.

F# on the other hand, is default to immutability, meaning, every variable is immutable. Changing it will result in a new copy of it. There is no null. There is no need to lock.