Skip to content

Instantly share code, notes, and snippets.

@Kennyl
Kennyl / suppress.py
Last active February 25, 2017 15:29
Python suppress excerption compatibility workaround
if (sys.version_info > (3, 0)):
from contextlib import suppress
else:
from contextlib import contextmanager
@contextmanager
def suppress(*exceptions):
try:
yield
except exceptions:
pass
@Kennyl
Kennyl / yahooFinanceQuote.php
Created February 26, 2017 06:07
get Finance Quote from Yahoo
<?php
class U_Yahoo{
private function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@Kennyl
Kennyl / calibre-web setup example.sh
Last active March 3, 2017 10:38
Calibre-Web Setup reminder
#!/usr/bin/sh
#install calibre
sudo yum install libg11-mesa-glx
sudo yum install libXcomposite
sudo yum install libGL
sudo pip install QtGui
#MACOS imagemagick 7 not work on any calibre-web
#brew install imagemagick@6 --with-liblqr --with-openjpeg
@Kennyl
Kennyl / docker-compose.yml
Last active January 17, 2018 13:24
Docker-Compose Wordpress Example
wordpress:
image: wordpress
links:
- wordpress_db:mysql
ports:
- 8080:80
volumes:
- ~/wordpress/html:/var/www/html
- /static
- another_static:/static2
@Kennyl
Kennyl / httpd.conf
Created March 6, 2017 14:06
Apache Reverse Proxy Example
#/usr/sbin/setsebool httpd_can_network_connect 1 if cannot localhost
#/usr/sbin/setsebool -P httpd_can_network_connect 1 if cannot localhost
#
<VirtualHost *:80>
ProxyPreserveHost On
ServerName myhostname.com
ProxyPass / http://localhost:808/
ProxyPassReverse / http://localhost:808/
</VirtualHost>
@Kennyl
Kennyl / centos.sh
Last active April 3, 2017 03:39
some SSH usages: forwards X11 ( GUI ), mount folder
sudo vi /etc/ssh/sshd_config
#Set the following two options:
#X11Forwarding yes
#X11UseLocalhost no
sudo /etc/init.d/sshd reload
sudo yum install xauth
#ssh from mac
@Kennyl
Kennyl / mount-ntfs.md
Last active March 10, 2017 15:04
How to mount NTFS on MacOS Serria

Preparation

brew install Caskroom/cask/osxfuse
brew install ntfs-3g

Serria is now rootless, so we need to disable rootless csrutil disable or reboot in recovery mode

@Kennyl
Kennyl / fixSEPermission.sh
Created March 12, 2017 11:03
WordPress SELinux
sudo chcon -R -v -t httpd_sys_content_t www/
sudo chcon -R -v -t httpd_sys_rw_content_t www/wp-content/plugins/ www/wp-content/themes/ www/wp-content/upgrade/ www/wp-content/uploads/
@Kennyl
Kennyl / 行車速度屏.MD
Last active April 19, 2017 10:39
行車速度屏

行車速度屏 - 大埔道沙田段南行近馬場(繁體中文) http://resource.data.one.gov.hk/td/TIS_S1_TC.png

行車速度屏 - 大老山隧道南行近石門(繁體中文) http://resource.data.one.gov.hk/td/TIS_S2_TC.png

行車速度屏 - 吐露港公路南行近科學園(繁體中文) http://resource.data.one.gov.hk/td/TIS_S3_TC.png

@Kennyl
Kennyl / a.js
Last active April 22, 2017 03:24
fontmin reduce
var fs = require("fs");
var Fontmin = require('fontmin');
var content = fs.readFileSync('a.txt', 'utf8');
var fontmin = new Fontmin()
.src('a.ttf')
.use(Fontmin.glyph({
text: content,
hinting: false // keep ttf hint info (fpgm, prep, cvt). default = true