Nugroho's blog.

Saturday, December 24, 2011

Tiny Core Linux


Just wandering around and landed in ibiblio, glaring at my mac screen the tiny core linux, just 10 Mb linux distro with GUI, wow… and I thought damnsmalllinux is small enough.

This distribution is based on nothing, I mean it didn't based on large or old distro like ubuntu, debian or slackware like other mini distros that usually is stripped down version of its big distro.



here some excerpt from (http://distro.ibiblio.org/tinycorelinux/intro.html)
Tiny Core is:


  • Very Small. At 10 megabytes, Tiny Core is 1/400 to 1/100 the size of the most widely used operating systems in the world (even compared to most Linux distros). That makes Tiny Core flexible enough to be stored and run from usb sticks, a just-about-full CD, or even embedded devices. hardware.




  • Linux. Tiny Core uses the Linux Kernel and a set of command-line (text interface) tools including busybox.




  • A GUI Desktop. Tiny Core has a flexible and fully-customizable Graphical User Interface Desktop. Mouse, keyboard, and screen support basically works out-of-the-box thanks to FLWM, the FLTK Desktop. You can also quickly install and try out a variety of other desktops and interfaces including Fluxbox, XFCE, OpenBox, IceWM, Joe's WM, LXDE, and others.




  • Minimal. Tiny Core does not 'ship' with most end-user software. Instead, Tiny Core lets you quickly and easily compare, select, download, and install your preferred web browser, word processor, music player, and other software.




  • Unusually Stable. Every time Tiny Core loads, it is brand-spanking new. That means Tiny Core just doesn't get a blue screen. Instead of installing programs into the system file space and risking damage to the system files, Tiny Core uses program 'extensions' that are re-prepared at each reboot ... and they are prepared fast.




  • Unusually Fast. Unlike most operating systems, the Tiny Core can run completely from RAM. Individuals with RAM to spare can even use Tiny Core to load and run their programs from RAM (you didn't know your computer could run Open Office and Firefox so quick). Experienced users can still install Tiny Core to disk, but Tiny Core can run in 48 megabytes of RAM ... or less.




  • Internet ready. Tiny Core almost always finds your network card right right away. You'll be adding applications and tools after an unusually quick boot. You can even come back here and ransack the forums if you find you need help.




  • Available even smaller. Linophiles that get things done without a GUI can get the MicroCore, a version of Tiny Core without X that is under 7 MB.




  • An open source community. Tiny Core is under active community development, led by a team of really dedicated people. You can find answers and ask questions in the forum, add your own experiences to the wiki, help add extensions (programs) to the Tiny Core Repository, and read enough Tiny Core to make your head spin.



What are the minimum requirements?
An absolute minimum of RAM is 46mb. TC won't boot with anything less, no matter how many terabytes of swap you have.
Microcore runs with 28mb of ram.
The minimum cpu is i486DX (486 with a math processor).


A recommended configuration:
Pentium 2 or better, 128mb of ram + some swap


Is Tiny Core for me?
If Linux and distributions are confusing to you, then Tiny Core might not be for you. To help you decide, you need to know a few things about Tiny Core.


To get started, Tiny Core is:



  • Not a duplicate of another really common operating system. Tiny Core doesn't have a pretty boot screen, or stock wallpaper, and Tiny Core certainly doesn't have its own advertising campaigns.




  • Not a 'turnkey' operating system. Tiny Core can help you do what you need to do, but Tiny Core stays tiny by not including tools like a browser or word processor (but Tiny Core can help you download and install those really quickly).




  • Not for everyone. Tiny Core is fast, powerful, and flexible. You can use Tiny Core without much technical knowledge, but, like any strong tool, Tiny Core becomes really useful if you know how to use it. Great starter skills could include command line usage, simple shell scripting, and Linux file and permission management, and some reasonably fast typing skills.



If you aren't scared off yet, you need to know that there are some characteristics that make Tiny Core a really unique Linux distribution.



SSH Tunnelling Firefox on Oneiric Ocelot behind Virtual Box's NAT

I have Ubuntu 11.10 guest installation on my VBox on OS X Lion host. What the point of it? Yeah, first I want to create isolated environment that won't bring the headache if it destroyed. Second, I want to break that isolated environment so it can reach the world wide.



For start, I begin with ssh tunneling. I used ssh connection to tunnel firefox's data. It look like firefox isn't connect through NAT but through my ssh server instead.

To be able to do this. I have to have access to some server outside via ssh. Fortunately, now free shell access is widely available, just google for it and subscribe.

To make connection through ssh for tunneling use this command

ssh -ND 7777 yourusername@shellserver.com 

It will bring a prompt ask for password and then nothing, that N means, it will not bring interactive shell

On firefox side, open edit, preferences, advanced, network, setting
Choose manual configuration and type on SOCKS host: localhost port 7777

Now firefox's connection have been tunnelled.

Friday, December 23, 2011

Automounting Shared Folder on Ubuntu 11.10 Oneiric Ocelot as Guest in OS X Lion VirtualBox

My Ubuntu 11.10 Oneiric Ocelot on virtual box have shared folder with host OS X Lion named 'vbox'. I used to typing command after login to mount that folder to my home directory. I mount it to falder named 'vbox' too using this command

$sudo mount -t vboxsf vbox vbox.  

However, at old time, I used to auto mount other partition that refused to automount (usually ntfs or other linux distros partition) at login by editing /etc/fstab



(using vi, press k to scrolldown and press i or a to edit the last line)
aravir@aravir-VirtualBox:~$ sudo vi /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda1 during installation
UUID=3c8759e3-314b-4e42-a39e-efe9c18a130c / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=1b64eb34-42af-4ada-8bf1-0273d572cdb6 none swap sw 0 0
#virtualbox shared folder
vbox /home/aravir/vbox vboxsf auto 0 0

press :wq! to save and quit vi session


Restart the machine. 


After the machine is back, well, there is no sign that my tweak above worked. Curious, I want to take a peek of what kind and what are already mounted by system.


aravir@aravir-VirtualBox:~$ mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
vbox on /home/aravir/vbox type vboxsf (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
vbox on /media/sf_vbox type vboxsf (rw,gid=1001)
gvfs-fuse-daemon on /home/aravir/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=aravir)
aravir@aravir-VirtualBox:~$
It's like the vbox is successfully mounted TWO times, however:
  • vbox did mount on /home/aravir/vbox but it's no file at all 
  • vbox mounted on /media/sf_vbox but only root have access to it 
So the last resort is playing with rc.local
aravir@aravir-VirtualBox:~$ sudo vi /etc/rc.local 

add this line before exit 0 

mount -t vboxsf vbox /home/aravir/vbox 

so the /etc/rc.local become like this
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
mount -t vboxsf vbox /home/aravir/vbox
exit 0
Restart the machine and voila, its success

Thursday, December 22, 2011

Lagu dengan Ketukan Nada Ganjil

Saat terbaring kaku karena obat tidur dosis super, aku buka iTunes dan memainkan keseluruhan koleksi  lagu-lagu secara shuffle. Enak sekali tidur tanpa bisa bergerak sambil diiringi lagu-lagu yang kadang sangat sering kuputar, kadang ada yang sudah lama tidak kuputar, bahkan lupa kalu pernah punya lagu itu.

Saat lagu "Tidurlah-tidur"nya Katon selesai, mulailah ketenangan tidurku terusik ketika "Under A Glass Moon"-nya Dream Theather mulai dimainkan oleh si Apple Mac. Lagu ini memiliki ketukan-ketukan yang berganti-ganti. Awalnya 6/4, sudah aneh, coba anggukkan kepala mengikuti nada-nadanya, anda akan dipaksa menganggukkan kepala saat seharusya anggukkan anda masih di atas. Saat melodi, hm , anda sakti kalo tahu itu birama berapa. Banyak lagu-lagu Dream Theather yang memiliki karakter seperti ini



Di "Metropolis", coba anggukkan kepala mengikuti ketukan di section 3, pasti anda akan dipaksa menghentikan kepala sejenak untuk mensinkronkan anggukkan kepala anda dengan musik. Itu di bagian saat ada bait "I was told there's a miracle for each day that I try, I was told there's new love is born for each one that's die, I was told there'll be no one to call on when I feel alone and afraid, I was told if You dream of the next world, you'll find yourself swimming in the lake of fire..."

Saat bagian melodi pun, sudah menjadi ciri khas DT, biramanya kebanyakan ganjil dan meloncat-loncat. Saat-saat awal mendengarkan lagu-lagu Dream Theater, aku sudah langsung berpikir "aku tidak akan mencoba memainkan lagu-lagu ini" Bukan karena tidak suka, tapi terlalu rumit untuk sebuah band jazz-latin-bossa, hehehe

Lagu-lagu yang memiliki birama tidak lazim sangat banyak.

Steve Vai, gitaris, mempunyai lagu-lagu seperti Incantation dengan birama 5/4, bayangkan gimana otak drummernya. Bagian melodi akustik di "Freak Show Excess" juga memiliki birama ganjil.

Naif punya lagu "Elton John" dengan birama 14/16 di bait awal

Beatless di lagu pertama side B album The Best of, birama 5/4

Dan yang paling sering kita dengar tahun lalu sebagai theme song di ISL adalah Damage Control, dari album solo John Petrucci (Gitaris Dream Theater). Lagu ini memang terkesan sporty dan heavy saat intro awal yang hanya dibawakan dengan gitar. Belum tampak keganjilan ketukannya, namun begitu drum dan bass masuk, coba anggukkan kepala anda, pasti beberapa saat kemudian anda akan dipaksa mensinkronkan kembali anggukan kepala anda dengan ketukan lagu, hehehe.

Obat Tidur Dosis Super

Saat ini aku susah bergerak, bahkan untuk batuk pun susah karena perut terasa kram. Bukan karena terkena penyakit tertentu, melainkan karena obat tertentu.

Tiga hari ini, tenggorokan terasa panas, bukan seperti batuk pilek biasa. Setelah periksa ke bidan desa, ternyata tenggorokanku ada semacam sariawan!!! Difteri, hm, sudah hampir dua tahun tidak mengalami lagi, bukannya ingin sakit sih, cuma gak bisa lupa sakit yang dua tahun lalu, suaraku sampe berubah jadi pecah kayak robot. Kalo bisa diatur agar suaranya bisa suara prime-tertz-quin sih tidak masalah, :(



"Suntik mas?" (waduh...)
"Hehehe..."
"Ok"

Bidan ambil alat suntik dan mencobloskan jarumnya ke ampul obat putih bening, seperempat dari isi keseluruhan alat suntik. Setidaknya yang disuntikkan tidak banyak, pikirku. Eh, tapi kok obatnya aneh?

"Bu, kok obatnya bening. Kayaknya dulu warnanya merah deh"
"Memang, lha ini yang merah" bu bidan mencobloskan jarum lagi ke ampul merah. Sekarang sudah setengah alat suntik terisi cairan, deg...deg..deg.
"Pernah alergi obat Mas?"Aku cuma bisa geleng, mulutku gak bisa kupercaya untuk mengeluarkan sepatah kata tanpa bergetar.

"Kalo gitu tak tambahkan ini" Sekarang alat suntik sudah berisi PENUH cairan obat yang akan disuntikkan ke tubuhKU..., duh gusti...

"AAAOOOUUUWWW..."

"Walah, sudah bolak balik ke sini berpuluh tahun kok ya masih sama gayanya"

"AAUUWWW..."

Semenit kemudian barulah dicabut. Aku cemberut.

Beberapa menit kemudian
"Nah, yang ini diminum kalo diare, 2 buah pil, jika dan hanya jika diare lho. Kalo nggak diare nggak usah di minum. Yang putih kecil ini untuk pilek tiga kali sehari , tapi minumnya besok, soalnya di suntikkan tadi sudah ada. Nah kalo yang untuk pusing bisa disimpan untuk suatu saat kalo pusing lagi, tiga kali sehari, kalo sudah tidak pusing hentikan minumnya, yang ini antibiotik....blablabla..."

Begitulah aku diberi obat 11 macam pil yang fungsinya macam-macam, dari diare, pusing, pilek, demam, sariawan ditenggorokan sampai jamur di usus. Hm, setidaknya aku masih tahan tidak pingsan mendengarnya, kalau pil sih, kecil... Suntikan? No Way...

Malamnya langsung minum obat, tidak ada masalah

Dini hari. Terbangun, keringat dingin yang melimpah tanda sembuh, mau merubah posisi tidur, eh loh? Kok badanku kaku? Coba menengokkan kepala, tidak bisa. Kupaksa bangun dengan cara normal, YA AMPUN, perutku rasanya seperti baru sit-up tujuhratus tujuhpuluh tujuh kali, njarem (ngilu). Pasrah, tidur lagi dengan posisi yang sama, obat tidurnya masih berpengaruh kuat.

Subuh terbangun lagi, mau menggeser kaki pun rasanya seperti habis lari marathon tanpa pemanasan. Kupaksa bangun sambil teriak-teriak, rasanya seluruh tubuhku habis digebuki orang (hm, mungkin rasanya gitu, gak pernah digebuki orang), tetap kupaksa bangun, ingin pipis.

Jalanku seperti robot, tangan kanan membantu mengangkat kaki kanan, yang kiri juga sama. Dekat kamar mandi ketemu Anggun

"Mas, kenapa"
"Gak tahu, kaku semua. Apa memang obatnya berpengaruh seperti ini?"
"Harusnya enggak, mana obatnya, tak lihatnya" Anggun juga bidan
"(nggremeng) hm, ni obat pilek ada CTM-nya, antibiotiknya ok, demakolin, loh, ini kan ada CTM-nya juga? wah ni harus diminum salah satu tok, nah kalo yang ini gak papa terus yang...."

....

"Wah, ini sampeyan dapat dua jenis pil yang ada obat penenangnya, efeknya sampeyan seperti dibius, efek sampingnya bisa kayak saya dulu, leher kaku, eh kalo sampeyan sekujur tubuh kaku, hehehe..."

Duh, dan beginilah, untuk batuk saja malah lebih susah dari sebelum diobati. Mungkin maksudnya memberi efek jera agar tidak bisa batuk, tapi... Setidaknya demam dan pilek sudah hilang, walau masih terbujur kaku.

Monday, December 19, 2011

Python-based Web Page to Compute Function with User Input Flexible Function

This is improved from my python-based web based to display function. In this version, users have ability to input a function and then display it with it value for given variable to python-based web page.

The code below will get input from users (if no input, the default value is sin(x)), parsed it to function python understand, and then eval it for given variable (in this code, x=10). After computed, it's inserted to template that resembling html code. Thus, since it's displayed in html style, we could add our customization (background, css, etc)



Here's the code


#!/usr/bin/python
# -*- coding: utf-8 -*-
import BaseHTTPServer, urllib, re
import sys,parser
from math import *

class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
    template = u"""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>%s</title>
        </head><body><h1>%s</h1><pre>%s</pre>Function<form action="" method="POST"
        class="editor"><div><textarea name="text">%s</textarea><input type="submit"
        value="Compute"></div></form></body></html>"""
    
    def escape_html(self, text):
        """Replace special HTML characters with HTML entities"""
        return text.replace(
                            "&", "&amp;").replace(">", "&gt;").replace("<", "&lt;")
    
    def link_repl(self, match):
        """Return HTML for link"""
        title = match.group(1)
        if title in self.server.pages:
            return u"""<a href="%s">%s</a>""" % (title, title)
        return u"""%s<a href="%s">?</a>""" % (title, title)
    
    def do_HEAD(self):
        """Send response headers"""
        self.send_response(200)
        self.send_header("content-type", "text/html;charset=utf-8")
        self.end_headers()
    
    def do_GET(self):
        """Send page text"""
        self.do_HEAD()
        page = self.escape_html(urllib.unquote(self.path.strip('/')))
        text = self.escape_html(self.server.pages.get(page, "sin(x)"))
        parsed = re.sub(r"\[\[([^]]+)\]\]", self.link_repl, text)
        #hitung fungsi
        fungsi=parser.expr(parsed).compile()
        x = 10
        y = eval(fungsi)
        tout = 'The value of  ',parsed, ' on x = ',x,' is ',y
        tout = str(tout)
        tout = re.sub(r",", "", tout)
        tout = re.sub(r"\'", "", tout)
        tout= tout[1:]
        tout= tout[:-1]
        self.wfile.write(self.template % (page, page, tout, text))
    
    def do_POST(self):
        """Save new page text and display it"""
        length = int(self.headers.getheader('content-length'))
        if length:
            text = self.rfile.read(length)
            page = self.escape_html(urllib.unquote(self.path.strip('/')))
            self.server.pages[page] = urllib.unquote_plus(text[5:])
        self.do_GET()

if __name__ == '__main__':
    server = BaseHTTPServer.HTTPServer(("", 8080), Handler)
    server.pages = {}
    server.serve_forever()

Here's the screenshot
From python

Sunday, December 18, 2011

User Input on Python during Runtime

Eventually, we want interactivity when executing Python script. We want user to give input for some variable. It'll useful for, lets call, application form where user have to input her/his name, age, etc. On math field, user will have flexibility to input the function and range of variable used to computation.



There is raw_input command and input command we can used.

raw_input command will translate all we type to string, while input command treat it as command

Here difference between the two

raw_input
x=raw_input('type anything \n')
print 'you typed ', x

Execute it
Nugrohos-MacBook-Pro:python nugroho$ python input.py 
type anything
a
you typed a
Nugrohos-MacBook-Pro:python nugroho$ python input.py
type anything
12
you typed 12
Nugrohos-MacBook-Pro:python nugroho$ python input.py
type anything
sin(x)+x**2
you typed sin(x)+x**2
Nugrohos-MacBook-Pro:python nugroho$

input
c='sin(x)+x**2'
me='Hello folks, Aravir here'
x=input('type anything \n')
print 'you typed ', x

Execute it
Nugrohos-MacBook-Pro:python nugroho$ python input.py 
type anything
a
Traceback (most recent call last):
File "input.py", line 3, in
x=input('type anything \n')
File "", line 1, in
NameError: name 'a' is not defined
Nugrohos-MacBook-Pro:python nugroho$ python input.py
type anything
12
you typed 12
Nugrohos-MacBook-Pro:python nugroho$ python input.py
type anything
sin(x)+x**2
Traceback (most recent call last):
File "input.py", line 3, in
x=input('type anything \n')
File "", line 1, in
NameError: name 'sin' is not defined
Nugrohos-MacBook-Pro:python nugroho$ python input.py
type anything
c
you typed sin(x)+x**2
Nugrohos-MacBook-Pro:python nugroho$ python input.py
type anything
me
you typed Hello folks, Aravir here
Nugrohos-MacBook-Pro:python nugroho$
323f (5) amp (1) android (12) apple (7) arduino (18) art (1) assembler (21) astina (4) ATTiny (23) blackberry (4) camera (3) canon (2) cerita (2) computer (106) crazyness (11) debian (1) delphi (39) diary (286) flash (8) fortran (6) freebsd (6) google apps script (8) guitar (2) HTML5 (10) IFTTT (7) Instagram (7) internet (12) iOS (5) iPad (6) iPhone (5) java (1) javascript (1) keynote (2) LaTeX (6) lazarus (1) linux (29) lion (15) mac (28) macbook air (8) macbook pro (3) macOS (1) Math (3) mathematica (1) maverick (6) mazda (4) microcontroler (35) mountain lion (2) music (37) netbook (1) nugnux (6) os x (36) php (1) Physicist (29) Picture (3) programming (189) Python (109) S2 (13) software (7) Soliloquy (125) Ubuntu (5) unix (4) Video (8) wayang (3) yosemite (3)