Senin, 12 November 2012

Enable and Start Mysql on Fedora 16/17

Sumber: http://www.ebugg-i.com/technology/howto/how-to-enable-start-restart-and-stop-mysql-in-fedora-16.html


1. Enable MySql using systemctl

** systemctl - Control the systemd system and service manager

[root@stk /]# su
[root@stk /]# systemctl enable mysqld.service

2. Start mysqld using this command "systemctl start mysqld.service"

[root@stk /]# systemctl start mysqld.service
Check the status of mysqld service using "systemctl status mysqld.service"

How to Check mysqld Status ?

[root@stk ~]# systemctl status mysqld.service
mysqld.service - MySQL database server
Loaded: loaded (/lib/systemd/system/mysqld.service; disabled)
Active: active (running) since Sat, 31 Dec 2011 18:26:00 +0400; 3h 0min ago
Main PID: 1791 (mysqld)
CGroup: name=systemd:/system/mysqld.service
* 1791 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/...

How to Restart mysqld ?


Restart mysqld service : "systemctl restart mysqld.service"

[root@stk /]# systemctl restart mysqld.service
Stop mysqld service : "systemctl restart mysqld.service"
[root@stk /]# systemctl stop mysqld.service

Minggu, 04 November 2012

Pemograman Grafik :: OpenGL C++

Membuat 26 Posisi Kamera:
Tampilan Output:



















Kode Program:


/*
 * Tanggal: Minggu, 04 November 2012 18:11:00
 * Program Kamera 26 Posisi
 * Dikembangkan Oleh Firmansyah Maulana
 * Referensi: http://www.komoto.org/opengl/sample06.html
 * Pada 20 Desember 1999 Oleh Komoto Masahiro
 *
 */

#include<stdlib.h>
#include<ctype.h>
#include<GL/glut.h>
#include<GL/gl.h>
#include<math.h>

//Deklarasi Variable
static GLfloat rot_y, rot_x;
static GLfloat bgn_y, bgn_x;
static int mouse_x, mouse_y;
static GLuint cubelist;

//Fungsi Tempat Menampilkan
void display_func(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0,1.0,1.0,1.0);
glPushMatrix();
glTranslatef(0.0, 0.0, -15.0);
glRotatef(rot_x, 1.0, 0.0, 0.0);
glRotatef(rot_y, 0.0, 1.0, 0.0);
glCallList(cubelist);
glPopMatrix();
glutSwapBuffers();
}

//Fungsi Membuat Lingkaran
void drawCircle( float Radius, int numPoints )
{
glBegin( GL_LINE_STRIP );
int i; float PI= 3.14;
for(i=0; i<numPoints; i++ )
{
float Angle = i * (2.0*PI/numPoints); // use 360 instead of 2.0*PI if
float X = cos( Angle )*Radius;        // you use d_cos and d_sin
float Y = sin( Angle )*Radius;
glVertex2f( X, Y);
}
glEnd();
}

//Fungsi Membuat BangunRuang
GLuint make_cube(void)
{
GLint list;
//Kumpulan Titik Kordinat
static GLfloat vert[][4]={

{ 2.0,  2.0,  4.0}, //0
{ 0.0,  2.0,  4.0}, //1
{-2.0,  2.0,  4.0}, //2
{ 2.0,  0.0,  4.0}, //3
{ 0.0,  0.0,  4.0}, //4
{-2.0,  0.0,  4.0}, //5
{ 2.0, -2.0,  4.0}, //6
{ 0.0, -2.0,  4.0}, //7
{-2.0, -2.0,  4.0}, //8

{ 2.0,  2.0, -4.0}, //9
{ 0.0,  2.0, -4.0}, //10
{-2.0,  2.0, -4.0}, //11
{ 2.0,  0.0, -4.0}, //12
{ 0.0,  0.0, -4.0}, //13
{-2.0,  0.0, -4.0}, //14
{ 2.0, -2.0, -4.0}, //15
{ 0.0, -2.0, -4.0}, //16
{-2.0, -2.0, -4.0}, //17

{ 2.0,  2.0,  0.0}, //18
{ 0.0,  2.0,  0.0}, //19
{-2.0,  2.0,  0.0}, //20
{ 2.0,  0.0,  0.0}, //21
{ 0.0,  0.0,  0.0}, //22
{-2.0,  0.0,  0.0}, //23
{ 2.0, -2.0,  0.0}, //24
{ 0.0, -2.0,  0.0}, //25
{-2.0, -2.0,  0.0}, //26

//{ 0.0,  0.0,  0.0}, //Titik Tengah
};

//Kumpulan Warna
static GLfloat color[][4]={
{1.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0},
{0.0, 0.0, 1.0, 0.0},
{0.0, 1.0, 1.0, 0.0},
{1.0, 0.0, 1.0, 0.0},
{1.0, 1.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
};


list=glGenLists(1);
glNewList(list, GL_COMPILE);

//Memanggil Fungsi Membuat Lingkaran
drawCircle(1, 360);

//Membuat Rangka BangunRuang
glBegin(GL_LINES);
glColor3fv(color[6]);

//Merah
//Garis Horizontal
glVertex3fv(vert[0]);
glVertex3fv(vert[2]);
glVertex3fv(vert[3]);
glVertex3fv(vert[5]);
glVertex3fv(vert[6]);
glVertex3fv(vert[8]);
//Garis Vertikal
glVertex3fv(vert[0]);
glVertex3fv(vert[6]);
glVertex3fv(vert[2]);
glVertex3fv(vert[8]);
glVertex3fv(vert[1]);
glVertex3fv(vert[7]);

//Biru
//Garis Horizontal
glVertex3fv(vert[9]);
glVertex3fv(vert[11]);
glVertex3fv(vert[12]);
glVertex3fv(vert[14]);
glVertex3fv(vert[15]);
glVertex3fv(vert[17]);
//Garis Vertikal
glVertex3fv(vert[9]);
glVertex3fv(vert[15]);
glVertex3fv(vert[11]);
glVertex3fv(vert[17]);
glVertex3fv(vert[10]);
glVertex3fv(vert[16]);

//Hijau
//Garis Horizontal
glVertex3fv(vert[18]);
glVertex3fv(vert[20]);
glVertex3fv(vert[21]);
glVertex3fv(vert[23]);
glVertex3fv(vert[24]);
glVertex3fv(vert[26]);
//Garis Vertikal
glVertex3fv(vert[18]);
glVertex3fv(vert[24]);
glVertex3fv(vert[20]);
glVertex3fv(vert[26]);
glVertex3fv(vert[19]);
glVertex3fv(vert[25]);

//Garis Penghubung
glVertex3fv(vert[0]);
glVertex3fv(vert[9]);
glVertex3fv(vert[1]);
glVertex3fv(vert[10]);
glVertex3fv(vert[2]);
glVertex3fv(vert[11]);
glVertex3fv(vert[3]);
glVertex3fv(vert[12]);
glVertex3fv(vert[4]);
glVertex3fv(vert[13]);
glVertex3fv(vert[5]);
glVertex3fv(vert[14]);
glVertex3fv(vert[6]);
glVertex3fv(vert[15]);
glVertex3fv(vert[7]);
glVertex3fv(vert[16]);
glVertex3fv(vert[8]);
glVertex3fv(vert[17]);

glEnd();

glBegin(GL_POINTS);
//Titik Merah
glColor3fv(color[0]);
glVertex3fv(vert[0]);
glVertex3fv(vert[1]);
glVertex3fv(vert[2]);
glVertex3fv(vert[3]);
glVertex3fv(vert[4]);
glVertex3fv(vert[5]);
glVertex3fv(vert[6]);
glVertex3fv(vert[7]);
glVertex3fv(vert[8]);

//Titik Biru
glColor3fv(color[2]);
glVertex3fv(vert[9]);
glVertex3fv(vert[10]);
glVertex3fv(vert[11]);
glVertex3fv(vert[12]);
glVertex3fv(vert[13]);
glVertex3fv(vert[14]);
glVertex3fv(vert[15]);
glVertex3fv(vert[16]);
glVertex3fv(vert[17]);

//Titik Hijau
glColor3fv(color[1]);
glVertex3fv(vert[18]);
glVertex3fv(vert[19]);
glVertex3fv(vert[20]);
glVertex3fv(vert[21]);
glVertex3fv(vert[22]);
glVertex3fv(vert[23]);
glVertex3fv(vert[24]);
glVertex3fv(vert[25]);
glVertex3fv(vert[26]);

glEnd();
glPointSize(5); //Ukuran Titik
glEndList();

return list;
}

//Fungsi Mengatur BangunRuang
void reshape_func(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 3.0, 10000.0);
glMatrixMode(GL_MODELVIEW);
}

//Fungsi Mouse Ketika di-Klik
void mouse_func(int button, int stat, int x, int y)
{
if(GLUT_DOWN==stat && GLUT_LEFT==button){
mouse_x=x;
mouse_y=y;
bgn_y=rot_y;
bgn_x=rot_x;
}
}

//Fungsi Ketika di-Drag
void drag_func(int x, int y)
{

rot_x=(GLfloat)(y-mouse_y)+bgn_x;
rot_y=(GLfloat)(x-mouse_x)+bgn_y;
if(90<rot_x)
{
rot_x=90;
}

if(rot_x<-90)
{
rot_x=-90;
}

glutPostRedisplay();
}

//Fungsi Ketika Keyboard 'Q' di Tekan
void key_func(unsigned char key, int x, int y)
{
switch(toupper(key)){
case 0x1b:
case 'Q':
exit(0);
break;
}
}

//Fungsi Ketika Keyboard Arah di Tekan
void skey_func(int key, int x, int y)
{
switch(key){
case GLUT_KEY_UP:
if(rot_x<90){
rot_x+=10;
}
break;
case GLUT_KEY_DOWN:
if(-90<rot_x){
rot_x-=10;
}
break;
case GLUT_KEY_LEFT:
rot_y+=10;
break;
case GLUT_KEY_RIGHT:
rot_y-=10;
break;
}

glutPostRedisplay();
}


//Fungsi Utama
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(500,500); //Ukuran Layar Window
glutCreateWindow("UTS | 26 Posisi Kamera - Firmansyah Maulana"); //Nama Judul Window
glutDisplayFunc(display_func); //Ambil Fungsi Tempat Menampilkan
glutReshapeFunc(reshape_func); //Ambil Fungsi Mengatur BangunRuang
glutKeyboardFunc(key_func); //Ambil Fungsi Ketika Keyboard 'Q' di Tekan
glutSpecialFunc(skey_func); //Ambil Fungsi Ketika Keyboard Arah di Tekan
glutMotionFunc(drag_func); //Ambil Fungsi Ketika di-Drag
glutMouseFunc(mouse_func); //Ambil Fungsi Ketika di-Klik
glEnable(GL_DEPTH_TEST);
cubelist=make_cube();
glutMainLoop();

return 0;
}

Pemograman Grafik :: OpenGL C++

Membuat Animasi Pesawat Tempur:
Tampilan Output:



















Kode Program:

/*
 * Tanggal: Minggu, 04 November 2012 18:11:00
 * Program Pesawat Terbang 2 Dimensi
 * Dikembangkan Oleh Firmansyah Maulana
 * Referensi: http://aliphoemarley.blogspot.com/2011/10/membuat-baling-baling-dengan-animasi-di.html
 * Pada Tanggal 24 Oktober 2011 Oleh ALIVI NUR ROSIDA
 *
 */

#include <GL/gl.h>
#include <GL/glut.h>

//Deklarasi Perputaran Pesawat
int x=0;
int z=0;

//Fungsi Membuat Pesawat
void pesawat()
{
glBegin(GL_LINES);
glColor3f (0.0, 0.0, 1.0);

//Senjata Pesawat Kiri 1
glVertex3f (0.40, 0.48, 0.0);
glVertex3f (0.40, 0.42, 0.0);

//Senjata Pesawat Kiri 2
glVertex3f (0.35, 0.46, 0.0);
glVertex3f (0.35, 0.40, 0.0);

//Senjata Pesawat Kiri 3
glVertex3f (0.30, 0.44, 0.0);
glVertex3f (0.30, 0.40, 0.0);

//Senjata Pesawat Kanan 1
glVertex3f (0.60, 0.48, 0.0);
glVertex3f (0.60, 0.42, 0.0);

//Senjata Pesawat Kanan 2
glVertex3f (0.65, 0.46, 0.0);
glVertex3f (0.65, 0.40, 0.0);

//Senjata Pesawat Kanan 3
glVertex3f (0.70, 0.44, 0.0);
glVertex3f (0.70, 0.40, 0.0);

glEnd();
glLineWidth(5);

glBegin(GL_POLYGON);
glColor3f (0.0, 1.0, 0.0);

//Kepala Pesawat
glVertex3f (0.50, 0.50, 0.00);
glVertex3f (0.47, 0.50, 0.00);
glVertex3f (0.47, 0.55, 0.00);
glVertex3f (0.50, 0.62, 0.00);
glVertex3f (0.53, 0.55, 0.00);
glVertex3f (0.53, 0.50, 0.00);

//Sayap Pesawat
glVertex3f (0.50, 0.50, 0.00);
glVertex3f (0.50, 0.42, 0.00);
glVertex3f (0.20, 0.38, 0.00);
glVertex3f (0.20, 0.40, 0.00);
glVertex3f (0.50, 0.45, 0.00);
glVertex3f (0.80, 0.40, 0.00);
glVertex3f (0.80, 0.38, 0.00);
glVertex3f (0.50, 0.42, 0.00);

//Badan Pesawat
glVertex3f (0.50, 0.50, 0.00);
glVertex3f (0.47, 0.55, 0.0);
glVertex3f (0.47, 0.33, 0.0);
glVertex3f (0.50, 0.35, 0.0);
glVertex3f (0.53, 0.33, 0.0);
glVertex3f (0.53, 0.55, 0.0);
glVertex3f (0.50, 0.45, 0.0);

//Sayap Pesawat Bawah
glVertex3f (0.50, 0.35, 0.00);
glVertex3f (0.50, 0.42, 0.00);
glVertex3f (0.40, 0.28, 0.00);
glVertex3f (0.40, 0.30, 0.00);
glVertex3f (0.50, 0.45, 0.00);
glVertex3f (0.60, 0.30, 0.00);
glVertex3f (0.60, 0.28, 0.00);
glVertex3f (0.50, 0.42, 0.00);
glEnd();
}

//Fungsi Tempat Menampilkan Pesawat
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glClearColor(0.0,1.1,1.1,1.1);
glShadeModel (GL_SMOOTH);
glColor3f (1.0, 1.0, 0.0);

//Ambil Fungsi Pesawat
pesawat();

glRotatef(x,0,0,45); //Untuk Membuat Rotasi Perputaran
glFlush ();
}

//Fungsi Keluar dengan Keyboard 'q'
void kunci(unsigned char key, int x, int y)
{
switch (key)
{
case 27 :
case 'q':
exit(0);
break;
}
glutPostRedisplay();
}

//Fungsi Waktu Berputar
void timer (int value){
if (z <= 360){
x = 1;
z +=1;
}
glutPostRedisplay();
glutTimerFunc(15,timer,0);
}

//Fungsi Utama
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitWindowSize(500,500); //Ukuran Layar Window
glutInitWindowPosition(100,100); //Posisi Window
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutCreateWindow("UTS | Animasi 2D - Firmansyah Maulana"); //Nama Judul Window
glutDisplayFunc(display); //Ambil Fungsi Tempat Menampilkan Pesawat
glutKeyboardFunc(kunci); //Ambil Fungsi Keluar dengan Keyboard 'q'
glutTimerFunc(1,timer,0); //Ambil Fungsi Waktu Berputar
glutMainLoop();
return 0;
}