Saturday, July 3, 2021

PowerShell not allow to run nodejs install

Following installation of nodejs managed by nvm for windows, I cannot run the node and npm in the Windows PowerShell unless run the PowerShell using administration access.

The solution is found here. https://stackoverflow.com/questions/4037939/powershell-says-execution-of-scripts-is-disabled-on-this-system answered Aug 30 '13 at 13:10 by Ralph Willgoss



For Windows 10, Windows 7, Windows 8, Windows Server 2008 R2 or Windows Server 2012, run the following commands as Administrator:
x86 (32 bit)
Open C:\Windows\SysWOW64\cmd.exe
Run the command powershell Set-ExecutionPolicy RemoteSigned
x64 (64 bit)
Open C:\Windows\system32\cmd.exe
Run the command powershell Set-ExecutionPolicy RemoteSigned


Now, node and npm can be run from the Windows PowerShell as normal user, no need administrator privileges.


NVM for windows installation is from here, https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows


 

Wednesday, June 9, 2021

Ubuntu apt-get not showing package list

 I got annoyimh issue when setting up the new server.The apt-get is not showing pakcage list when we press TAB. This article helps to solve the problem, https://askubuntu.com/questions/86375/apt-get-autocomplete-package-name-is-broken. Below is helping me to solve the problem.


# sudo apt-get install --reinstall bash-completion

Wednesday, February 12, 2020

Docker on Ubuntu 18.04

1. Follow the instruction from here
First, update your existing list of packages:
  • sudo apt update
Next, install a few prerequisite packages which let apt use packages over HTTPS:
  • sudo apt install apt-transport-https ca-certificates curl software-properties-common
Then add the GPG key for the official Docker repository to your system:
  • curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to APT sources:
  • sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Next, update the package database with the Docker packages from the newly added repo:
  • sudo apt update
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
  • apt-cache policy docker-ce
You’ll see output like this, although the version number for Docker may be different:
Output of apt-cache policy docker-ce
docker-ce:
  Installed: (none)
  Candidate: 18.03.1~ce~3-0~ubuntu
  Version table:
     18.03.1~ce~3-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
Notice that docker-ce is not installed, but the candidate for installation is from the Docker repository for Ubuntu 18.04 (bionic).
Finally, install Docker:
  • sudo apt install docker-ce
Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running:
  • sudo systemctl status docker



2. Cannot install docker yii2, follow instructions below:
  1. sudo apt-get remove docker-compose
  2. sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  3. sudo chmod +x /usr/local/bin/docker-compose
  4. sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Saturday, September 1, 2018

Ubuntu WOL not working anymore after apt-get upgrade

I got a problem on my server that it could not be woken up after I did apt-get upgadre and apt-get dist-upgrade to my system.

Quick googling the problem, I found that doing this would solve the problem. The reference was https://help.ubuntu.com/community/WakeOnLan

Enabling WoL in the NIC

Determining whether the NIC supports WoL

First, determine which NIC will be used, and then check whether it supports the Magic Packet™ using
sudo ethtool 
where is the device name of your NIC, e.g. eth0. This command will output some information about your the capabilities of your NIC. If this output contains a line similar to the following:
Supports Wake-on: 
where  contains the letter g, the NIC should support the WoL Magic Packet™ method (for the other letters look at man ethtool).

Enabling WoL in the NIC

To check whether WoL is enabled in the NIC, one could use
sudo ethtool 
and look for
Wake-on: 
If  contains g and not d, then Magic Packet™ is enabled. However, if  does contain d, WoL needs to be enabled by running the following command:
sudo ethtool -s  wol g
On most systems, issuing this command is required after each boot. If the system's networking is configured via ifupdown, then it is easy to add the line up ethtool -s  wol g below the interface's configuration stanza in /etc/network/interfaces. For example:
shahar@shahar-backup:~$ cat /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface

auto lo
iface lo inet loopback
# The primary network interface

auto eth0
iface eth0 inet static
        address 10.0.0.1
        netmask 255.255.255.0
        gateway 10.0.0.138
        up ethtool -s eth0 wol g

This will ensure that WoL is enabled in the NIC on each boot. Fore more information see the interfaces manual.

However, my network setting was done using Network Manager. I did not dare to follow edit of /etc/network/interfaces since I was afraid it would ruin the network setting. Another googling found this, https://apuntesderootblog.wordpress.com/2015/12/02/enable-wake-on-lan-with-networkmanager/

Enable wake-on-lan with NetworkManager

This little tip enables wake-on-lan on our network interfaces so the computer can be awaken with a magic packet from other host in the same network.
First, identify your connection:
# nmcli connection 
NOMBRE      UUID                                  TIPO            DISPOSITIVO 
virbr0      3ee5c0b6-1030-4609-b087-4ab3d39ccdfa  bridge          virbr0      
br-lan      e7b20dc3-9d8e-4b0e-b56f-27a87f17ebe3  bridge          br-lan      
enp5s0      8581aa55-eead-41d6-a216-41f52b4e0c30  802-3-ethernet  enp5s0      
virbr0-nic  04cc0eff-0b0d-4440-9e7b-1c54418e8ef7  generic         virbr0-ni
Then, activate the wake-on-lan functionality:
# nmcli connection modify enp5s0 802-3-ethernet.wake-on-lan magic
Your BIOS has to support and had enabled waking up from your network card.

Thank you so much for both who provide those references. It as useful for me and I hope also for you.

Friday, February 16, 2018

Swiftmailer cannot work after upgrade php to 5.5


I'm using SwiftMailer to send email by SMTP. The library is working fine when running in the server with PHP version 5.4. However, after upgrading the server to PHP version 5.5, email was not sent and the server threw the following error:
Undefined property: Swift_Transport_StreamBuffer::$_sequence
How can I resolve this issue? Thanks.

Simple solution:
In swift-mailer/classes/Swift/ByteStream/AbstractFilterableInputStream.php change
 private $_sequence = 0;
to
 protected $_sequence = 0;
Then the message goes away.
I must use a different version of Swiftmailer than you in the legacy project I got the exact same error notice. My Swift::VERSION is 4.1.1.

Source of solution: https://stackoverflow.com/questions/26020949/swiftmailer-error-undefined-property-swift-transport-streambuffer-sequence

Friday, January 26, 2018

dpkg cannot find ldconfig/start-stop-daemon in the PATH variable


I have this problem in my ubuntu server 11.04,

Preconfiguring packages ...
dpkg: warning: 'ldconfig' not found in PATH or not executable.
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable.
dpkg: error: 2 expected programs not found in PATH or not executable.
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
E: Sub-process /usr/bin/dpkg returned an error code (2)

And I found the solution from  https://ubuntuforums.org/showthread.php?t=1266104, I adjust it to my ubuntu version.

1. sudo apt-get download libc-bin    // download the library
2. sudo dpkg-deb -x libc-bin*.deb libc-bin-unpacked/              // unpack it
3. sudo cp libc-bin-unpacked/sbin/ldconfig* /sbin/    // copy to sbin folder
--- sometimes, you need to remove old one, I did it using sudo rm -rf /sbin/ldconfig*

4. sudo apt-get -f install
5. sudo dpkg-reconfigure libc-bin
6. sudo apt-get install --reinstall libc-bin

One error now is gone. Another one is solved using guide from https://ubuntuforums.org/showthread.php?t=1919127, Below is the guide:

1. Download the dpkg package from http://launchpadlibrarian.net/63806751/dpkg_1.15.8.10ubuntu1_amd64.deb


2. Copy the file into a temporary location:
mkdir ~/dpgk_temp
cp ~/Downloads/dpgk*.deb ~/dpkg_temp
cd ~/dpgk_temp


3. Extract the files from the archive:
ar x dpkg*.deb
tar xfvz data.tar.gz


4. Copy the file to /sbin:
sudo cp ./sbin/start-stop-daemon /sbin


5. Try update the apt information:
sudo apt-get update
sudo apt-get upgrade



Thank you to those who gives us solution, I just put this in here as my reference.


Tuesday, October 26, 2010

Resetting Password on MacOS

One of my friend called me and asked how could he reset the password on his macbook. quick browsing on google, found these interestings:

  • http://support.apple.com/kb/ht1274
  • http://sg.answers.yahoo.com/question/index?qid=20071012020748AAvXTi9

Not testing yet, but should be working since one of it is directly from Apple.

Tuesday, June 9, 2009

ICEfaces Day 1: Installing ICEfaces in NetBeans 6.5.1

The best explanation about ICEfaces can be seen at their website, http://www.icefaces.org/main/home/.

Now, the step to install it on the NetBeans 6.5.1:

1. Run NetBeans 6.5.1.

2. Navigate to the Tool -> Plugins. Go to Available Plugins tab, type "icefaces" on the search box. It is already there. However, they are not the latest version. Go with them if you just want to try ICEfaces. Install them and you are finish. Otherwise, follow the next steps to install the latest version (as for today it is ICEfaces 1.8.1 20090526).

3. Using your favourite browser go to http://www.icefaces.org/main/downloads/os-downloads.iface?category=NetBeans look for the plugin for NetBeans 6.5. Downloand it.

4. After finish downloading the file, extract it somewhere, for example in you Desktop or Download folder.

5. Back to NetBeans window, in Plugins window. Navigate to Downloaded tab. Click on "Add plugins ...". Navigate to where you extract the files and select org-icefaces-netbeans-modules-lib.nbm, org-icefaces-netbeans-modules-visualweb-frameworks.nbm, and org-icefaces-netbeans-modules-web-frameworks.nbm under nbms folder on your extracted folder. Then, click on "Install" button to start the installation.

6. During the installation process, a warning about the signing but not trusted plugin will appear. Just click on "Continue". This warning is appeared because this is not yet verified by NetBeans.

7. After the installation of the plugin is finished. Close the Plugins window. Start a new project and verify that the plugin has been installed by looking whether you can make a new Project, Web -> Web application then on the last wizard page (4. Framework), you can see "ICEfaces" and "Visual Web ICEfaces".


Now, that the ICEfaces is installed on the NetBeans, see you on the next day to "play" with it.

Managing your wealth with Buddy Day 5: Create transaction

The menu is not really clear and on the spot. In my opinion, Buddy is a great application but it is suffered a usability problem. My recommendation is to split the menu for Budget, Account and Transaction, not put all of them under one "Edit" menu. Additionally, the title of the command is not consistent through out the application. To enter new budget or Account we use term "Create" but for transactions, we use "Edit All Transactions". However, the scheduled transactions is a good feature.

To enter a transaction, open the menu under Edit -> Edit All Transaction














Next, the transaction window will appear. Enter the new transaction at the bottom of the window with minimum date, description, amount, from and to values must be filled. Click on "Record" button to save the transaction. "Clear" to reset the form. Edit the transaction by selecting the transaction the click on "Update" button.















There are two kinds of Delete transaction, one is VOID (appear in transactions window but not affecting the balance) and the other one is DELETE (removing completely from the transaction).

It has been 9 days now in operation. My wife and I love it very much. Especially, the encryption feature. Despite the usability problem.

I understand this is not the full review of Buddy since I am preparing new website for all of the tutorials. Until then, goodbye for now.

Wednesday, June 3, 2009

Managing your wealth with Buddi Day 4: Create budgets

The other thing also important in managing your wealth is setting your budget, your spending limit. It used to be easy since there is no credit card, or it would be easy for people not using credit card since the limit is the money available in your hand. However, it is also no good. We need to set the budget for our expenses, so that we do not waste our money on something useless. In some cases, unpredictable emergency expenses also need to be allocated. Finally, they are depending on yourself as the manager to manage the budget. In Buddy you can create budget as follow:

1. Run Buddy, navigate to "Budget" tab and click on Edit -> Create Budget
2. You can create category of your budget here. In addition, you also can create subcategory of a category, see the sample below:



























3. Finally your budget summary is below:















That's it for today.

Managing your wealth with Buddi Day 3: Create account

After finish with setting the environment, we should make some accounts first. This accounts are important so that we can withdraw the money from.

1. Run Buddy.
2. Click on Edit -> Create Account. new window will appear.
3. Make an account of type Cash, for example name it as wallet.















4. Also input other type of accounts you have, such as Investment or Savings.















5. Finally, you will have all of your accounts in Buddy as below.
















Next day, we will see how to create budgets.

Tuesday, June 2, 2009

Managing your wealth with Buddi Day 2: Setup the environment

Printing out my account books is taking time. Beforehand, I also want to setup the environment. The setting would involves date and currency format. Navigate to Edit -> Preference -> Locale:

1. Setting date: I choose to use "dd MMMM yyyy", you can create anything you want with the combination of d, M and y.















2. Setting currency: I put "Rp" here. [See suggestion below]















3. Final setting.















Suggestions:
I would ask a feature which is a capability to enter other currency including the exchange rate since some people have some accounts in different currency.


That's all for today.

Sunday, May 31, 2009

Managing your wealth with Buddi Day 1: Installation day

Have you ever notice how much have you been spent monthly on shopping? or how much have you been spent on food? If not, then you need buddi. I read the review of buddi on Info Linux (Indonesian open source magazine). I think I will try this to see my spending. I used to be using Excel. It was good but I was too lazy to update it. Anyway, let's try it:

1. Download buddi from its website. It is available for Windows, MacOS and Linux. The main reason why I want to try this is that buddi is developed using Java. I choose to try this on Windows 7 RC, so I download the Windows version.

2. After finished download it, run the installer. It is very easy, just run it and accept all default values.

3. Buddi is now already installed on my Windows 7 machine. Run Buddi, you will be welcomed with "Make a donation" page, simply click on "Not now" (please make a donation if you think it is helping you. Disclaimer: I am not having any kind of relationship with this product or the eprson behind it. Just think that it would be nice to encourage the developer in maintaning and further developing this product).

That is for now, today I will check all of my bank accounts so I can input my "wealth".

Saturday, May 30, 2009

Symfony of Love Day 2: Business Case

On the day 1, I already defined the simple requirements for my new project. Now, going further to define the business case. I made an observation on how my wife running the business. Below are the scenario,

1. Items are coming from the supplier.

a. When items are coming from supplier, their information should be recorded into the system. The important information are Item name, description, weight, photo (yes, it would be nice to have the picture of it), purchase price, quantity, minimum stock level for re-ordered and also the storage location if already decided. Otherwise, a default location would be supplier by the system.

b.When the item is not yet in the system, there should be a new window displayed to record the information of the new item.

c. After all items have been recorded, a summary page is displayed listing all items received from a supplier, then supplier information is also entered including the shipping cost.

d. Next step is to determine the sale price. The items are displayed in a table contains information about purchase price, shipping cost, suggested sale price (5% profit, 10%profit, 15% profit, 20% profit, 25% profit, 30% profit, 40% profit and 50% profit). The last column would be final sale price.

e. After sale prices are determined. The process is finished and back to main menu.


2. Customer makes a purchase.

a. When customer makes a purchase, a window displayed to provide the operator to record the items to be delivered to the customer. The information needed is item id/name, quantity and delivery date, due payment date, the customer information and also the payment method.

b. After all information required are recorded, operator should be able to print out the invoice. Two invoices are generated. One with the "Copy" watermark and the other one is "Paid" watermark.


3. Management.

a. CRUD of items (stock management), customers and payment method.


I know, probably this is what I would not do in the real business case. However, I am short of time at the moment ;( so that's all for today.

Thursday, May 28, 2009

Symfony of Love Day 1: Introduction

Why I called this project as Symfony of love? There are two reasons, first and the most important one is because I dedicated this project to my wife and second, I hope I can learn Symfony.


Background:

It has been few years that my wife is running her business from home. She sometimes asks for a software to help her in managing her business to replace her old excel system. I called it an excel system, since it is actually a system that is utilizing excel. Not the excel is the core of the system, but how she defined the procedures and utilized the sheets to do the calculation are the core of the system. Remember, excel is only the tool. One day, when we do not have access to excel, she can open and run it in OpenOffice Calc (good to hear!).


Objective:

Create a system to help small business in managing stock, price and orders. I know there are many and probably better solution for her (and others) but making one for your special one is very special!!!


Requirements:

I make it as simple as possible for the version 0.1:

R1. The system shall be able to be used to manage the stock of a product including its location. A notification will be issued when an item has reached a certain level thus need to be reordered.

R2. The system shall be able to be used to manage orders from clients including the their payment information.

R3. The system shall be able to be used to help in calculating the selling price.


I know they are still very broad requirements and i will make them more detail and clear in the business case on the next day.

Secure VPS Day 2: IPTables

I got a problem. Unfortunately, IPTables are not included in the Ubuntu kernel on the vps I used. Activate it would take some time, so I decided to reinstall my vps and use Debian 4 image instead. The steps for day 1 are the same as in ubuntu, only that sudo package is not installed by default. Install it by running:

debian:~# apt-get sudo


Now, check the iptables configuration:

cath@debian:~$ sudo iptables -L

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

Password:
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
cath@debian:~$


Save old configuration (if any, usually the rules is still empty):

cath@debian:~$ sudo iptables-save > /etc/iptables.up.rules


Create new rules:

cath@debian:~$ sudo vim /etc/iptables.test.rules

*filter

# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT

# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allows all outbound traffic
-A OUTPUT -j ACCEPT

# Allows HTTP and HTTPS connections from anywhere (the normal ports for websites)
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT

# Allows SSH connections
#
# THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE
#
-A INPUT -p tcp --dport 2987 -j ACCEPT

# Reject ping
-A INPUT -p icmp -m icmp --icmp-type 8 -j REJECT

# log iptables denied calls
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

# Reject all other inbound - default deny unless explicitly allowed policy
-A INPUT -j REJECT
-A FORWARD -j REJECT

COMMIT


Use above rules in iptables:

cath@debian:~$ sudo iptables-restore < /etc/iptables.test.rules


Check it to see the differences:

cath@debian:~$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT 0 -- anywhere anywhere
REJECT 0 -- anywhere loopback/8 reject-with icmp-prt-unreachable
ACCEPT 0 -- anywhere anywhere state RELATED,ESTALISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:www
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:2987
REJECT icmp -- anywhere anywhere icmp echo-request eject-with icmp-port-unreachable
LOG 0 -- anywhere anywhere limit: avg 5/min brst 5 LOG level debug prefix `iptables denied: '
REJECT 0 -- anywhere anywhere reject-with icmp-prt-unreachable

Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT 0 -- anywhere anywhere reject-with icmp-prt-unreachable

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT 0 -- anywhere anywhere
cath@debian:~$
cath@debian:~$
cath@debian:~$ cath@debian:~$ sudo vim /etc/iptables.test.rules
-su: cath@debian:~$: command not found
cath@debian:~$


Finally, test it:

Pinging ppa16.vpsfarm.com [209.9.227.210] with 32 bytes of data:
Reply from 209.9.227.210: Destination port unreachable.
Reply from 209.9.227.210: Destination port unreachable.
Reply from 209.9.227.210: Destination port unreachable.
Reply from 209.9.227.210: Destination port unreachable.

Ping statistics for 209.9.227.210:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),


There it is for day 2. I am searching again for other tips and tricks to secure our vps. Till then, good bye for now!