Nugroho's blog.

Sunday, October 11, 2015

Belajar.

Dulu belajar berbicara.

Sekarang perlu untuk belajar diam.

(The Tales of Tatonka)

Saturday, October 10, 2015

Pasir

Berapa nikmat yang diberikan kepadaku?

Ngawur,

kurang kerjaan.

Sana, mending hitung butiran pasir di pantai saja sana,

tu lebih sedikit, lebih gampang.

(terinspirasi status mbakYu)

Wednesday, October 7, 2015

Lagrange Interpolation using Python

 Here it is. We could set the order of interpolation by changing the value of k


from pylab import *
from random import uniform
k = 11

def l(t):
l = []
for i in arange (len(t)):
l.append(0.)
for j in arange(k+1):
lag = 1.
for m in arange(k+1):
if m!=j:
lag = lag * (t[i]-x[m])/(x[j]-x[m])
l[i] = l[i]+y[j]*lag


return l

def f(x):
f = []
for i in arange (len(x)):
f.append(0.)
f[i] = x[i]+uniform(-10,10)
return f

x = arange(0.0, 2.0, 0.1)
t = arange(0.,2.,0.001)
y = f(x)
z = l(t)

plot(x,y)
plot(t,z)
xlabel('x')
ylabel('y')
title('interpolasi')
grid(True)
axis([0,2,-111,111])
#savefig("test.png")
show()

.

Monday, October 5, 2015

Walking Sine on Visual Python GDisplay

 Look, the wrong way often provide a beautiful result. Yeah, it's not what the program should be, but still I like it, :)


from __future__ import division, print_function
from visual import *
from visual.graph import *

def f(x):
f = sin(pi*x+p)
return f
def g(x):
g = cos(pi*x)
return g

graph1 = gdisplay(x=0, y=0, width=600, height=400,
title='A vs. t', xtitle='t', ytitle='A',
foreground=color.black, background=color.white)
p = 0.
f1 = gcurve(color=color.blue)
f2 = gcurve(color=color.red)

t = arange(-2.,2.,0.01)
s = g(t)
while True:
rate(100)
f1.gcurve.pos=[] #delete this and look at the effect :)
f2.gcurve.pos=[]
u = f(t)
for i in arange(len(s)):
f2.plot(pos=((i-len(s)/2.)*.01,s[i]))
f1.plot(pos=((i-len(s)/2.)*.01,u[i]))
p = p + 0.01
if p >100:
p = 0



















Saturday, October 3, 2015

Fourier Transform using Delphi

 It's not Discrete Fourier Transform.

 Instead, I use continue definition (using Integral, not Sum) to compute the transformation. I know, it's weird, but it's worth a try, :)

 What I did is transform signal with 3 frequency, remove the two frequency and trasform back to time-signal.










unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;

type
TForm1 = class(TForm)
Image1: TImage;
Timer1: TTimer;
Memo1: TMemo;
Image2: TImage;
Image3: TImage;
Image4: TImage;
procedure proses;
procedure gambarFungsi;
procedure gambarSumbu;
procedure gambarTransformasi;
procedure olahTransformasi;
procedure gambarOlahTransformasi;
procedure transformasiBalik;
procedure gambarTransformasibalik;
function f(x:real):real;
procedure Timer1Timer(Sender: TObject);
private
public
end;

const
a=200;
b=150;

var
Form1: TForm1;
x0,y0,xm,ym:integer;
s,ss:array[-a..a]of real;
ft:array[-b..b]of real;
implementation
{$R *.dfm}
function tform1.f(x:real):real;
begin
f:=cos(PI*x)+cos(2*PI*x)+cos(4*PI*x);
end;
procedure tform1.transformasiBalik;
var i,j:integer;
t,w,dt:real;
begin{}
dt:=0.1;
for i:=-a to a do begin
w:=i/10;
ss[i]:=0;
for j:=-b to b do begin
t:=j/10;
ss[i]:=ss[i]+ft[j]*cos(w*t)*dt
end;
end;
gambarTransformasiBalik;
end;

procedure tform1.olahTransformasi;
var i:integer;
begin
for i:=-b to b do begin
if abs(i)>50 then ft[i]:=0;
end;
gambarOlahTransformasi;
end;

procedure tform1.proses;
var i,j:integer;
t,w,dt:real;
begin
form1.Caption:='transformasi';
gambarSumbu;
{transformasi}
dt:=0.1;
for i:=-a to a do begin
s[i]:=f(i/30);
end;
for i:=-b to b do begin
w:=i/10;
ft[i]:=0;
for j:=-a to a do begin
t:=j/10;
ft[i]:=ft[i]+f(t)*cos(w*t)*dt
end;
end;
gambarFungsi;
gambarTransformasi;
olahTransformasi;
transformasiBalik;
end;

procedure tform1.gambarFungsi;
var i,xo,yo,xt,yt:integer;
begin
xo:=-a; yo:=0;
for i:=-a to a do begin
xt:=i;
yt:=round(10*s[i]);
with image1.Canvas do begin
moveto(x0+xo,y0-yo);lineto(x0+xt,y0-yt);
end;
xo:=xt;
yo:=yt;
end;
end;

procedure tform1.gambarTransformasibalik;
var i,xo,yo,xt,yt:integer;
begin
xo:=-a; yo:=0;
for i:=-a to a do begin
xt:=i;
yt:=round(10*ss[i]);
with image4.Canvas do begin
moveto(x0+xo,y0-yo);lineto(x0+xt,y0-yt);
end;
xo:=xt;
yo:=yt;
end;
end;

procedure tform1.gambarOlahTransformasi;
var i,xo,yo,xt,yt:integer;
begin
{}
xo:=-b; yo:=0;
for i:=-b to b do begin
xt:=i;
yt:=round(10*ft[i]);
with image3.Canvas do begin
moveto(x0+xo,y0-yo);lineto(x0+xt,y0-yt);
end;
xo:=xt;
yo:=yt;
end;
end;

procedure tform1.gambarTransformasi;
var i,xo,yo,xt,yt:integer;
begin
xo:=-b;yo:=0;
for i:=-b to b do begin
xt:=i;
yt:=round(10*ft[i]);
with image2.Canvas do begin
moveto(x0+xo,y0-yo);lineto(x0+xt,y0-yt);
end;
xo:=xt;
yo:=yt;
end;
end;

procedure tform1.gambarSumbu;
begin
x0:=image1.Width div 2;
y0:=image1.Height div 2;
xm:=image1.Width;
ym:=image1.Height;
with image1.Canvas do begin
moveto(0,y0);lineto(xm,y0);moveto(x0,0);lineto(x0,ym);
end;
with image2.Canvas do begin
moveto(0,y0);lineto(xm,y0);moveto(x0,0);lineto(x0,ym);
end;
with image3.Canvas do begin
moveto(0,y0);lineto(xm,y0);moveto(x0,0);lineto(x0,ym);
end;
with image4.Canvas do begin
moveto(0,y0);lineto(xm,y0);moveto(x0,0);lineto(x0,ym);
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
timer1.Enabled:=false;
proses;
end;

end.

HFS+ (Journaled) Flash Drive on Ubuntu

 I have no problem mount it on Centos, read and write mode.

 But, on Ubuntu, it needs some works.

 Install hfsprogs

 
sudo apt-get install hfsprogs


 umount the drive if it's already meunted


sudo umount /dev/sdb2


create folder to mount the drive


mkdir flash


mount again


sudo mount -t hfsplus -o force,rw /dev/sdb2 flash


It works for me, but it need sudo privilege to write to it. Maybe because it's journaled and ubuntu didn't support journaled HFS+ filesystem.

At least it works, :)

Friday, October 2, 2015

#MelawanAsap

 Yang tak terlupa, saat ada acara pembacaan surat YaaSin di rumah, ikut tradisi setempat, saat bapak meninggal.

 Yeah, bapak meninggal, itu sulit dilupakan.

 Tapi beberapa minggu ini ada yang mengungkit-ungkit kenangan itu lagi, kebakaran di Sumatera dan Kalimantan.

 Bukan tentang bapak yang diungkit (mudah sekali mengingat kejadiaan itu), tetapi tentang asap.

 Apa yang terjadi saat pembacaan surat YaaSin? Tentu saja, membaca surat YaaSin bersama-sama, diawali surat-surat pendek untuk pemanasan, Yaasin, trus doa-doa yang dipimpin secara estafet oleh dua pemuka agama.

 Yang terungkit oleh kebakaran di SwarnaDwipa dan Borneo justru sebelum acara. Ketika tamu mulai datang dan menunggu yang lain. Harus menemui tamu itu jelas, dan kebanyakan mereka adalah perokok! Hm, mereka merokok sebelum mendoakan seseorang yang meninggal akibat rokok, ckckck.

 Ketika acara akan mulai, tamu sudah semakin banyak, delapan puluh lebih. Ruangan sudah penuh hingga meluber ke halaman. Juga asap rokoknya.

 Sehari, ..., OK

 Dua hari, OOOOK...

 Hari ketiga, KO..., ke bidan, kena radang tenggorokan parah, harus minum 7 jenis pil.


 (dan ada dua pil yang mempunyai kandungan sama, sehingga dosisnya tanpa sengaja dobel, efeknya ketiga terbangun jam tiga pagi mau pipis, gak bisa gerak, otot kaku njarem, seperti habis berlari sprint sepuluh kilo, atau habis nabrak sedan diam dengan naik sepeda 80km/jam [sudah pernah mengalami, :) ])

 That's it. Asap, cuma terpapar tiga hari, dan setiap hari hanya sekitar dua jam.

 Bayangkan saudara kita di Sumatera dan Kalimantan.  Mereka di Pulau Emas dan Borneo terpapar setiap saat selama berminggu-minggu. SwarnaDwipa sedang berduka.

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)