Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / cleangit.sh
Created February 25, 2017 09:03
Clean git like nothing again.
git checkout --orphan tmp
git add .
git commit -m "init"
git push --force --set-upstream origin master
git branch -d master
git branch -m tmp master
@Kennyl
Kennyl / gif2png.py
Created February 21, 2017 15:10
Sample for python Gif to PNG
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw, ImageFont #dynamic import
gif='a.gif'
img = Image.open(gif)
img.save(gif+".png",'png', optimize=True, quality=70)
@Kennyl
Kennyl / gist:eda52972616d19e3b12010e0048f85d3
Created February 21, 2017 14:32
Most Update ebooklib for python3
pip3 install --upgrade git+https://github.com/aerkalov/ebooklib
@Kennyl
Kennyl / emailprotection.js
Last active February 14, 2017 15:30
Simple Email Link Protection as well as Any A href
// use it on mouser over will replace all whitespace when human interacts it
this.href='mailto:'+ (this.innerHTML=this.innerHTML.replace(/ /g,''))
/*<a id="e" href="#" onmouseover="this.href='mailto:'+ (this.innerHTML=this.innerHTML.replace(/ /g,''))">abc @ efg.com</a>*/