Nugroho's blog.

Sunday, December 11, 2011

Double Tap Dragging on Lion


I wrote about missing single-tap-hold on Lion to dragging. However, after googling around, I found that it's still has capability to do it, just you will find it at the most unpredictable place in System Preferences

To enable one finger drag by double-tap-hold, go to System Preferences, click on Universal Access, and then the Mouse & Trackpad tab. Click on the “Trackpad Options…” at the bottom section of window. Enable dragging option; we can select the desired dragging behaviour from the drop down list. I wonder why this preference is here, not on trackpad section instead.









From Blogsy Photos

Lion have more Finger Gesture than Snow Leopard


Migrating from Snow Leopard to Lion is confusing and annoying but fun experience. One feature of Lion that I noticed very much is new finger gesture as it's a whole different experience than Snow Leopard.



I noticed first bad feeling when I browsing through Safari and can't double-tap-hold todragging a text to highlight it. I think, oh my God, my trackpad is broken. Calming down, go to preferences panel. I can't find double tap option, hm. Drag n Drop now can be done by three finger, uh. Highlighting text using three finger seems wrong to me. So, no double-tap-hold. (edit: there is double-tap-hold )

Two finger gesture to scroll and zoom is intact. Hm, not really. Scroll direction now has default option to 'natural', iPad like scroll.

No Exposé or Space, just Mission Control. Mission Control contain apps on current active desktop, just like Exposé, and all full screen apps, including other desktop.

Sweeping down four finger now show windows from same apps while sweeping up bring us to Mission Control. Sweeping left or right will bring us to next full screen apps (Desktop's treated as fullscreen apps).

A new gesture is pinching with four finger; pinching down will bring up Launchpad, an apps list just like iOS. A reverse pinching, spread (not sure what it's named), will push all windows to side to show Desktop.

I'm a bit missing the time when I could switch apps by sweeping down my four finger. Moving apps through spaces has gone too, but I guess it's a sacrifice to be able jump too next step.

Operasi Vektor di Python


Di python terdapat operasi dot dan cross untuk array. Namun ketika saya terapkan, ternyata operasi tersebut bukan merupakan operasi vektor melainkan operasi untuk matrik. Mungkin saya yang kurang mempelajari lebih mendalam atau mungkin memang demikian sifat operasi tersebut, akhirnya saya mendefinisikan sendiri operasi dot dan cross untuk vektor menggunakan def (semacam implementasi python untuk function atau procedure).



Berikut adalah contoh perbandingan operasi vektor di python. Kode yang atas adalah operasi bawaan dari Python sedangkan yang bawah adalah operasi dot dan cross dengan definisi yang baru

from numpy import *
from numpy.linalg import *
a=array((4,5,7),float)
b=array((2,3,4),float)
c=array((1,2,3),float)
print 'axb',a*b
print 'bxa',b*a
print 'dot(a,b)',dot(a,b)
print 'c.(axb)',dot(c,(a*b))
print '(bxa).c',dot((b*a),c)
print 'ax(bxc)',a*(b*c)
print '(axb)xc',(a*b)*c
print '(a.c)b-(a.b)c',(dot(a,c)*b)-(dot(a,b)*c)
print 'a=',a,'2a=',2*a
d=7*a+11*b
print 'd',d

def cross(v, w):
x = v[1]*w[2] - v[2]*w[1]
y = v[2]*w[0] - v[0]*w[2]
z = v[0]*w[1] - v[1]*w[0]
return (x, y, z)

def dott(v, w):
return v[0]*w[0] + v[1]*w[1] + v[2]*w[2]

print 'axb',cross(a,b)
print 'bxa',cross(b,a)
print 'dot(a,b)',dott(a,b)
print 'c.(axb)',dott(c,cross(a,b))
print '(bxa).c',dott(cross(b,a),c)
print 'ax(bxc)',cross(a,cross(b,c))
print '(axb)xc',cross(cross(a,b),c)
print '(a.c)b-(a.b)c',((dott(a,c)*b)-(dot(a,b)*c))
print 'a=',a,'2a=',2*a
print '(axb)x(cxb)=b[b.(cxa)]'
print cross(cross(a,b),cross(c,b))
print b*(dott(b,cross(c,a)))


Operasi Matrik di Python


Python dapat melakukan operasi matrik semacam invers, normalisasi, determinan, mencari nilai eigen, trace, bahkan eksponen matrik.



Untuk dapat menggunakan operasi matrik di Python, kita membutuhkan modul numpy.

Berikut adalah contoh kode operasi matrik di python.

from numpy import *
from numpy.linalg import *
a=array(((1,2),(3,3)),float)
b=inv(a)
c=dot(a,b)
d=norm(a)
e=eig(a)
f=det(a)
g=trace(a)
h=exp(a)
i=log(a)
print 'matrik A ='
print a
print 'matrik invers A = B ='
print b
print 'AB ='
print c
print 'norm A ='
print d
print 'eigen A ='
print e
print 'det A ='
print f
print 'trace A ='
print g
print 'exp A ='
print h
print 'log A ='
print i
z=array(((0.0,0.0+1.j),(0.0-1.j,0)),complex)



Perhatikan bahwa python juga mendukung bilangan imajiner sehingga dapat digunakan untuk menghitung matrik kompleks

Menggambar Grafik di Python dengan Matplotlib


Ada beberapa modul di python untuk menggambar grafik, semacam graphy, pycairochart, matplotlib dll. Berikut adalah contoh plot grafik dari y=sin(x) dengan range x dari -10 s.d 10 dengan resolusi 0.1 satuan. Resolusi di sini adalah langkah dari -10 ke 10, jadi kita akan mem-plot sin(-10), sin(-9,9), sin(-9.8), ...




from matplotlib.pyplot import *
from visual import *
x=[]
x=arange(-10.,10.,0.1)
grid(True)
xlabel('Sumbu x')
ylabel('Sumbu y')
title('Jejak ')
plot(x,sin(x),'b-')
batas=10
ylim(-2,2)
xlim(-batas,batas)
show()


The Journey of Installing Matplotlib Python Module on OS X Lion

I need matplotlib to plot my python output when I am running my output function generator python code.

This post is a log of what I did to being able to install matplotlib 1.1.0 on python 2.7.2 on my Mac OS X Lion 10.7.2. Yet, it's unfinished job.


First, googling for matplotlib, sourceforge is official home fon it, but it's very slow, I coudn't even open download page with my sluggish connection. So, I searching other source.

Got it from kambing.ui.ac.id, it has pypi repositories, but when it opened, there is no package, just blank folder.

After further googling, I finally found http://pypi.python.org, pypi stand for python package index.

To be able to use pypi package, we have to install pip first, but before that install distribute using this command

curl http://python-distribute.org/distribute_setup.py | python
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python

and then install matplotlib using pip, there is download activity, but got error at the end; must install numpy first, but it got error too as I didn't have GCC on my lion yet, aaarrrgghh... So, the hell of dependencies is begin...

So here I am, searching for 'light' GCC for my lion. I know I should install XCode 4 from Apple , it's free anyway, but I must face the fact that it's including 4.5GB download job, such a tedious job and wasting time; I just want to install 13 MB matplotlib.

I wish I can type the code below

pip install numpy
pip install matplotlib

(pray)

Saturday, December 10, 2011

Portable Python

When I wandering around, through virtual world, looking for Python reference of matplotlib, don't know what link I'd click, suddenly I'm landing in Portable Python page. Barely interested, not because it's not interesting, but I've already have python on my Mac and this Portable Python came with .exe download, such a tedious job if I try to run it on my machine (clearly, it's Windows apps). However, it's really useful distribution of Python.



At download section, it's recommended to download via torrent network, another interesting idea. Here some excerpt from Portable Python website



Portable Python is a Python® programming language preconfigured to run directly from any USB storage device, enabling you to have, at any time, a portable programming environment. Just download it, extract to your portable storage device or hard drive and in 10 minutes you are ready to create your next Python® application.

One of the most powerful dynamic programming languages that is used in a wide variety of application domains and is used at many companies and institutions around the world ( YouTube, Google, NASA, Firaxis Games, etc.).

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)