Sunday, March 4, 2018

Command lines for launching a web page at amazon web service

As an amateur web developer-like person, ​I needed a blog post that shows how to launch a web site in Amazon Web Service. I made one!

If the commands at the below are followed, a django-powered webpage gets created. After finishing these steps, this app can be a nice starting point for building your web app idea, by adding in your html files and back-end python codes. 

-These commands require you have a completely new unused Ubuntu instance at AWS. Follow this  
  • Choose 'Ubuntu Server 16.04 LTS (HVM), SSD Volume Type - ami-66506c1c' or something like that from Step 1. 
  • For Step 6: Configure Security Group, click add group and choose HTTP. The proceed to the next. For source field, it should be like, ::/0
  • When you launch ubuntu, you must download and save the pem file for ssh. Also the pem file security should be secure. This means you type in:     chmod 400 your.pem
-You have a linux terminal or anything that allows you to do ssh and sftp. My desktop is ubuntu-powered PC as well. You could use psft or putty for windows ( Below are versions of the involved software/server but maybe not that important. 
-This assumes you know how to do basic vim commands for editing codes. 

--------Ubuntu Version-----------
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
--------Python Version---------------
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
--------Apache Version -------------
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Jan 14 2016 17:45:23
--------Django Version---------------
(1, 7, 0, 'final', 0)

----------------------------------------Start. -----------------------------------------------
------ssh into AWS ubuntu, following the ssh command provided by the aws launching tutorial.-------------
sudo apt-get update
sudo apt-get install apache2 
sudo apt-get install libapache2-mod-wsgi
sudo apt-get install python-setuptools
sudo vim ~/.bashrc

------------- Using vim, put in the following three lines of codes and save the code---------------
alias re="sudo /etc/init.d/apache2 restart"
alias ee="sudo vim /var/log/apache2/error.log"
alias dc="sudo vim /etc/apache2/sites-available/django.conf"
--------------Exit vim after saving --------------------

sudo mkdir /var/src
------In your personal PC, download django 1.7 -------

------sftp  into AWS ubuntu and put in django --------
put Django-1.7.tar.gz

------ssh into ubuntu again ---------
sudo tar xzvf Django-1.7.tar.gz
cd Django-1.7
sudo python install
cd /home/ubuntu startproject website
cd website/website
sudo rm
sudo vim

----------------- Using vim, PUT THE FOLLOWING INTO

import os,sys

apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

------------------------exit vim after saving the code.-----------------

cd /etc/apache2/sites-available/
sudo vim django.conf

-----------------PUT IN THE FOLLOWING---------------------- has to be changed to your ubuntu server's web address ----------------

<VirtualHost *:80>
Alias /static/ /home/ubuntu/website/static/

<Directory /home/ubuntu/website/static/>
Require all granted

WSGIScriptAlias / /home/ubuntu/website/website/

<Directory "/home/ubuntu/website/website">
Require all granted

------------------exit vim after saving the code -----------------
sudo a2ensite django.conf
sudo /etc/init.d/apache2 restart
cd ~/website/
python startapp go

sudo rm ~/website/website/
sudo vim ~/website/website/

----Put in the following into your
from django.conf.urls import patterns, include, url
from django.contrib import admin
from go import views
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = patterns('', 
    url(r'^admin/', include(,
)+static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

----------------exit vim after saving the code ----------------------
sudo rm  ~/website/go/ 
sudo vim ~/website/go/ 

--------------------------PUT ----------------------------
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
import random
import re 
from django.http import HttpResponse
def index1(request):
    return render_to_response(


-------------------exit vim after saving the code----------------------------
sudo vim ~/website/website/ 

-----------------Do not cut and paste the following. Just edit accordingly. The variable ALLOWED_HOSTS, and INSTALLED_APPS  are already in ~/website/website/  ------------------------------



---------------Do not close vim yet. Now cut and paste the following two codes into the code-------------------

TEMPLATE_DIRS= ("/home/ubuntu/website/go/template",'')
STATIC_ROOT = '/home/ubuntu/website/static/'

----------------Now exit vim after saving the code------------------------

mkdir ~/website/go/template/
cd ~/website/go/template/
vim bibindex.html

***********PUT ****************
<!DOCTYPE html>

<h2>I love yeasts</h2>
<img src="/static/pic_mountain.jpg" alt="Mountain View" style="width:304px;height:228px;">

*************exit vim after saving **************
mkdir /home/ubuntu/website/static/
cd /home/ubuntu/website/static/
mv xl_2116_yeast-tp.jpg pic_mountain.jpg

Now go see that web site with the yeast picture. (Sorry I am a yeast biologist). From here you start developing your own django web app!

For Django tutorial, go to Django 1.7 tutorial on the django website to understand the codes above.  
For html tutorial, go to W3 school website. You can totally do jQuary, Javascript and others. 

If you liked the post, please donate to UNICEF at below link:

Thursday, December 4, 2014

Idea fragment for business idea

Someone created a dent on my car. She had to pay for repair. But if someone else totals my car, the first person does not have to pay at all....

This can be a shadow of a bigger and interesting business idea. I am not suggesting the destruction as business idea. But.... I don't know, this idea can be related to something else...

Wikipedia of experimental automations

Create a website collecting user-created contents/ideas/instructables for experimental automation in liquid handling. They should be modularized for maximal scalability+flexibility+'interconnectability ' ......

Sunday, September 28, 2014

Humor recommendation app idea

Make an app containing speech recognition functionality and humor database so that the app can provide real-time recommendation of jokes based on the content of the conversation of the user. You are not funny? There is an app for that!

The database would be:
The speech recognition functionality would be:

Tuesday, February 4, 2014

Arduino for Yeast Fermentation

For hobby electronics person like me, arduino is a very fun to play with. Simple coding combines any electronical input and output in any way you want so that  interactive devices can be made. We (hobby electronics people) love the cheap price of it: $25.

I am a student studying yeast fermentation, and we use this device called 'PLC' (Programmabel Logic Circuit, sounds intimidating yeah) to automate parts of the fermentation process. The industry uses this for fermentation processes too. Basically, capture electronical signal from the fermentor indicating its concentration of gas using PLC and send a signal from PLC to control another gas pump to maintain the gas level in the fermentor. This is the photo showing the PLC (the giant monster at the left) next to Arduino, and the fermentor that I use (at the background).  So the machine is much bigger and more expensive (~$500 vs $25). I have been playing around with programming PLC these days..

But you know what? I found you can do the exact same thing with Arduino. Arduino can take industry standard current or voltage signals and send out current and voltage signal in any way you want. The programming is much cleaner and interesting than PLC's. (PLC takes in this 'Ladder Diagram' programming that any programmer might feel very awkward.) So if I were that person in the industry, I would totally consider using arduino for yeast fermentation process development research. With Arduino, it saves you a lot of money (~$500), and it is much more flexible to program.

Since I am nearly the only person in the fermentor lab in an academic institution, I can do whatever heck I want with the fermentor including implementing arduino. Yeah you know what I will be doing next... I am going to make the Arduino the commandor of this thing:

Sunday, October 20, 2013

How to make the LED guided piano teaching device

Hi there, here goes the manual. (Here is more important manual for your life)

First, I made an android app for the LED guided piano. I am sharing the code at a Github. This android app  parses *any* piano MIDI songs and convert the data into data format for driving the IOIO OTG board.

Materials needed:

2 Meters of LED Strip (WS 2801 based) 
Your android phone.
Micro USB Type A to Type B cable (For connecting your phone to IOIO OTG)
Soldering Supplies.
Breakable pin header.  (This goes to IOIO OTG and LED Strip. This is actually important)
Lots of short jumper wires (female to female)
5 volt 1A power supply and corresponding power jack
(So power supply powers the IOIO OTG, and IOIO OTG directly powers LED strip)
3M Double Sided Tape  (For attaching your LED strip to Piano)

Three critical notes.
The 2 Meters led strip is cut into three parts. One part for powering 20 black keys, one part for powering 21 white keys, and one part for powering 5 black keys and 15 white keys. This is because IOIO OTG can send only 64 bytes of data which correspond to controlling 21 led lights. So this is the setup. Three strips are controlled simultaneously. 

The way you attach the LED strip to the white key. Do not set tapes on every single white keys
For black keys you have to cut the LED strips into pieces of three LED lights and two LED lights to accomodate for distances between the black keys. Also use pin header to connect the LED strip to jumper wires. You do not want to solder the jumper wire directly onto the LED strip because the LED strip can tear easily.

How to connect from IOIO OTG to LED strip:
Solder the pin headers onto the pins of IOIO OTG and LED stip. Connect the headers using female-to-female jumper wires. Here is the setup.

This is the Java code within the android app that tells the IOIO OTG to use pin 1,2 for strip 1,  and pin 4,6 for strip 2, and pin 10,11 for strip 3.

    white= ioio_.openSpiMaster (27,4,6,15 ,Rate.RATE_50K);
    black= ioio_.openSpiMaster (28,1,2,16 ,Rate.RATE_50K);
    three= ioio_.openSpiMaster (29,10,11,17 ,Rate.RATE_50K);

This is the explanation for each input for the above java code.
 spi = ioio.openSpiMaster(misoPin, mosiPin, clkPin, ssPins, Clock rate;

ioio.openSpiMaster does not serve 'null' for the case there is no misoPin or ssPin, so we have to specify misopin or sspin even though they are not used.
pin 27,28,29,15,16,17 are not used.

Monday, October 14, 2013

Use Bacteria for Communication

For security reasons, electromagnetic wave might not be feasible for communication.

Use bacteria. Recombinant technology can put any DNA into bacteria. Write your message into bacteria using DNA, and send the bacteria to the receiver through air, water stream, or dirty surfaces.

Friday, October 4, 2013

LED Guided Piano Playing

I built a piano teacher. I installed LED light on each piano key and turned on and off each of them to show which piano key to press for any given song. (So that any novice should be able to play piano) I don't play piano at all, and this is me playing piano with the help of the device I made. This should not be too hard to build. You will be able to see the instruction manual on how to build this device in 1 or 2 weeks from now. Android app driving the LEDs will be provided as well. As far as I know, no one made this before and I am an amateur, so it had been such a roller coaster ride building this without instruction manuals. But I wanted this device badly enough. It was fun overall. Post your comments here if you have questions.

Saturday, May 4, 2013

Cosmetics I Really Want to Build

There is something I would kill to make. Really.
Currently, girls wear beautiful cosmetics. They are wonderful. .. but they are static. Once drawn, it stays there as it is. But wouldn't it be GREAT if it changes? I mean wouldn't it be great if we can 'spray' special LCD material onto human face so that LCD screen on human face can, like a TV, display absolutely dynamic & beautiful art patterns in the form of motion pictures?

 Yes, it is impossible. But as soon as I find such 'sprayable' LCD materials in a distant future, I am going to make cosmetics out of it. For now, maybe I can make just an LCD mask with flexible LCD like this.

I hope they are not too expensive for hobby projects....

Monday, April 29, 2013

Automated Piano Lesson with Embeded Systems

To learn Piano, it costs a fortune to hire a pianist to get lessons. So I am building piano teaching device that costs under $70 to teach myself Piano.

The basic idea goes like this: install one LED on each Piano key and turn each LED on/off to show which key to press down for each note in a song. The implementation involves an Android Phone, IOIO Board, and an LED module. I thought I was the only one who came up with the idea but it turns out there was a startup company based on this idea. Booohh

Android cannot control shift registers by directly sending out bits. Intermidiary is needed so the system like IOIO board is needed.   The project is nearly done so I will post a youtube video of me playing piano with the LED module. Standard music media format MIDI is parsed within anroid phone to send bits to the shift registers. This  can be done with external java library found by googling.

This is the photo showing the IOIO board+74HC595 Shift Registers+ Arduino Board. Why do I need Arduino board? Well I forgot to buy power supply so now Arduino's 5V Pin/Ground Pin is being used to power IOIO board. LOL. Above all, JAVA is needed to program Android and even for driving IOIO board. 

(Edited 10/9/13: Comment here if you have questions about the setup.) 


Wednesday, April 24, 2013

Python Powered Bible Reading

For Church, it is good for the church members to read the Bible everyday. 

Previously I made a python script to parse and analyze the Bible. So I launched it into a web application serving my church: if you submit your email address, everyday the web app sends HTML email containing daily bible verses.

The website is powered by Django (Python) on Amazon Web Services EC2 micro instance (Free.)  The server contains the Bible in text file so I made a python script to parse and load into Django.  The script has to run permanently so I used 'sudo nohup python &' command found by google search. The beautiful looking front end is not my work. I downloaded the template from this website. The hardest part was parsing and using Korean language within python and html. I did not know I had to declare encoding within html to serve foreign language. Django does not naturally serve media file (The beautiful CSS) so I used an inefficient way recommended here

Sunday, April 7, 2013

Flattery Generator

So if you need some sentences for flattery, you could use this webpage I made for fun! For example, it outputs entries like " YOU, painfully amazing flower, shut up and take me." each time you push a button. 
 I used some JQuerry, AWS, and Django to implement this..

Sunday, March 31, 2013

Catch a Squirrel with Arduino Electronics

There are lots of squirrel in my town, and I want to catch one of them for fun. So I made a laser trap using Arduino to catch a squirrel.

The electronics circuit is very simple. It goes: 3.3V pin -> Photoresistor -> Pull-down resistor -> Ground, so digital I/O pin measures voltage between the photoresistor and pull-down resistor. I used 5V pin and another digital pin  to run the servo that closes the trap if the reading from photoresistor drops too much (i.e. laser is blocked by the presence of squirrel.). This is the photo of the arduino setup. Notice how I try to entice a squirrel with Korean food. 

I will post the photo of the unfortunate squirrel later. Here goes the Arduino sketch.

Servo myservo;  
int pos = 0; 

void setup()

void loop()
  float v = analogRead(0)* .004882814;  

if (v > .5)
  for(pos = 0; pos < 180; pos += 1) 

Wednesday, March 6, 2013

Prototype Submitted to Make-a-thon Competition

MAKE magazine's Make-a-thon competition  awards up to $5000 for creative DYI projects submitted to their website. With my friend (a college friend I met at Rice Univ), I introduced LED guided dance floor.
It is an extended version of DDR (Dance Dance Revolution) with higher resolution and size. Take a look!

Saturday, February 9, 2013

Creative Idea Generation Helper

One of the core sources of creativity is finding useful link between
two disparate items. So I made a Django view that randomly pick two items from Webster's Unabridged Dictionary ( and show them at the same place. Then, you can try to find the interesting link between the two items that might assist your brainstorming/ideation/thinking. Visit: