Skip to main content

Posts

Showing posts from 2020

Setup a digital download site on WordPress

 This sample site was built on Azure VM, ubunti 18.04 Here're steps for setup: Update Ubuntu packages  Install Apache Check disk space Start/ Reload/ Stop service on Azure Ubuntu Install MySQL Install PHP and WordPress Setup SSL Check Apache Role Setup FTP on Azure VM Update Ubuntu packages before installation  Ref: https://tecadmin.net/upgrading-ubuntu-packages-command-line/ sudo update; sudo upgrade  Install Apache  Ref: https://ubuntu.com/tutorials/install-and-configure-apache#1-overview sudo apt install apache2 When installation complete,  Root path of the website: /var/www/html/ Apache config folder: /etc/apache2/ On tutorial, it shows you how to create a virtual host. (We could see command a2ensite (to apply new config file) when setting up a WordPress Site.) I have blog sites hosted on blogspot.com which provide domain name reassignment. I setup their domain names on Google Domains (https://domains.google.com/), and use redirection on .access file.  Access control : /var/www

Tomcat port and Apache redirection

This update briefly describes the installation of Tomcat and Apache.    Install and set up Tomcat   Reference:  Digital Ocean https://www.digitalocean.com/community/tutorials/install-tomcat-9-ubuntu-1804 Highly suggest moving to reference when install. It provides detailed description.      Install Java    Create Tomcat user on Linux sudo groupadd tomcat sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat     Download Tomcat  Tomcat download https://tomcat.apache.org/whichversion.html (I’m using Tomcat 9) wget -url-get-from-download-page-in-tar-gz- sudo mkdir /opt/tomcat sudo tar xzvf apache-tomcat-*tar.gz -C /opt/tomcat --strip-components=1   Update Permission cd /opt/tomcat sudo chmod -R g+r conf sudo chmod g+x conf sudo chown -R tomcat webapps/ work/ temp/ logs/   Create systemd service file (Ubuntu service) sudo update-java-alternatives -l It shows Java Home sudo vi /etc/systemd/system/tomcat.service Edit Environment=JAVA_HOME sudo systemctl daemon-reload sudo systemctl star

[update]Add web service

    Added REST API on Unity game, and created a Spring server to collect data and present it on a simple web page.          This version of web service is not on Azure yet. I was also testing JUnit and MSTest. Finally I complied to install IDE for Spring.... I have a very small hard disk, and already have Android Studio, Anaconda3 for Python, Visual Studio community, VS code, Unity, MySQL, OBS, Inkscape, Medi Bang Paint, Gimp, etc. Just unwilling to add another editor. I'm also supposed to install Decker....      Anyway, I installed Eclipse with STS support. And found it was difficult to test Unity functions related to position mappings, and nothing related to server needed testing. I tested time conversion and it would be much faster to create a main[]. The function I like in Duration is on Oracle Java 9..... not the public version, which Maven/Spring/Linux server uses, Java 8. Math makes things simple. I'm just lazy... 

[Update] Add UI to end a game

    I found without a proper UI, sectional conclusion would never be possible. It might be something like endless life. Vampires live forever and inevitably lose the sense of meaning. Similar stories were also depicted in Japanese comics. Some monsters do harm to others because of boring.       UI animation and Start/End game control were added in this version.     Also borrowed some pictures to match presentation with intention. "A reader with a cup of mike tea" hardly can relate to "a worker on station", although I like reading with coffee or milk tea aside. 

Unity simulation shell

    Simulation shell built from Unity. Players can plan how many stations(milk tea) wanted and the number of workers(reader). When a worker is attached to a station, the sales increase and also the pressure. When detached the worker from the station, the pressure decreases.       Now is only the shell. Game logic is illogical. But the following steps are game recording at server-side and simple report. Better game logic also depends on accumulated effect. Then return back to game design. Project development is a looping circle. Further development needs other parts and accumulation of usage. Actually, the original idea of this simulation game is for training. Games explain experience sometimes better than lecture or communication. But the investment costs more, of course.       Here are some notes deserve recording.  point tracking  UI elements depends on event queue. Game content depends more on overall scanning. Event object will automatically generated when deploy event actions (i.

Unity (mouse & clone)

Squeezed out some time to move forward a little.  No. I'm not creating a game, but a simulator, trying to solve currently encountered problem.  How could you tell someone the time management is harmful, if the culture of environment is "the superior knows the all"? I knew this is far-fetched. And hopefully I soon need not to worry about it, but giving this out as a gift.  Useful function: public void OnMouseUp()     {         if (!bMouseDown) return;         //keep it simple. just return if irrelevant         bMouseDown = false;         if (id != 0)         {             origin = transform.position;             return;         }         //if the genuin, make clone.          Vector3 pos = Input.mousePosition;         pos = Camera.main.ScreenToWorldPoint(pos);         pos.z = origin.z;         if (pos.x > Boundary.x || pos.y < Boundary.y)         {             stationact newob = Instantiate(this);             newob.id = ++idMax;             newob.transform.position

Unity 2D game connects to Bookmk REST

Yeah~~~!! I collect the last piece of my puzzle!!  I used to say I like C and Java, but just don't know what to do with it. Python is my new collection, I'm looking for good data to try its scientific libraries. For Java, I got Spring server. Finally I got C on Unity! Games got talent on dumping garbage (just kidding). It's a great playground! 

Bookmark service (MongoDB & Spring REST) -2/2

    I accidentally deleted my development VM. I got lucky having the habit of taking notes. This blog is useful. Development VM is doom to be lost. Rebuild it waste time, but having a clean slate is refreshing~. What concerns me more is my AWS free quota this month is reaching 85%. The second VM I launched but never being used might be the one to blame. (Of course, my mistake.) I terminated the wrong VM. Now I got Linux 2 built. Great, just threw away everything happened on AMI.  1st layer: Page Page class   Originally, I need to prepare getter/setter for all class properties for Spring. By using lombok, I only need to create constructors. lombok will deal with getter/setter and toString(). But there are chances to call getter/setter, but how? .......Naming convention.... Capitalize the 1st character with the prefix get/set.  Annotation @Data was used on this class.  Repository class Spring Docs: Repository https://docs.spring.io/spring-data/mongodb/docs/3.0.0.RELEASE/reference/html/#m

I accidentally deleted my Development VM

source  http://www.dbbqb.com/detail/122531.html

Bookmark service (MongoDB & Spring REST)

Completed a working version of Bookmark service. Feeling great~~ ha! ha! Finding something to practice is an efficient way of learning. The project concept is redesigned from a MongoDB project. Weeks ago, I was learning MongoDB and NodeJS. Mixing everything together is my hobby. There might be conflictions, but putting all strengths together has higher potential to resolve difficult and complex problems. Elites getting together might sometimes not be easy, I mean technology, of course. Nice things deserve practice.  Building your first application with MongoDB: Creating a REST API using the MEAN Stack https://www.mongodb.com/blog/post/building-your-first-application-mongodb-creating-rest-api-using-mean-stack-part-1   After redesign…… is ….extremely simple…. But contains enough new topics for me to explore. I’m just a starter of Spring (and a veteran of OO and Cloud programming). Keep everything simple and fast.    I applied to cloud services (like AWS), online artist supporting platfor

Spring simple and MongoDB (Finally)

    Finally~~~ I could start a Spring project ~~~~ 3 days ago.        Following the user's guide is simple. ...... and then difficult. Not to go astray is a difficult task for my curiosity.... My second day fell in the trap of using an external DB and then found my development server was not whitelisted. The third day fell into mysterious naming convention..... Why is it not noted on User's Guide?        In case Spring 2.3.0 covers up everything (just kidding) or I forget everything while moving on, I keep a note here.    Building an Application with Spring Boot https://spring.io/guides/gs/spring-boot/ This “quick start” was not well designed, but provides a more comprehend snapshot of Spring Boot full stack development. Only when I encountered various issues then I found this is a saviour.    Accessing MongoDB Data with REST https://spring.io/guides/gs/accessing-mongodb-data-rest/     No property found for type… custom Spring Data repository https://stackoverflow.com/questions

File upload Servlet/JSP

I want to start my first Spring project, and found I can not skip its initializr. (Of course not!) I'm too lazy to open ftp port. Therefore I created a file-upload page to receive initializr I downloaded. (I may have a different definition of time....)    I usually don’t use IDE while experimenting/learning on my PC. So I made a video showing how I complete my work. It’s very much like looking up dictionaries. When hired by companies, they usually provide great IDE. Or some definitely need specialized IDE, i.e. developing Wii or 3DS.    I created two versions in this video. One referred to Oracle’s example, the other referred to Apache’s explanation. It seems since Servlet 3.0, the maintenance switched to Apache. And the library,  Apache Common FileUpload is very much simplified, compared to the previous sample.    BootStrap  Here I used BootStrap contempt to design the form. It is a mobile-first design. Roughly speaking…. I’d say it designs the screen by percentage; Bootstrap also

Setup Maven and two basic projects

    The interesting implementation of Java I proceed to is Spring. And, only getting Java running is not enough. I also need to set up Maven. This name is new to me, and I found many Spring tutorials just skip this part. At least I need Maven to generate templates for me. I should learn it more. ( I knew there is a great tool -- Eclipse -- can make tedious things disappear. I’m taking a strategy to install all experiments I want to try and throw away when it's full. And that's an external VM, not my PC. I, not yet, want to do research about installing Eclipse on AMI. )    Upgrade to Java 8     First is to upgrade Java on AMI to Java8. AWS provides advanced tools for Linux 2. And DIY for Linux2. At least there are solutions for my choice.  Amazon Corretto 8 Installation Instructions for Amazon Linux 2 https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/amazon-linux-install.html Here are commands I used: >wget */amazon-corretto-8-x64-linux-jdk.deb >wget */amazon-corre

Linux socket in C and Java

    Finally, I found good reason to practice on Java. First, start with Linux network socket.      I'm using Windows OS, so I setup AWS EC2:AMI to be the developing VM. Installing development tools is required: For C:  sudo yum groupinstall "Development Tools" For Java: sudo yum install java-devel     I worked on Linux socket in my early IT career path. I love cloud computing and admire its greatness. Does it mean I adore technology more than humanity? No. Both are fair. How about thinking in this way:  Technology paves the way to listen to everyone who has access to it. No matter you're rich or poor, old or young, brilliant or stupid.      IT doesn't make decisions; the people behind IT do. If the administrator decides to silence/filler out  certain information or opinions, it’s nothing different from you sending inquiry to the court, petitions to the government, complaints to customer services, even the advice to your parents/children. But to developers, we need

Notes on learning WordPress

    Finally I finished study the book : WordPress Theme Development with Bootstrap: The Beginner’s Guide to Building Your Own Mobile-First Theme from Scratch     It is practical.      Here are some notes I’d like to share during study: I was using IIS+PHP. Windows Active Directory is sophisticated. Make sure WordPress was granted to use its own folder. “Application pool” authentication is effective. By default is IUSR. I couldn’t see uploaded-pictures’ thumbnails, even when I granted “Everyone/ full control” on a specific picture. Then I removed inherited-hierarchy, and lost the right to delete it, even with admin rights.   PHP module gd2 After correcting authentication, the functionality “Edit Image” on WordPress still didn’t work. I validated minimum required modules while installing PHP. Maybe most developers validated the gd2 (JPEG related) module. It took me quite a long to find out my server needs gd2.   wp_enqueue_script Developers use wp_enqueue_script() to ask WordPress to loa

Built LAMP on AWS AMI, and update/install Python3.6, pip v20, Apache wsgi and Flask

I got one half day free and I spent it on building a LAMP on AWS AMI. I also wanted to squeeze Flask into Apache. So I also install/update Python 3.6, pip V.20.1, Apache wsgi and Flask. I wrapped up progress for now before I forgot all resources.    On AWS marketplace, everyone can pay for a good suit such as Django. I’m not interested in content creation unless there are interesting topics to resolve. I don’t know what left to do if I bought a solution; and I may get annoyed like everyone else if the solution causes more problems. To build on my own is more realistic and practical. Installing a LAMP (Linux, Apache, MySQL, PHP) was smooth while following AWS tutorial. Tutorial: Install a LAMP Web Server with the Amazon Linux AMI https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html To build Flask is absolutely a different thing….  still failed before I fell asleep... If I choose AWS EC2 Ubuntu instance, most tutorials are based on this Linux version. Unfortunately I oft

Laravel & PHP7 minor test

    Got some time testing on Laravel and PHP7's new feature. Usually, learning basic language is straightforward. Redesigning the sample and studying the difference gain good understanding.     Due to my short time, PHP7 test paused before the anonymous class definition. Not because of technical reasons... I didn't really agree with the sample that defines an anonymous class under the blueprint of a template(interface).... Usually a template exists because different classes may implement it in different ways. When debugging, a developer needs to trace how a class is defined and used. A better developing habit is to put class definitions somewhere easy to identify. According to this example, an anonymous class hid behind an interface... would cause many troubles such as some classes defining the interface in wild or absolutely opposite ways. https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.anonymous-classes     Fortunately I got another time

Comments for my Server/Client Web API samples

        Finally, I finished the comments for python/07 and 09 projects. I almost forgot to put the date on source code which is used to note how long it took me. Not precisely in hours….. I didn’t include source code in my previous post. If choosing code-section for this post…… maybe I want to mark out my comment….. (Really?!)          Once my work was developing websites for enterprises, including ERP, CRM or content sites. The sustainability of network and security are important issues. There are 2 methods for HTML Form submission: GET and POST. Submit via POST is secure, compared to GET which piles parameters on URL. RESTful API is mainly using GET.         Yup, even if you have a certification key, if you put the value on the URL, it is visible data. When writing socket-communication, client-server sockets are a pair; both follow the agreement on commands and structures; and there are countless ports for usage. Plain text on the message of socket communication usually wouldn’t be

Sample for client RESTful API, pandas, tqdm, argparse

    Here is a good example for practicing:     DataQuest:  Tutorial: Getting Music Data with the Last.fm API using Python     Why I didn't mention it as "good tutorial" because I encounter several obstacles while working on this example (then it became a project..) Probably  related tools' reversion is the main issue. IT is a fast changing world. Many tutorials I found online are already invalid.  the author was using both programming and terminal. I was mainly on programming because data processing/conversion in advance; Skipping complex  work, ex. temporary storage.      At beginning I expected to complete this exercise in one file. But at the end, to deal with multiple obstacles, It grew to mobilized functions (options/database/REST loading/parsing) , many steps ( at least 7, not including removed tests) and many tests.....      In order to deal with multiple REST querying and its agreement of usage,  I employed SQLite3. At first, I was using saving-files to keep r

Started on RESTful API + Flask + Python

Started experimenting on RESTful API. Actually, I always doubt the necessity of the name 'RESTful API' or microservice... There're already web pages for years. Yes, you read it right, 'WEB PAGE'. If any programmer ever worked on assembling web pages: filling queried results into blank area, and then sending out the whole content, REST API on server side seems to be sending data without decoration....  I didn't mean that modern technique is simple. Decode the structure designed by others is a kind of art. I do respect all designers. I just think passing data between devices is not something new.... Maybe, it's because I wrote network sockets in very early days.... It's kind of difficult for me to choose section of codes that represents REST API... This is an example of server-side web API.  So I chose filter for queried data.. sqlight3 allowed developer to register a processing function to deal with our own data. This technique is not uncommon. Often