Skip to content

Instantly share code, notes, and snippets.

View thephucit's full-sized avatar

Thế Phúc thephucit

View GitHub Profile
@thephucit
thephucit / Plugin.php
Created April 28, 2020 08:08 — forked from khoatran/Plugin.php
Customize OctoberCMS sidebar navigation for your plugin
<?php namespace Author\PluginName;
use System\Classes\PluginBase;
use Backend\Facades\BackendMenu;
class Plugin extends PluginBase
{
public function register() {
BackendMenu::registerContextSidenavPartial('Author.PluginName',
'sidebar-menu',
@thephucit
thephucit / odoo.sh
Last active April 15, 2020 10:09
Install odoo on ubuntu server
Lưu ý: Odoo chỉ kết nối với PostgreSQL, nên phải cài đặt PostgreSQL trước.
Bước 1: Cài các chương trình cần thiết theo dòng lệnh bên dưới
> sudo apt install git python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less
# nếu python 2 thì chạy lệnh dưới
> sudo apt-get install python-dateutil python-docutils python-feedparser python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi poppler-utils python-pip python-pypdf python-passlib python-decorator gcc python-dev mc bzr python-setuptools python-markupsafe python-reportlab-accel python-zsi python-yaml python-argparse python-openssl python-egenix-mxdatetime python-usb python-serial lptools
Run this
"sudo -u postgres psql"
in your terminal to get into postgres
postgres=#
Run "CREATE USER new_username;"
Note: Replace new_username with the user you want to create,
@thephucit
thephucit / bash.sh
Created April 12, 2020 04:59
Switch between PHP versions on Ubuntu Nginx
sudo update-alternatives --config php
sudo service nginx restart
sudo service php7.2-fpm restart
@thephucit
thephucit / admin.sql
Created March 2, 2020 10:59 — forked from Hikingyo/admin.sql
create admin user with all privileges on mysql/mariadb
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
## remote connection - not secure
CREATE USER 'admin'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
# export postgres db
pg_dump -p [post] -U [username] -h [host] -d [db_name] > dbexport.pgsql
# import postgres db
psql -p [post] -U [username] -h localhost [dbname] < dbexport.pgsql
@thephucit
thephucit / index.php
Created February 4, 2020 10:15
Convert datetime in db into local datetime
<?php
/**
* Convert datetime in db into local datetime
* @param string $datetime
* @param string $format
* @param string $timezone
* @return String
*/
public static function convert_datetime_to_local($datetime, $format = 'H:i d-m-Y', $timezone = 'Asia/Ho_Chi_Minh')
{
@thephucit
thephucit / chimmoi.conf
Last active September 28, 2020 12:49
Octobercms NginX
server {
listen 80;
server_name .example.co.uk.dev;
access_log /usr/local/var/log/nginx/example.co.uk-access.log;
error_log /usr/local/var/log/nginx/example.co.uk-error.log error;
root /var/www/example.co.uk/public;
index index.php index.html;
@thephucit
thephucit / index.php
Created January 7, 2020 03:14
Generate QR code with custom logo
<?php
/**
* QR Code + Logo Generator
*
* http://labs.nticompassinc.com
*/
$data = isset($_GET['data']) ? $_GET['data'] : 'https://tunlookup.com/';
$size = isset($_GET['size']) ? $_GET['size'] : '200x200';
$logo = isset($_GET['logo']) ? $_GET['logo'] : FALSE;
header('Content-type: image/png');
@thephucit
thephucit / QRLogo.php
Created January 7, 2020 03:13 — forked from NTICompass/QRLogo.php
QR Code + Logo Generator
<?php
/**
* QR Code + Logo Generator
*
* http://labs.nticompassinc.com
*/
$data = isset($_GET['data']) ? $_GET['data'] : 'http://labs.nticompassinc.com';
$size = isset($_GET['size']) ? $_GET['size'] : '200x200';
$logo = isset($_GET['logo']) ? $_GET['logo'] : FALSE;