Sunday, January 27, 2013

Run Codes On the Webpage!

Fun little project where..
1. Copy your source code (Live shell script, Python, Html, and Perl) and paste them into the text box.
2.Click the run button corresponding to each language the code belongs to.
3. See the output below the buttons. (No page reload needed, using JQuery)
(I am not going to reveal the url for this webpage, because this opens lots and lots of security holes to my server..,., Just a proof of concept.)
 


It was fun.  Here is the JQuery that
1)gets the code in the text box,
2) sends to the Django web server,
3)Gets the result,
4)show it to the webpage without reloading


$('button').mouseenter(function(event) {
    var text = $('textarea').val();
    var language = event.target.id;

     $.get(
       "ec2-xxxx-xxxxx-xxxxx-xxxxx.compute-1.amazonaws.com/blahblahblah",
       {user: text,lng:language}, 
       function(data) {$('a#friend').html(data);}
             );
       }); 

Also you can deal with this age-old problem about how to insert the tab in the text box by: (Found by googling it)


$("textarea#1").keydown(function(e) {
    if(e.keyCode === 9) { // tab was pressed
        // get caret position/selection
        var start = this.selectionStart;
        var end = this.selectionEnd;

        var $this = $(this);
        var value = $this.val();

        // set textarea value to: text before caret + tab + text after caret
        $this.val(value.substring(0, start)
                    + "\t"
                    + value.substring(end));

        // put caret at right position again (add one for the tab)
        this.selectionStart = this.selectionEnd = start + 1;

        // prevent the focus lose
        e.preventDefault();
    }
});

Real-Time GPS Tracking of my Android Phone

I made a website to track the location of my Android Phone real time.
Aww it was a pleasant project. But of course I cannot show the url to this for privacy reasons ;)





This is the step I took..
1 Download Android SDK. This includes IDE (eclipse with Android SDK plugin installed).  So you can create an android app project right away. Basic Android App dev tutorial
2. Give permission requests in the manifest file (internet and gps device), and follow this tutorial to get the source code to get the access to GPS device.
3. In the main java code, do http get request to send the latitude and longitude of the location to the django loaded in amazon web services. Such request is made every 5 seconds within android view.
4. Using USB debugging mode, upload and install the app.
5. Have a Django views.py to save the location info into a text file (LOL).
6. On the webpage, use JQuery to send repetitive HTTP GET requests (every 3 seconds using setInterval() method. There is no such thing as sleep() method to put in while loop) to get current location. 
7. Use Javascript to do real-time update of the location of marker using Google maps API.
Of course the API key registration needs to be done.

Here goes the source code

Real Time Control of my Arduino Device through Webpage

I made a website where an anonymous visitor can turn on/off an LED light in my Arduino device on my desk real-time. Live video broadcast shows the LED light for live feedback. Visit http://ec2-50-19-51-195.compute-1.amazonaws.com/live/
But this is now a downtime.
(What I learned here turned out to be a help for the next project. Nice)



The mechanism is:
1.You click a button.
2.JQuery detects the event and send a HTTP request. (To prevent the page from reloading)
3.The Django mounted on Ubuntu Server (amazon web services micro instance) serves the HTTP request.
4. The Django view writes to a text file saying the button was clicked.
5. And every 1 second the python program in my laptop makes ssh request to read the file to know the state (I know this is really akward)
6. The python program talks to my Arduino to turn on and off via a protyping module
7. The Ustream app on my Android Phone does live broadcasting on the LED.
8. The streaming is shown on the channel embeded to the browser
9. Additionally, I embeded a facebook comment tab.

From this point, many things can be tried to extend this idea. 

Well now is a downtime.

Friday, January 11, 2013

Analyzing the Bible with a Web Server

Finally, it's the weekend. As a celebration, I made a website that searches all the bible verses that include a keyword you want. Type in the word in the text box and submit it. The reference bible is New International Version.
Visit:  http://ec2-50-19-51-195.compute-1.amazonaws.com/bible/

Aw, this website is run on amazon web services micro instance (free tier) so please limit your searches (<100)... Also feel free to comment on the Facebook comments window.

Sunday, December 23, 2012

Testing Natural Talent to Decide Career

The Rockport Institute, a famous career consulting firm, provides a $550 service to test the natural talents of the clients. Recommended by Yale U Business School, this tests various talents that will help guide deciding his/her career path. I took the test myself, and wow it was a long test (for me it took four hours). So it tells you

-whether you should be a specialist/generalist.
-how good your 3D thinking is (so that you will work well with spatial imagination needed in engineering/science/designing etc)
-Diagnostic reasoning (making a leap of thought/conclusion/diagnosis out of disparate facts. Good for being a critic/doctor/inventor/consultant)
-Analytical thinking
-Rate of Idea flow. Whether you tend to concentrate on one thing or your mind tend to continually flow from topic to topic. Low score: Focused slow work. ie) Brain Surgeon. High score: fastly moving thoughts. Improv. ie) ER doctor.
-MBTI type indicator to know about your personality trait. (Not talents.) 
-Many others..

So this is the most thorough test of someone's aptitude I know. I got this $550 test as a gift I chose for myself. This is my test result. Client ID says I am 16307th test taker..



This tells me I am a damn good at 3D spatial thinking (99/100), I should be  very specialzed at one thing (95/100), and I need an environment that requires continual flow of thoughts (66/100). Low Diagnostic Reasoning (25/100) means I should be good at creating stuff because middle to high scored Diagnostic Reasoning tend to involve overlly critiqueing self. Also I got ENTP for my MBTI test here.  In this photo, top 9 categories are the most important indicators for deciding a career. To my life experience everything above is completely true.

How do I combine all of these information to make a single decision? Now there is a chart published by the company to indicate a smaller subclass of career that maximally utilize each different combination of above indicators. So, in reference to this publication, my theme based on above indicators is 'Advanced technology development'. My reaction to this is 'I knew it! Awesome!'. So after much thoughts, I decided to join Microbial Engineering career! (Because I love microbes also)

Tuesday, December 18, 2012

Facebook page of a genetics laboratory

Previously I have worked at a Genetics lab in Stanford. I loved my work there sequencing DNAs and analyzing it.
In the mean time, I created a Facebook page for the lab to share the works and happenings in the lab to people.  

 It was a nice experience. I videotaped/audiotaped interviews with the professor, post docs, graduate students, and other lab people about science and posted them. Also, as a lab with more than 70 members there I found many bloggers who love to write about their work. So I found a Facebook app that streams new blog entries to this Facebook page through RSS feed. Photos of lab or department parties were shared as well. Also, I made a Facebook app (an app that does Iframe to embed a chatting box) to host several chatting sessions between the lab members and the Facebook fans. I did everything I felt fun. :)

This photo lists where the Facebook fans come from.. Out of 626 people, only 200 are from the US so we have a very global reach! Well, when I left the lab about six months ago, I gave all the lab people who were also the Facebook fans of the page administrator's privilege(around 30 of them). So, all of them can share contents representing the lab. It is collectively being maintained by them very well so far without my help!

Arduino vs Raspberry Pi?

 I have been using Arduino to build many electronics projects listed in Sparkfun's starter kit Thanks to the kit, I have been able to easily build absolutely awesome things as a begineer. Within two nights of work, I already learned to combine different kinds of sensors (temperature, light, physical contacts) with actuators (motors, speakers, LED lights) and IC chips. So I love my Arduino with a starter kit which you can see in this photo.   

But now I ask: if I were given a choice between Arduino and Raspberry pi to build electronic devices, what would I choose? Without delay, I would go for Raspberry Pi. For about the same price ($35) as Arduino Uno board R3 ($25), I can get a whole linux computer that can digitally control all the circuits listed in the Sparkfun's kit. Contrary to Arduino, it can do Internet, play TV through HDMI cable, and save data through miniSD chip.See the diagram indicating all the awesome stuffs that can be done with Raspberry Pi!

Ahhh go for Raspberry Pi even for amateur electronics projects.