I used to type on Dvorak layout. But, it's very difficult today to get Dvorak layout on any keyboard by default. So I have habit to disassembly all of my new device keyboard (MacBook Pro, PC, standalone keyboard).
This K380 is no exception, :)
This keyboard is using butterfly mechanism, so it's easy to disassembly it, :)
Showing posts with label computer. Show all posts
Showing posts with label computer. Show all posts
Thursday, March 26, 2020
Friday, December 19, 2014
Using 'Home-Made' Fortran Binary as Python module
Python is easy to use, but it's slow, especially for loop computation. So I compute it using fortran like this
save it as aravir.py and do the following command
To use the module on the python I use the code below
:)
subroutine subs(a, b, n)
double precision a(n)
double precision b(n)
integer n
cf2py intent(in) :: a
cf2py intent(out) :: b
cf2py intent(hide) :: n
! b(1) = a(1)
do 100 i=2, n
b(i) = a(i)-1
100 continue
end
save it as aravir.py and do the following command
$ f2py -c aravir.f -m aravir
To use the module on the python I use the code below
import numpy as np
import aravir as ar
a = np.linspace(0,1,100)
b = ar.subs(a)
print a
print b
:)
Thursday, September 25, 2014
Asus Eee PC won't Enter BIOS
Got this Eee PC without OS.
Planned to install it myself.
This netbook don’t have cd drive.
so the choice is via pxeboot or flash/thumb drive.
(have set PXE boot several month ago for CentOS, and have no desire to do it again or my head will split :) )
so via flash drive then
we could use any thumb drive and any iso, given it have enough space
we could make this pen drive bootable with any tool (windowsbased, linux via dd, os x based, unix based) just google for it
Okay
what now
First, we must set BIOS of this netbook to boot via USB drive
to enter BIOS we must press F2 after powered this device on
…
…
or maybe F1
…
…
ESC
…
…
DEL
…
…
F12
…
err, it seem I couldn’t get bios interface. Googling around and found out that I have to repeat the press on F2 fast
and, hooray…
succeed, installed OS on it
but, wait
my OS is 32bit
I have 4GB RAM on this eee PC and 32bit OS generally could only handle 3.6GB RAM, oh my…
…
download 64bit iso
make it bootable on flashdrive
reinstall the OS, but…. it won’t enter BIOS, again
no mater how fast I press F2 key it’ll always go to OS boot
same thing happenend to del, esc, F1, F12 keys
…
:(
…
(wish for luck)
grab external usb keyboard
plug it on
press power, press F2 and, tadaa…, oh my God, that BIOS interface…
…
(reinstalling)
…
now my ASUS Eee PC have 64bit OS on it
:)
Thursday, November 7, 2013
Laggy Mavericks and QuickLook that Neither Quick nor Look on Anything
Don't know what happened, but my Maverick is getting slower and slower.
QuickLook can't preview .f, .py and .tex files (and other files type too as I tried to "quick-looking" other type but fortran, python and latex is what I "quick-looking" most).
QuickLook can't preview .f, .py and .tex files (and other files type too as I tried to "quick-looking" other type but fortran, python and latex is what I "quick-looking" most).
Thursday, May 2, 2013
Monte Carlo PI
c calculating pi by throwing stones
c
PROGRAM stones
IMPLICIT none
c
c declarations
REAL*8 area, x, y, DRAND48
INTEGER i, max, pi, seed
c
c set parameters (number of stones, seed for generator)
max = 1000
seed = 11168
c
c open file, set initial value, seed generator
OPEN(6, FILE='pif.dat')
pi=0
call seed48(seed)
c
c execute
DO 10 i=1, max
x = DRAND48()*2-1
y = DRAND48()*2-1
IF ((x*x + y*y) .LT. 1) THEN
pi = pi+1
ENDIF
area = 4.0 * pi/REAL(i)
WRITE(6,*) i, area
10 CONTINUE
STOP
END
PI on MPI
still trying...
program main
include "mpif.h"
double precision PI25DT
parameter (PI25DT = 3.141592653589793238462643d0)
double precision mypi, pi, h, sum, x, f, a
integer n, myid, numprocs, i, ierr
c function to integrate
f(a) = 4.d0 / (1.d0 + a*a)
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, numprocs, ierr)
10 if ( myid .eq. 0 ) then
print *, 'Enter the number of intervals: (0 quits) '
read(*,*) n
endif
c broadcast n
call MPI_BCAST(n,1,MPI_INTEGER,0,MPI_COMM_WORLD,ierr)
c check for quit signal
if ( n .le. 0 ) goto 30
c calculate the interval size
h = 1.0d0/n
sum = 0.0d0
do 20 i = myid+1, n, numprocs
x = h * (dble(i) - 0.5d0)
sum = sum + f(x)
20 continue
mypi = h * sum
c collect all the partial sums
call MPI_REDUCE(mypi,pi,1,MPI_DOUBLE_PRECISION,MPI_SUM,0,
& MPI_COMM_WORLD,ierr)
c node 0 prints the answer.
if (myid .eq. 0) then
print *, 'pi is ', pi, ' Error is', abs(pi - PI25DT)
endif
goto 10
30 call MPI_FINALIZE(ierr)
stop
end
Wednesday, April 24, 2013
Hello Canvas World
Back to first again
Tulisan di atas ditulis dalam canvas seperti kode di bawah. Di sini perintahnya adalah
context.fillText('Hello Canvas World',canvas.width/2-150,canvas.height/2+15);
context adalah '2d' dari canvas, dalam hal ini context kotak yang menyimpan perintah-perintah '2d' canvas seperti contoh diatas, yaitu menulis text.
fillText('tulisan', posisi_x,posisi_y) adalah perintah untuk menampilkan tulisan dengan warna sesuai fillStyle, yaitu 'green'
strokeText('tulisan', posisi_x,posisi_y) adalah perintah untuk menampilkan tulisan dengan warna 'tepi' sesuai strokeStyle yaitu 'red'
var canvas = document.getElementById('canvasexample'),
context = canvas.getContext('2d');
context.font = '38pt Arial';
context.fillStyle = 'green';
context.strokeStyle = 'red';
context.fillText('Hello Canvas',canvas.width/2-150,canvas.height/2+15);
context.strokeText('Hello Canvas',canvas.width/2-150,canvas.height/2+15);
Saturday, December 8, 2012
Mountain Lion's Spotlight didn't Spot Application
Maybe it's just me, after upgrading from leopard to snowleopard to lion and finally mountain lion (always upgrade, no fresh install), this big cat suddenly refuse to index my Application. Whenever I type application name in Spotlight, it just show document, picture but not Application. Typing "macvim" bring me to macvim installation folder, macvim on the web but not Macvim apps. Spotlight setting clearly didn't ban Application folder, so maybe this is another Mountain Lion problem
Still looking for solution...
Still looking for solution...
Mountain Lion's Fullscreen Apps on Extended Display
It seems that weakness of this big cat isn't resolved yet. I used Pages in my Desktop while the big one browsing trough web using safari for refence. When I switch (automatically, bad behaviour I think) to fullscreen on Pages, suddenly the other display become blank (not actually blank, just linen-like wall, or maybe canvas).
Monday, December 3, 2012
Playing with Opacity on HTML5's canvas
What I do here is wrap whole canvas on this program with a rectangle with opacity 0.1. So the code (under script tag) become like this:
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
var n=10;
var bBola=new Array();
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
for (i=0;i < n;i++){
dx = Math.random()*10-5;
dy = Math.random()*10-5;
bBola.push(new bola('#007700', 11,dx,dy));
}
setInterval(draw,10);
}
function draw(){
for (i=0;i < n;i++){
if (bBola[i].x > = (canvas.width - bBola[i].r) || bBola[i].x < = bBola[i].r) bBola[i].dx *= -1;
if (bBola[i].y > = (canvas.height - bBola[i].r) || bBola[i].y < = bBola[i].r) bBola[i].dy *= -1;
//buat
bBola[i].context.beginPath();
bBola[i].context.fillStyle = bBola[i].color;
bBola[i].context.arc(bBola[i].x,bBola[i].y,bBola[i].r,0,Math.PI*2,false);
bBola[i].context.fill();
//gerak
bBola[i].x+=bBola[i].dx;
bBola[i].y+=bBola[i].dy;
}
context.fillStyle='rgba(255,255,255,.1)';
context.fillRect(0,0,canvas.width,canvas.height);
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
window.onload = function(){
init()
}
Here the complete html page code
<head>
<script>
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
var n=10;
var bBola=new Array();
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
for (i=0;i<n;i++){
dx = Math.random()*10-5;
dy = Math.random()*10-5;
bBola.push(new bola('#007700', 11,dx,dy));
}
setInterval(draw,10);
}
function draw(){
for (i=0;i<n;i++){
//pantul
if (bBola[i].x >= (canvas.width - bBola[i].r) || bBola[i].x <= bBola[i].r) bBola[i].dx *= -1;
if (bBola[i].y >= (canvas.height - bBola[i].r) || bBola[i].y <= bBola[i].r) bBola[i].dy *= -1;
//buat
bBola[i].context.beginPath();
bBola[i].context.fillStyle = bBola[i].color;
bBola[i].context.arc(bBola[i].x,bBola[i].y,bBola[i].r,0,Math.PI*2,false);
bBola[i].context.fill();
//gerak
bBola[i].x+=bBola[i].dx;
bBola[i].y+=bBola[i].dy;
}
context.fillStyle='rgba(255,255,255,.1)';
context.fillRect(0,0,canvas.width,canvas.height);
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
window.onload = function(){
init()
}
</script>
</head>
<body>
<canvas height="300" id="myCanvas" width="500">
</canvas>
</body>
Friday, November 30, 2012
Bouncing Ball using Array on Canvas (without prototype method) in HTML 5
Here the code for this
<head>
<script>
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
var n=5;
var bBola=new Array();
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
for (i=0;i<n;i++){
dx = Math.random()*10-5;
dy = Math.random()*10-5;
bBola.push(new bola('#007700', 17,dx,dy));
}
setInterval(draw,10);
}
function draw(){
context.clearRect(0,0, 500,300);
for (i=0;i<n;i++){
//pantul
if (bBola[i].x >= (canvas.width - bBola[i].r) || bBola[i].x <= bBola[i].r) bBola[i].dx *= -1;
if (bBola[i].y >= (canvas.height - bBola[i].r) || bBola[i].y <= bBola[i].r) bBola[i].dy *= -1;
//buat
bBola[i].context.beginPath();
bBola[i].context.fillStyle = bBola[i].color;
bBola[i].context.arc(bBola[i].x,bBola[i].y,bBola[i].r,0,Math.PI*2,false);
bBola[i].context.fill();
//gerak
bBola[i].x+=bBola[i].dx;
bBola[i].y+=bBola[i].dy;
}
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
window.onload = function(){
init()
}
</script>
</head>
<body>
<canvas height="300" id="myCanvas" width="500">
</canvas>
</body>
<head>
<script>
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
var n=5;
var bBola=new Array();
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
for (i=0;i<n;i++){
dx = Math.random()*10-5;
dy = Math.random()*10-5;
bBola.push(new bola('#007700', 17,dx,dy));
}
setInterval(draw,10);
}
function draw(){
context.clearRect(0,0, 500,300);
for (i=0;i<n;i++){
//pantul
if (bBola[i].x >= (canvas.width - bBola[i].r) || bBola[i].x <= bBola[i].r) bBola[i].dx *= -1;
if (bBola[i].y >= (canvas.height - bBola[i].r) || bBola[i].y <= bBola[i].r) bBola[i].dy *= -1;
//buat
bBola[i].context.beginPath();
bBola[i].context.fillStyle = bBola[i].color;
bBola[i].context.arc(bBola[i].x,bBola[i].y,bBola[i].r,0,Math.PI*2,false);
bBola[i].context.fill();
//gerak
bBola[i].x+=bBola[i].dx;
bBola[i].y+=bBola[i].dy;
}
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
window.onload = function(){
init()
}
</script>
</head>
<body>
<canvas height="300" id="myCanvas" width="500">
</canvas>
</body>
The Bouncing Ball
The Code for this under the script tag
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
setInterval(draw,10);
bal=new bola('#007700', 17,dx,dy);
}
function draw(){
context.clearRect(0,0, 300,300);
bal.Pantul();
bal.Create();
bal.x+=bal.dx;
bal.y+=bal.dy;
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
bola.prototype.Create = function (){
this.context.beginPath();
this.context.fillStyle = this.color;
this.context.arc(this.x,this.y,this.r,0,Math.PI*2,false);
this.context.fill();
}
bola.prototype.Pantul = function (){
if (this.x >= (canvas.width - this.r) || this.x <= this.r) this.dx *= -1;
if (this.y >= (canvas.height - this.r) || this.y <= this.r) this.dy *= -1;
}
window.onload = function(){
init()
}
Friday, November 16, 2012
Bouncing Ball using Array in HTML5
I want to create bouncing ball program that's very easy on Flash, Python or Delphi yet very tricky on html5. The program consist of n ball with random velocity (each) moving in a 2d box (oh yeah, square then :) )
I am playing with array in html5 script which is helpful on this program. I don't declare the array using
that come as standart on many language, but prefer
instead, just like list on python. In this program, array's just like container for ball.
In html5, moving an object is a bit tricky and, for some Pascal programmer like me, bringing an old memory of draw-clear-draw-clear... cycle; draw a ball, delete it, draw the same ball but slightly right, delet it, ... and so on. All that kind of tedious job, but it worth for the sake of fast execution and no-need-slow-loading-flash-player thing.
Here's the code under script tag. Keep in mind that many variable's name is in indonesian (ball -> bola, bounce->pantul, collision -> tumbukan )aBola = new array()
that come as standart on many language, but prefer
aBola = []
instead, just like list on python. In this program, array's just like container for ball.
In html5, moving an object is a bit tricky and, for some Pascal programmer like me, bringing an old memory of draw-clear-draw-clear... cycle; draw a ball, delete it, draw the same ball but slightly right, delet it, ... and so on. All that kind of tedious job, but it worth for the sake of fast execution and no-need-slow-loading-flash-player thing.
(to be continued)
//bola:ball
//pantul:bounce
var context;
var n=10;
// membuat bola
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
bola.prototype.Create = function (){
this.context.beginPath();
this.context.fillStyle = this.color;
this.context.arc(this.x,this.y,this.r,0,Math.PI*2,false);
this.context.fill();
}
bola.prototype.Pantul = function (){
if (this.x >= (canvas.width - this.r) || this.x <= this.r) this.dx *= -1;
if (this.y >= (canvas.height - this.r) || this.y <= this.r) this.dy *= -1;
}
function init(){
canvas = document.getElementById("myCanvas")
context = canvas.getContext('2d');
// membuat array untuk bola
//create array for ball
aBola = [];
for (i=1;i<=n;i++){
//membuat bola sejumlah n dengan dx dan dy acak
//create n balls with random dx and dy
dx = Math.random()*10-5;
dy = Math.random()*10-5;
aBola.push(new bola('#007700', 17,dx,dy));
}
setInterval(draw,20);
}
function draw(){
context.clearRect(0,0, 500,350);
for (i in aBola) {
//menggerakkan bola
//moving balls
aBola[i].x += aBola[i].dx;
aBola[i].y += aBola[i].dy;
aBola[i].Pantul();
aBola[i].Create();
}
}
Tuesday, November 13, 2012
2D/3D Ball Collision
I used on 1D collission problem where, in case of elastic collision, the ball is changing velocity each other. In 2D/3D case however, the collision is not always head-on collision (which is basically 1 dimension collision).
Head-on
The system above's easy too solve, as simple as interchanging velocity (in elastic case).
Not head-on
Head-on
The system above's easy too solve, as simple as interchanging velocity (in elastic case).
Not head-on
When two balls are in non-head-on collision we could always using transposed new coordinate where both of ball center are on the new x-axis like below
On the new coordinate, we can treat the velocities along x-axis as one dimensional collision case and let go on other component (y, z) intact.
Below's snippet from python code of balls collision detection; the whole code is code of moving many ball on a box.
###deteksi tumbukan antar bola
for i in arange(jumlah):
for j in arange(i+1,jumlah):
jarak=mag(lbola[i].pos-lbola[j].pos)
if jarak<(lbola[i].radius+lbola[j].radius):
arah=norm(lbola[j].pos-lbola[i].pos)
vi=dot(lbola[i].v,arah)
vj=dot(lbola[j].v,arah)
tukar=vj-vi
lbola[i].v=lbola[i].v+tukar*arah
lbola[j].v=lbola[j].v-tukar*arah
pantul=lbola[i].radius+lbola[j].radius-jarak
lbola[i].pos=lbola[i].pos-pantul*arah
lbola[j].pos=lbola[j].pos+pantul*arah
Moving to HTML5
After years fighting the slow loading flash without alternative software, I begin to think seriously about moving to HTML5 coding. Altough it ain't true software for me, it provide what I need mostly: animation.
HTML5 support canvas, audio ad video tag, javascript. Need array data? No problem. If then else? OK.
So, begin...
HTML5 support canvas, audio ad video tag, javascript. Need array data? No problem. If then else? OK.
So, begin...
Monday, April 9, 2012
Array di Delphi
Array dapat digunakan sebagai penyimpanan sementara. Array dapat dipandang sebagai sebuah variabel yang berisi barisan variabel di dalamnya.
Berikut adalah contoh penggunaan array di delphi sekaligus penggunaan listbox dan radiobutton.
Buat sebuah form dengan satu edit, satu button, satut listbox dan tiga radiobutton.
Berikut adalah contoh penggunaan array di delphi sekaligus penggunaan listbox dan radiobutton.
Buat sebuah form dengan satu edit, satu button, satut listbox dan tiga radiobutton.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
ListBox1: TListBox;
RadioButton3: TRadioButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
nama:array [0..100] of string;
n:integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
radiobutton1.Caption:='input';
radiobutton2.Caption:='tampilkan';
radiobutton3.Caption:='semua';
edit1.Text:='';
radiobutton1.Checked:=true;
button1.Caption:='OK';
n:=0;
end;
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
if (radiobutton1.Checked=true) and not(edit1.Text='') then begin
listbox1.Items.add(edit1.Text);
n:=n+1;
nama[n]:=edit1.Text;
end;
if radiobutton2.Checked=true then begin
listbox1.Clear;
if (edit1.Text<='9') and (edit1.Text>='0') and not(edit1.Text='') then begin
listbox1.Items.Add(nama[strtoint(edit1.Text)]);
end;
end;
if radiobutton3.Checked=true then begin
listbox1.Clear;
for i:=1 to n do begin
listbox1.Items.Append(nama[i]);
end;
end;
end;
end.
Subscribe to:
Posts (Atom)
My sky is high, blue, bright and silent.
Nugroho's (almost like junk) blog
By: Nugroho Adi Pramono
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)