Tuesday, July 18, 2017

Mouse Cursor Gesture Detection

Uses a neural network programmed "from scratch". You can do up-down motions, left-right motions, and large clockwise motions with your mouse. The neural net was trained on real mouse cursor gestures. See the GitHub link below for more info. Try it right in your browser! 
See and edit the code live: Codepen
More info: GitHub



Original Art

Thursday, July 6, 2017

Make Your Own Word Inventor

Markov Word Generator

Give it words from a dictionary, and it'll create made-up words that have the same "feel", as if they're from the same language. (Also works on made-up languages like conlangs.)

The original inspiration for this project came from a YouTube video (en français): https://www.youtube.com/watch?v=YsR7r2378j0

Use It:

  • Install Python2 or Python3, numpy, and click. Macs should have Python2 installed already.
  • Download the folder from https://github.com/hchiam/word_gen (look for the clone or download button) and go to that folder using Terminal/CLI/Bash.
  • Then run this command (you'll have to wait a little while it processes your data):
python make_map.py && python create_words.py

Note: That little "&&" runs the second python command only if the first python command works. You can just re-run python create_words.py without having to run the other one (if you didn't reset the input words in input.txt).

Input data file: input.txt. Put at least about 30 words here to have the algorithm working, but maybe over a thousand to get more robust/realistic results. You can get real word lists from the Gutenberg project.

Output data file: output.txt. See your words get generated here! :)

You can see the original code here: https://sciencetonnante.wordpress.com/2015/10/16/la-machine-a-inventer-des-mots-video/
(I just cleaned things up more after forking https://github.com/scls19fr/word_gen).


Original Art

Wednesday, February 22, 2017

10 Programming Data Structures and Algorithms - in Pictures

I've been studying

...I know, doesn't sound that interesting, right? Well, I noticed that, while studying, I started drawing "icons" to remind myself how each concept works---and to do so quickly

(Plus, I just find sketches more interesting to look at than text anyways.)

There are a lot of data structures and algorithms out there, some of which I just need to brush up on, others are entirely new to me. It's easy to lose track of the important details when there's a lot to catch up on.

I personally find it much easier to quickly scan a visual than to read the same thing in text. So with my "icons", I don't have to re-read the walls of text in my notes (and potentially forget details when I need to code on the spot). Maybe you might find these pictures helpful for review, or as a starting point.

The idea is similar to the visual memory-aids I made for an earlier post on learning more efficiently. Deeply learning and connecting concepts can help make memories more robust.

As a final thought, you might find it helpful to also use the method of loci, to keep track of all the concepts under one roof in your mind (with some branching to group details together to each concept). 

For example, my living room couch is my "location" for the hash table. From there it's easy to visualize the insert, delete, search, and rehash functions---using the pillows. Different parts of that couch also serve as reminders of member variables, etc.

Not actually my couch(es). Image from Wikipedia.

Now, without further ado, here are "icons" that serve as visual summaries for ten computer science concepts. Enjoy! 

Search Algorithms:


#1. Interpolation Search:


#2. Binary Search:


Sorting Algorithms:


#3. Insertion Sort:


#4. Shell Sort:


#5. Quick Sort:


#6. Merge Sort:


Data Structures:



#7. Stack - Array Implementation:


#8. Stack - Linked List Implementation:




#9. Queue - Array Implementation: 


#10. Queue - Linked List Implementation:



Chinese Learning Projects:
 - Book
 - HSK 1
 - HSK 5

Wednesday, November 16, 2016

Learning Faster and Memory Structures

Make effective connections.


Learning Faster

The idea is this:  the more effectively you use your time to learn something, the less time you have to spend on reviewing it (i.e. "reviewing" what you thought you knew in the first place).  Here are four steps in the "Feynman Technique" (based on a post from Medium) that could help you more effectively learn an idea that is new to you:

Step 1:  Teach it [as if] to a child.
Step 2:  Review.
Step 3:  Organize and Simplify.
Step 4 (optional):  Transmit.

I personally would addTest it.  Apply it. 

And based on a post from LinkedIn:  
When you learn something, check that you can actually do a few things. 
an you...:  Understand it? 
Explain itRemember it so you can use it later? 
...Use it in real life? 


Now here's all of the above info, re-digested and re-combined into pictures:

Step 1: Link "New" Idea to "Old" Idea
Step 1Take a new idea (usually an abstract idea, or at least an idea that's "new" to you) and link it to an "old" idea (something concrete and/or that you personally understand well already).  There's at least three ways to do this.  You could directly relate the new idea to something you learned earlier (if that idea was well understood in the first place).  Or you could substitute the new idea with a more concrete one by using an analogy or metaphor.  Or you could (try to) put the new idea into simpler words while still capturing the same meaning (just trying to do this can help test how well you understand something, as if you were trying to explain something to a very young child.)
Step 2: Make a Cohesive "Story" out of the Ideas
Step 2This builds on step 1Connect the new ideas together into one "story", like how different ideas in a textbook can build on each otherLike how different pieces of a puzzle can be put together to tell a bigger story.  Like how different parts of an assembly line contribute to the final product.  Like how different moves in a game help you to win.  Like parts of an organism or a chemical pathway or a movie or a song.  It should flow naturally as if it were one story.
Step 3: "Tell" your "Story" to Someone Else
Step 3:  Tell your "story" to someone else.  Actually try to explain the ideas to someone else.  Or pretend to explain it to someone (ever heard of "rubber ducking"?).  Either way, this can help make sure you know the ideas well enough by forcing yourself to organize your ideas so that someone else can understandPreferably find a beginner who doesn't already know the subject.  And see if they can explain it back to you---in their own words.
Step 4: Use it and Test it
Step 4:  Test it.  This is another way to check for gaps in your understanding.  Actually see if your explanations are helpful when the ideas are used in real-life.  Don't just feel satisfied that people like your explanation or that they can tell it back to you in their own words.  The ultimate test is to use what you know and understand, to do something with it.  And isn't that why you're learning it in the first place?



Memory Structures 

The structures in those pictures are quite similar to the structure of some mnemonic techniques (i.e. similar to the structures of different ways to help yourself remember things).

Visually, they remind me of machine learning and neural network connections, but also can serve as "schematics" for memory and understanding.

The table below shows my visualizations of five memory techniques I've seen before (link, sub, story, peg, loci)*, plus one "new" visual I've thought up for remembering branching information (I don't really know what to call it besides "branching memory structure").

Visuals Examples Example Uses
A grocery list (milk, apples, and cash) can become a ridiculous but memorable mental image that can be described as "a cow made of apples eating grass made of money---so money doesn't grow on trees". For lists of visualizable items. Or for "attaching" reminders to objects you'll see in your home or surroundings.
The state of Kentucky becomes "KFC food". Or "nihao" becomes "knee how" (homophones). Or conifer tree becomes your friend Khan or Connie is suddenly made of cones (head partial homophones). Or Nevada becomes a "new Vader". For remembering definitions or translations by turning abstract words into visualizable or concrete items.  The free website Memrise "automates" this with crowd-sourced memory aids for vocabulary.
= Substitution + Link For a list of abstract words that are new to you.
Make use of how numbers and letters have built-in order. "One" rhymes with "sun", two with shoe, three with tree. Or A is for Aladdin, B is for Batman, C is for Cookie monster. You then use the link method to attach items to the visuals already associated to each number/letter peg. Example: Aladdin drinking milk, Batman slicing apples, Cookie monster eating cookies shaped like money. For longer lists where the order might matter. You can still recall and test yourself on items out of order once you establish your own pegs. Also for main ideas of a script, book, presentation, etc.
Loci / Journey / Mind Palace
Similar to the pegs method, but instead uses spatial memory pegs that are real-life permanent items in a room you're familiar with, and those items numbered clockwise around the room, and extending to other rooms in your house. Example in my room: 1=window, 2=bed, 3=shelf. --> Milk splat on the window, pile of apples on the bed, cash exploding out from books on the shelf. For even longer listsFor the main ideas in a script, book, presentation, etc.  You recall or practice by mentally "walking" through the numbered path in your house.
(Branching memory structure)
Example: broadleaf trees can be divided into opposite-branching and alternate-branching leaves. This can be visualized as a brood Zerg having opposing claws and a tail that wags alternately back and forth. Further sub-divisions among opposite-branching trees are visualized by that opposing brood Zerg claw scratching Optimus Prime, who has a hand holding a SIMS character (simple leaf) and has a foot kicking a compound inmate (compound leaf). For branching information, like in tree identification.

 (If you can think of a better name for the last one, let me know!)

Final thoughts:
Without scrolling up, are you able draw down on paper one thing you've just learned? 
Choose just one idea and try putting it to use.

* You can see more examples and details at:  

Lorayne, Harry, and Jerry Lucas. The memory book: The classic guide to improving your memory at work, at school, and at play. Ballantine Books, 2012.

And for a 7-minute video on Sherlock's Mind Palace: 



Original Art