Friday, February 17, 2017

Install Wordpress on Ubuntu

Installation

To install WordPress, run the following comand in the command prompt:
    sudo apt install wordpress
You should also install apache2 web server and mysql server. For installing apache2 web server, please refer to Installation sub-section in HTTPD - Apache2 Web Server section. For installing mysql server, please refer to Installation sub-section in MySQL section.

Configuration

For configuring your first WordPress application, configure an apache site. Open /etc/apache2/sites-available/wordpress.conf and write the following lines:
        Alias /blog /usr/share/wordpress
        
            Options FollowSymLinks
            AllowOverride Limit Options FileInfo
            DirectoryIndex index.php
            Order allow,deny
            Allow from all
        
        
            Options FollowSymLinks
            Order allow,deny
            Allow from all
        
           
Enable this new WordPress site
    sudo a2ensite wordpress
Once you configure the apache2 web server and make it ready for your WordPress application, you should restart it. You can run the following command to restart the apache2 web server:
sudo systemctl restart apache2.service
To facilitate multiple WordPress installations, the name of this configuration file is based on the Host header of the HTTP request. This means that you can have a configuration per VirtualHost by simply matching the hostname portion of this configuration with your Apache Virtual Host. e.g. /etc/wordpress/config-10.211.55.50.php, /etc/wordpress/config-hostalias1.php, etc. These instructions assume you can access Apache via the localhost hostname (perhaps by using an ssh tunnel) if not, replace /etc/wordpress/config-localhost.php with /etc/wordpress/config-NAME_OF_YOUR_VIRTUAL_HOST.php.
Once the configuration file is written, it is up to you to choose a convention for username and password to mysql for each WordPress database instance. This documentation shows only one, localhost, example.
Now configure WordPress to use a mysql database. Open /etc/wordpress/config-localhost.php file and write the following lines:

Now create this mysql database. Open a temporary file with mysql commands wordpress.sql and write the following lines:
CREATE DATABASE wordpress;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
ON wordpress.*
TO wordpress@localhost
IDENTIFIED BY 'yourpasswordhere';
FLUSH PRIVILEGES;
Execute these commands.
cat wordpress.sql | sudo mysql --defaults-extra-file=/etc/mysql/debian.cnf
Your new WordPress can now be configured by visiting http://localhost/blog/wp-admin/install.php. (Or http://NAME_OF_YOUR_VIRTUAL_HOST/blog/wp-admin/install.php if your server has no GUI and you are completing WordPress configuration via a web browser running on another computer.) Fill out the Site Title, username, password, and E-mail and click Install WordPress.
Note the generated password (if applicable) and click the login password. Your WordPress is now ready for use.


https://help.ubuntu.com/lts/serverguide/wordpress.html

Monday, February 13, 2017

Blank screen after entering password on login screen Ubuntu

Right click on your virtue machine -> setting-> hardware -> display and deselect the option "3D acceleration"

source

Thursday, July 30, 2015

Rangkaian Kiprok Sepeda Motor (Shunt Regulator)



ref:
Single phase voltage regulator (full wave)

Artikel ini menyambung artikel sebelumnya tentang kiprok honda tiger. Link di bawah ini menarik untuk dipelajari.
 
Link1 (alter)
Link2
Link3
Link4


Friday, January 3, 2014

Passing two dimensional array

#include
#include

foo(char in[][10]){
char *a = "Hello";
char *b = "Helle";

memcpy(in[0],a,strlen(a)+1);
memcpy(in[1],b,strlen(b)+1);
}


int main(int argc, char *argv[]){
char var[2][10];

  foo(var);
  printf("out: %s %s \n", var[0], var[1]);
 
    return(0);
}

Thursday, November 28, 2013

NTP Client

Linux version

#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <arpa/inet.h >

int main(void)
{
    int sockfd = 0, n = 0, ii = 1;
    char recvBuff[1024];
    struct sockaddr_in serv_addr; 
    setvbuf(stdout, NULL, _IONBF, 0);
printf("Retrieving time, please wait ");
    memset(recvBuff, '0',sizeof(recvBuff));
    n=-1;

    while(n<=0)
    {
//    printf("====== attempt %d \n\n", ii);
    printf(".");
    
    if (ii == 50)
    {
   printf("\n");
   ii =0;
   }
    
    if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    {
        printf("\n Error : Could not create socket \n");
        return 1;
    } 

    serv_addr.sin_addr.s_addr = inet_addr("64.90.182.55");
//     serv_addr.sin_addr.s_addr = inet_addr("96.47.67.105");
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_port = htons(13); 

       if( connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
       {
          printf("\n Error : Connect Failed \n");
          return 1;
       } 

       n = read(sockfd, recvBuff, sizeof(recvBuff)-1);
       close(sockfd);
       usleep(10000);
       ii++;
    }
      recvBuff[n] = 0;
      printf("%s\n",recvBuff);

    return 0;
}

Windows version

//============================================================================
// Name        : windows_time_client.cpp
// Author      : Norma Hermawan
// Version     :
// Copyright   : Your copyright notice
// Description : CONNECT TO REMOTE HOST (CLIENT APPLICATION)
//               Include the needed header files.
//               Don’t forget to link libws2_32.a to your program as well
//               2. To set the library
//               Bring up the properties box for the project.
//               Select all configurations.
//               In the linker section on the left handside - select Input and in the right hand side add
//               ws2_32.lib in the Additional Dependencies box

//============================================================================

#include "stdafx.h"
#include <winsock.h>
#include <iostream>

using namespace std;
#define TIMESERV_PORT  13
//#define TIMESERV_IP    "96.47.67.105" // this is time server IP
#define TIMESERV_IP    "64.90.182.55" // this is time server IP
//#define TIMESERV_IP    "128.138.188.172" // this is time server IP
//#define TIMESERV_IP    "211.233.40.78" // this is time server IP
//#define TIMESERV_IP    "203.160.128.178" // this is time server IP
//#define TIMESERV_IP    "113.20.31.30" // this is time server IP

int main() {
SOCKET sfd; //Socket handle
char buffer[80];
int n, ii =1;
time_t prev_stamp;

printf("Retrieving time, please wait ",ii);
do{
//    system ("ping 64.90.182.55");
//Start up Winsock…
// printf("Starting winsock ============================= attempt %d\n\n",ii);
// printf("Retrieving time, attempt %d\n\n",ii);
printf(".");
if (ii==50){
      printf("\n");
      ii = 0;
            }
WSADATA wsadata;

int error = WSAStartup(0x0202, &wsadata);

//Fill out the information needed to initialize a socket…
SOCKADDR_IN addr; //Socket address information

addr.sin_family = AF_INET; // address family Internet
addr.sin_port = htons (TIMESERV_PORT); //Port to connect on
addr.sin_addr.s_addr = inet_addr (TIMESERV_IP); //Target IP

// printf("Create socket\n");
sfd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); //Create socket
// printf("Establishing Connection \n");
    int res = connect(sfd, (sockaddr*) &addr, sizeof(addr));
//    printf("Connectition is established \n");
memset(buffer, 0, sizeof(buffer)); //Clear the buffer
// printf("Receiving signal \n\n");
prev_stamp = time(NULL);
//Put the incoming text into our buffer
n = recv (sfd, buffer, sizeof(buffer)-1, 0);//) <= 0) &&((time(NULL) - prev_stamp) < 5))
    
closesocket(sfd);
WSACleanup(); //Clean up Winsock
// Sleep(10);
ii++;
}
while(n<=0);
printf("\nTime: ", n);
buffer[n] = 0;
printf("%s\n",buffer);

system("Pause");
return 0;
}

Tuesday, November 26, 2013

Time Slice Multitasking

This is a code example of time slice multitasking in C.

#include
#define KERNEL_SLEEP_US 1000
#define msleep(x) sleepc++; if(sleepc != x){return;}else{sleepc=0;}
int program_end = 0;

void task1(void) {
static int pc=0,sleepc=0;
switch (pc){
case 0: goto label0;
case 1: goto label1;
case 2: goto label2;
case 3: goto label3;
case 4: goto label4;
case 5: goto label5;
case 6: goto label6;
case 7: goto label7;
default: return;
}                                   // task code section
                                       // ========================================= 
label0:               /* a task code -> */ while(1){
pc=1; return; label1: /* a task code -> */   
pc=2; return; label2: /* a task code -> */   
pc=3; return; label3: /* a task code -> */   
pc=4; return; label4: /* a task code -> */   
pc=5; return; label5: /* a task code -> */   printf("Hello from task 1\n");
pc=6; return; label6: /* a task code -> */   msleep(250);  }
pc=7; return; label7: /* a task code -> */   
pc=8; return;                           // ========================================      
}

void task2(void) {
static int pc=0,sleepc=0,ii;
switch (pc){
case 0: goto label0;
case 1: goto label1;
case 2: goto label2;
case 3: goto label3;
case 4: goto label4;
case 5: goto label5;
case 6: goto label6;
case 7: goto label7;
default: return;
}                                   // task code section
                                       // ========================================= 
label0:               /* a task code -> */   for(ii=0;ii<5 font="" ii="">
pc=1; return; label1: /* a task code -> */     printf("<<-- --="" 2="" d="" font="" ii="" n="" task="">
pc=2; return; label2: /* a task code -> */     msleep(1000); };
pc=3; return; label3: /* a task code -> */   
pc=4; return; label4: /* a task code -> */   program_end = 1;
pc=5; return; label5: /* a task code -> */   
pc=6; return; label6: /* a task code -> */   
pc=7; return; label7: /* a task code -> */   
pc=8; return;                           // =========================================        
}

my_kernel(){
  usleep(KERNEL_SLEEP_US); // sleep 100 ms
}

int main(void)
{
  while(!program_end)
  {
  task1();
  task2();
  my_kernel();
  }
    return 0;
}

Tuesday, August 6, 2013

Mini Transistor Audio Amplifier

When I was childhood, I always curious about how electronic circuitry works. I remembered when I wanted to build a transistor audio amplifier, but didn't have any supporting knowledge. Internet hadn't come to my place at that time, not like today. Well, I need some time to build and test all those circuits. Even if I can design a much more complicated circuit than a simple audio amplifier today, but recalling the romance of the past is always exciting. Someday, when knowledge is no longer needed for my work, I will use it for myself fun.

Source:
link1
link2
link3
link4
link5

1. Class AB 4 Transistor Amplifier

2. Class A Headphone amplifier

3. Small audio amplifier circuit diagram


4. Power Amplifier OTL Cassette Radio Booster by TIP41+TIP42

5. Power Amplifier Class A by Transistor


6. Mic/Guitar Compressor with Transistor Bias Control

7. 50 mW 3 Transistors Amplifier




https://www.eleccircuit.com/4-transistor-audio-amplifier-circuit/
https://www.deeptronic.com/electronic-circuit-design/small-audio-power-amplifier-using-3-transistors/
http://www.bowdenshobbycircuits.info/page8.htm