Skip to content

Instantly share code, notes, and snippets.

View thephucit's full-sized avatar

Thế Phúc thephucit

View GitHub Profile
@thephucit
thephucit / script.sql
Created August 31, 2019 11:09
update root pass
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new pass';
@thephucit
thephucit / gist:c1d680be87a538fd3caabfb10a657a89
Created September 12, 2019 03:53
setup permission octobercms on nginx
sudo mkdir storage/framework/cache &&
sudo mkdir storage/cms/combiner &&
sudo mkdir storage/cms/cache &&
sudo mkdir storage/cms/twig &&
sudo mkdir storage/framework/sessions &&
sudo mkdir storage/cms/cache &&
sudo mkdir storage/framework/views
sudo chmod -R 775 artisan &&
@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;
@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 / 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 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')
{
# 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 / admin.sql
Created March 2, 2020 10:59
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;
@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
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,