Thursday, March 2, 2017

Ubuntu Cannot Enable WiFi

sudo modprobe -r acer_wmi

Source:
askubuntu.com 

Thursday, February 23, 2017

Update grub on a dual boot machine

sudo nano /etc/default/grub 
 
sudo update-grub
 
 
 
 
source  

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;
}