Posts

PHP Type Hinting using Netbeans

Approach 1: Return type declaration: <?php function getUser () : User { //... } $a = getUser(); $a -> // PRESS CTRL-SPACE TO AUTO COMPLETE Approach 2: Using annotation @var <?php function getUser () { //... } /* @var $a User */ $a = getUser(); $a -> // PRESS CTRL-SPACE TO AUTO COMPLETE Approach 3: Using annotation @return <?php /** * @return User */ function getUser () { //... } $a = getUser(); $a -> // PRESS CTRL-SPACE TO AUTO COMPLETE I preferred approach 2 and 3 For PHP 7.1 support, use nightly build of netbeans from here: http://bits.netbeans.org/download/trunk/nightly/latest/

High quality audio on linux

Reference: https://medium.com/@gamunu/enable-high-quality-audio-on-linux-6f16f3fe7e1f # vim ~/.config/pulse/daemon.conf default-sample-format = float32le default-sample-rate = 48000 alternate-sample-rate = 44100 default-sample-channels = 2 default-channel-map = front-left,front-right default-fragments = 2 default-fragment-size-msec = 125 resample-method = soxr-vhq enable-lfe-remixing = no high-priority = yes nice-level = -11 realtime-scheduling = yes realtime-priority = 9 rlimit-rtprio = 9 daemonize = no # pulseaudio -k # pulseaudio -D

DNS over HTTPS using Dingo

UPDATE: It is easier to achive similiar result using systemd Edit /etc/systemd/resolved.conf and change these lines: FallbackDNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844 DNSSEC=yes systemctl daemon-reload and use 8.8.8.8 as your dns in network manager Download binary https://github.com/pforemski/dingo and copy to /usr/local/bin/ Create systemd unit vim /etc/systemd/system [Unit] Description=Dingo Wants=network.target [Service] Type=simple ExecStart=/usr/local/bin/dingo-linux-amd64 -port 53 -gdns:auto StandardOutput=null Restart=on-abort   [Install] WantedBy=multi-user.target systemctl daemon-reload systemctl enable dingo systemctl start dingo Use it in resolv.conf or enter in Network Manager echo nameserver 127.0.0.1 > /etc/resolv.conf

Connect to Fortinet VPN SSL using Linux

To install: dnf install openfortivpn To connect: /bin/openfortivpn --no-dns IP.ADD.RE.SS:443 -u USERNAME --trusted-cert 48239849249248998298492894829482948 Enter password: ****** # trusted-cert parameter value will be print out on first connect

Best theme for Gnome/GTK (Fedora 25)

Image
After trying many themes, my choice is Zukitre with numix-circle icon, and zuki-shell theme To download themes: https://www.gnome-look.org/p/1013758/ To install, just extract to ~/.themes  Icon and font: dnf install google-roboto-fonts dnf install numix* And then choose the theme using Tweak Tool

Suspend then hibernate when battery low

After suspending laptop, it will wake up again when battery drop below 5% (Thinkpad) then it will stay powered on If you set handle lid switch to suspend, it will rapidly resume, suspend which is not good To put laptop hibernate when it wake up, edit /etc/UPower/UPower.conf And set PercentageAction=4 CriticalPowerAction=hibernate And reboot your laptop

Reusable steel coffee filter

So I bought reusable stainless steel coffee filter, the result is very good 👍 It is laser cutted fine filter, shaped like cone. But after a few months using it, water wont flow through filter completely 😭 I found many solutions to fix this on the web, pour with hot water, cleaning with soap, run with hot vinegar, problem still exists Then one suggests to run it with bleach (i use bayclin) and finally the filter back to normal again 😍

Fix ugly java applications font in Linux

Add this to ~/.bashrc: export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=lcd' Select openjdk for default java: alternatives --config java   Selection    Command ----------------------------------------------- *+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b14.fc25.x86_64/jre/bin/java)    2           /usr/java/jdk1.8.0_112/jre/bin/java    3           /usr/java/latest/jre/bin/java Enter to keep the current selection[+], or type selection number: 1 Relogin your session, and launch the java app For netbeans to use openjdk, change launch command to: netbeans --jdkhome /usr/lib/jvm/java-1.8.0

Linux video editor comparing (2017)

So I have try to edit video: Pitivi, Openshot, and Kdenlive using Fedora 25 Pitivi : less feature, but has good potential, integrated to gnome Openshot : lots of feature, but slow, easy to install using Appimage, crashes sometime Kdenlive : many feature, user friendly, easy install using Appimage So my choice is using Kdenlive

My discrete VGA is now fast using 4.10 rc2 kernel (Fedora 25)

I'm using Fedora 25 and Wayland without problem. But my discrete VGA is very slow. My laptop have hybrid graphics , internal is Intel HD 5500 and discrete is AMD R7 M260 00:02.0 VGA compatible controller: Intel Corporation HD Graphics 5500 (rev 09) 05:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Topaz XT [Radeon R7 M260/M265 / M340/M360 / M440/M445] By upgrading kernel to rawhide kernel (4.10.0-0.rc2.git3.2.fc26.x86_64) my discrete VGA run fast now: dnf config-manager --add-repo=http://dl.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/fedora-rawhide-kernel-nodebug.repo  dnf update I'm using Dota2 to benchmark, Resolution: Full HD 1920x1080 , Video Setting preset: #2 from left: Fastest O--X--O--O Best Looking To run application using discrete VGA from terminal: DRI_PRIME=1 steam Or just right click on launcher and choose Launch using Dedicated Graphics Card Previously only 8 fps but now it can render as high as 42 fps 😮😃

Enabling fingerprint auth in Fedora 25

By default only login is using fingerprint auth but not for sudo, to enable: Just run authconfig-tui and check Use fingerprint reader Then enroll your fingerprint using Settings - Users To enroll multiple fingerprint matches, do this from terminal: fprintd-enroll -f FINGERNAME Replace FINGERNAME with: right-little-finger, right-middle-finger, right-thumb, right-index-finger, right-ring-finger You can swipe same finger for all enroll

Hibernate your laptop (Fedora 25)

You can hibernate your laptop for faster boot next time. Hibernate is suspending to disk , so you'll need swap partition. I dont use suspend to RAM because it sucks battery. Follow these steps to make hibernate work using Fedora 25/24: Create swap partition or logical volume (LV) Common size for hibernating: RAM 8 GB  create 12 GB swap RAM 4 GB  create 8 GB swap RAM 2 GB  create 4 GB swap Format swap partition Check new created swap using lsblk -p For example: mkswap /dev/mapper/VG-Swap Add swap to fstab /dev/mapper/VG-Swap            swap            swap    defaults  0  0 Activate and check swapon -a swapon --show     #or swapon -s Recreate initramfs dracut --force Edit grub cmdline dracut --print-cmdline will print recommended GRUB_CMDLINE_LINUX Add resume= and rd.lvm.lv= lines to /etc/default/grub (GRU...

Find previously installed package (Fedora 25)

Using DNF: dnf history you can also undo by ID: dnf history undo 307 If dnf dont show previously installed packages, use RPM: rpm -qa --last

Cool bash prompt and VIM status line using Powerline (Fedora 25)

This guide is based from: https://fedoramagazine.org/add-power-terminal-powerline/ INSTALL PACKAGES $ dnf install powerline vim-powerline BASH Edit ~/.bashrc and /root/.bashrc add these lines: powerline-daemon -q POWERLINE_BASH_CONTINUATION=1 POWERLINE_BASH_SELECT=1 source /usr/share/powerline/bash/powerline.sh VIM Edit ~/.vim/vimrc and /root/.vim/vimrc add these lines: python3 from powerline.vim import setup as powerline_setup python3 powerline_setup() python3 del powerline_setup set laststatus=2 set t_Co=256

Bypass your ISP DNS blocking

Follow this instruction to bypass your ISP DNS blocking  (I'm using Fedora 24) Ikuti langkah di bawah ini untuk menghindari pembatasan situs oleh ISP # Install the package dnf install dnscrypt-proxy # To start manually dnscrypt-proxy -R cisco # To start automatic using systemd vi /etc/systemd/system/dnscrypt-proxy.service [Unit] Description=DNSCrypt client proxy Documentation=man:dnscrypt-proxy(8) After=network.target Before=nss-lookup.target [Install] WantedBy=multi-user.target [Service] Type=forking ExecStart=/sbin/dnscrypt-proxy  -R ovpnse -S -d -u nobody systemctl enable dnscrypt-proxy.service systemctl start dnscrypt-proxy.service # To use it echo 'nameserver 127.0.0.1' > /etc/resolv.conf # or change DNS in network manager ping www.reddit.com # Tips You can download latests resolver from https://raw.githubusercontent.com/jedisct1/dnscrypt-proxy/master/dnscrypt-resolvers.csv and replace this file /usr/share/dnscrypt-proxy/dnscr...

Ports to allow for whatsapp call

These are ports to be opened on your firewall to allow WA video call or voice call: WHATSAPP Call: TCP: 4244,5222,5223,5228,5242 UDP: 3478,45395 Reference: http://kaa.kiev.ua/blog/whatsapp-voice-calls-firewall-ports/ LINE call: TCP: 443 UDP: 2675

Running RaspberryPi using Qemu (Fedora 24)

Mostly taken from here: https://wiki.debian.org/RaspberryPi/qemu-user-static Adopted to run using Fedora 24 Install qemu-user-static: dnf install qemu-user-static Register binfmt: systemctl restart systemd-binfmt Check binfmt interpreter: cat /proc/sys/fs/binfmt_misc/qemu-arm-static will show you: enabled interpreter /usr/bin/qemu-arm flags: offset 0 magic 7f454c4601010100000000000000000002002800 mask ffffffffffffff00fffffffffffffffffeffffff Make symbolic link to match the interpreter path: ln -s /usr/bin/qemu-arm-static /usr/bin/qemu-arm Download raspbian image, and extract it (Skip this if you already have sdcard with raspbian) wget ...... unzip 2016-05-27-raspbian-jessie.zip Setup loopback: losetup -f -P --show 2016-05-27-raspbian-jessie.img Mount image or sdcard: cd ~ mkdir ~/mnt mount /dev/loop0p2 ~/mnt mount /dev/loop0p1 ~/mnt/boot # or for sdcard mount /dev/mmcblk0p2 ~/mnt mount /dev/mmcblk0p1 ~/mnt/boot Copy qemu-arm-static:...

French press coffee

There is no single rule for everyone to get best cup of coffee 😀 I use manual burr grinder to adjust grind size. More coarse grind, more sweetness/flavour but more time to brew https://baristahustle.com/surface-area-and-time/ Best cup for me: Boil water Wait 1 min Pour water a little Stir slowly for 1 min Add rest of the water Wait 5 min Done, filter it (that's totally 7 min) Add little milk & sugar as preferred

Test your server SSL using OpenSSL cli

HTTPS    openssl s_client -connect mail.yourserver.com:443 IMAPS    openssl s_client -connect mail.yourserver.com:993 POP3S    openssl s_client -connect mail.yourserver.com:995 POP3 TLS    openssl s_client -connect mail.yourserver.com:110 -starttls pop3 IMAP TLS    openssl s_client -connect mail.yourserver.com:143 -starttls imap SMTPS    openssl s_client -connect mail.yourserver.com:465 SMTP TLS    openssl s_client -connect mail.yourserver.com:587 -starttls smtp To show expired date of certificate add :        | openssl x509 -noout -dates for example:      openssl s_client -connect mail.yourserver.com:443   | openssl x509 -noout -dates

LVM: Move extents on same disk

I want to move LVM physical extents on the same disk to avoid gap between logical volumes. To visualize physical allocation I use system-config-lvm. Found unused space which size equal to an LV Find out the LV location: lvdisplay -m Show something like this:  --- Segments ---   Logical extents 0 to 20479:     Type                linear     Physical volume     /dev/sda2     Physical extents    116224 to 136703 Or use: pvdisplay -m   --- Physical volume ---   PV Name               /dev/sda2   VG Name               Vol01   PV Size               931.26 GiB / not usable 4.00 MiB   Allocatable         ...