Tuesday, February 28, 2017

เปลี่ยน bluetooth codec บน macOS ให้ใช้ aptX

1. วิธีดู codec ปัจจุบัน ให้กด Option ค้างแล้วกด Bluetooth icon บนเมนูบาร์ แล้วเลื่อนไปที่ device ที่ต้องการเพื่อดู codec ปัจจุบัน (จะเห็นว่าเป็น SBC, aptX, etc..)
2. ถ้าไม่ใช่ aptX แต่อุปกรณ์ Bluetooth ที่ connect อยู่ support aptX ให้ download Bluetooth Explorer ไปที่ Tools/Audio Settings แล้ว Force aptX
3. Disconnect และ Connect Device ใหม่

ขอบคุณที่มา
http://www.theghostbit.com/2015/03/force-mac-os-x-to-use-aptx-with-your.html

Wednesday, December 28, 2016

Quick Apache Setup - Change localhost path on macSierra for Test Only

To quickly change the localhost path from default (/Library/WebServer/Documents) to your path and bypass all the permission problems

  • edit DocumentRoot in /private/etc/apache2/httpd.conf and set it to your path, both "DocumentRoot" and "Directory"
  • add the following lines
Options Indexes FollowSymLinks Multiviews
AllowOverride All

  • change User from _www to



This is for single machine and for test only as it will not be highly secure but it's a quick way for not having to do all the permission change on your test web directory.

Saturday, December 24, 2016

Turn off ipv6 on mac Sierra

Off setting was removed from the network settings for ipv6. To turn it off, need to use terminal command networksetup

1. list hardware port
networksetup -listallhardwareports

2. turn off the port you want
networksetup -setv6off Ethernet (Ethernet is the name of the port to want to turn if off)

3. turn it back to default
networksetup -setv6automatic

Tuesday, July 26, 2016

Update Wordpress Plugins - Could not create directory issue

Put this in wp-config.php

define('FS_METHOD','direct');

and change wp-content folder to 777 temporarily, update and change it back

Wednesday, June 15, 2016

Clone SD Card Image (Mac)

I've started using Raspberry Pie. Backing up the SD Card image and restore is a quick way to test things out.

First check which disk the SD card is using

diskutil list




















then copy raw format of the card to image file while at the same time compress it to save some space

sudo dd if=/dev/rdisk2 bs=1m | gzip > ~/Desktop/pi.gz

To restore image to SD, first unmount the card by

diskutil unmountDisk /dev/disk2

then 

gzip -dc ~/Desktop/pi.gz | sudo dd of=/dev/rdisk2 bs=1m


this could take a while

(to eject disk)
diskutil eject /dev/disk2

Friday, May 13, 2016

Quick firewall setting for Ubuntu/Wordpress

To show current firewall rules, use
iptables -L
If it's empty, below are the steps to quickly add firewall rules, assuming you want to run a simple wordpress site (only allow loopback, ssh, http, https and drop the rest).
sudo iptables -I INPUT 1 -i lo -j ACCEPT
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo iptables -A INPUT -j DROP
Then save it to file to apply at reboot:
sudo sh -c "iptables-save > /etc/iptables.rules"
Create a script /etc/network/if-pre-up.d/iptablesload with content below:
#!/bin/sh
iptables-restore < /etc/iptables.rules
exit 0
and a script /etc/network/if-post-down.d/iptablessave with content below:
#!/bin/sh
iptables-save -c > /etc/iptables.rules
if [ -f /etc/iptables.downrules ]; then
       iptables-restore < /etc/iptables.downrules
fi
exit 0
Don't forget to 
sudo chmod +x /etc/network/if-post-down.d/iptablessave
sudo chmod +x /etc/network/if-pre-up.d/iptablesload
****note if you want to allow ftp then add these to iptables rules
sudo iptables -I INPUT -p tcp --dport 21 -j ACCEPT
sudo iptables -I OUTPUT -p tcp --sport 20 -j ACCEPT

and you have to change pam_service_name=vsftpd to pam_service_name=ftp near the end of your /etc/vsftpd.conf file

Wednesday, April 27, 2016

Increase Swap size - digitalocean droplet

Set the swap size to 512M and after a while mysql failed to start. Tail the /var/log/mysql/error.log and found that innodb had memory-related error. For now I solved it by increasing the swapfile size.

1. Cannot swapoff since there was not enough memory
2. So I create new swapfile first and use it and then delete the old one and edit the /etc/fstab file

sudo fallocate -l 4G /swapfilenew
sudo mkswap /swapfilenew
sudo swapon /swapfilenew
sudo swapoff /swapfile # < delete old swap
sudo rm /swapfile
sudo swapon -s # check to make sure


Edit /etc/fstab to turn on swap when reboot. Change from /swapfile to /swapfilenew