Skip to content

Instantly share code, notes, and snippets.

View soiqualang's full-sized avatar
🙃
hihihaha

Đỗ Thành Long soiqualang

🙃
hihihaha
View GitHub Profile
@soiqualang
soiqualang / delete_files.php
Last active August 24, 2017 07:15
delete all function
//ham xoa tat tan tat
function delete_files($target) {
if(is_dir($target)){
$files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned
foreach( $files as $file )
{
delete_files( $file );
}
@soiqualang
soiqualang / services_ajax.php
Created August 25, 2017 03:58
Service để Ajax gọi tới get data
//get URL cua file hien tai;
$baseUrl = $_SERVER['PHP_SELF'];
//kiem tra thong tin request den
if (isset($_POST['getMember']) && $_POST['getMember'] == 'view')
{
//wating 1s truoc khi thuc thi
sleep(1);
//tao mang member
@soiqualang
soiqualang / client_ajax.js
Created August 25, 2017 03:59
Hàm gọi Ajax phía client
$(document).ready(function(){
// Gắn sự kiện onclick vào #viewbtn
$('#viewbtn').click(function() {
$('#loading').html('Loading...');
var strURL = $('#base_url').val();
$.ajax({
url: strURL,
type: 'POST',
cache: false,
data: 'getMember=view',
@soiqualang
soiqualang / ogr2ogr.sh
Created January 11, 2019 08:03 — forked from zackad/ogr2ogr.sh
ogr2ogr cheatsheet
# export mysql database into shapefile
ogr2ogr out_shapes MYSQL:gis,user=root,password=password
# import shapefile into mysql
ogr2ogr -f MySQL MySQL:database_name,user=root,password=password my_shapefile.shp -nln table_name -a_srs EPSG:4326 -update -overwrite -lco engine=MYISAM
# reproject spatial reference from WGS 84 UTM 48S to Geographic Lattitide/Longitude Coordinate System
ogr2ogr -f "ESRI Shapefile" target_file.shp source_file.shp -s_srs EPSG:32748 -t_srs EPSG:4326

Install Microsoft Office 2010 on Ubuntu

Requirements

We'll install MSOffice using the PlayOnLinux wizard. Additionally, MSOffice requires samba and winbind to properly work.

So, if not installed, install them:

sudo apt-get install playonlinux samba winbind
@soiqualang
soiqualang / npmatrix_to_geotiff.py
Created June 28, 2019 02:34 — forked from CMCDragonkai/npmatrix_to_geotiff.py
Numpy Matrix to GDAL GeoTiff #python #gdal #numpy
import numpy as np
from osgeo import gdal, gdal_array, osr
def npmatrix_to_geotiff (filepath, matrices, gdal_type, transform = None, projection = None, nodata = None):
(y_res, x_res) = matrices[0].shape
driver = gdal.GetDriverByName('GTiff')
image = driver.Create(filepath, x_res, y_res, len(matrices), gdal_type)
if transform is not None:
image.SetGeoTransform(transform)
if projection is not None:
@soiqualang
soiqualang / youtube_frame.html
Last active August 7, 2019 07:25
Embed youtube iframe auto play when loaded
<iframe width="1263" height="695" src="https://www.youtube.com/embed/-SFcIUEvNOQ?rel=0&autoplay=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
@soiqualang
soiqualang / union_table_postgresql.sql
Last active August 7, 2019 07:25
[sql] ghep bang - UNION ALL #sql #UNION #ghep_bang
SELECT hientrang_cong.name,
replace(replace(replace((''::text || box2d(st_transform(hientrang_cong.geom, 4326))), 'BOX('::text, ''::text), ')'::text, ''::text), ' '::text, ','::text) AS bbox
FROM hientrang_cong
UNION ALL
SELECT hientrang_dap.name,
replace(replace(replace((''::text || box2d(st_transform(hientrang_dap.geom, 4326))), 'BOX('::text, ''::text), ')'::text, ''::text), ' '::text, ','::text) AS bbox
FROM hientrang_dap
UNION ALL
SELECT hientrang_debao.name,
replace(replace(replace((''::text || box2d(st_transform(hientrang_debao.geom, 4326))), 'BOX('::text, ''::text), ')'::text, ''::text), ' '::text, ','::text) AS bbox
@soiqualang
soiqualang / clone_database.sql
Created August 7, 2019 07:24
Clone Database in PostgreSQL #clone #database #sql #postgresql
/* KILL ALL EXISTING CONNECTION FROM ORIGINAL DB (sourcedb)*/
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'SOURCE_DB' AND pid <> pg_backend_pid();
/* CLONE DATABASE TO NEW ONE(TARGET_DB) */
CREATE DATABASE TARGET_DB WITH TEMPLATE SOURCE_DB OWNER USER_DB;
--https://stackoverflow.com/questions/876522/creating-a-copy-of-a-database-in-postgresql
@soiqualang
soiqualang / postgresql-set-id-seq.sql
Created August 8, 2019 07:32 — forked from henriquemenezes/postgresql-set-id-seq.sql
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));