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 / 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 / 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 / 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 / MSSQLSpatial.md
Last active September 5, 2019 04:30
[OGR2OGR] MSSQLSpatial - Microsoft SQL Server Spatial Database

[OGR2OGR] MSSQLSpatial - Microsoft SQL Server Spatial Database

Creating a layer from an OGR data source

ogr2ogr -overwrite -f MSSQLSpatial "MSSQL:server=.\MSSQLSERVER2008;database=geodb;trusted_connection=yes" "rivers.tab"

Connecting to a layer and dump the contents

ogrinfo -al "MSSQL:server=.\MSSQLSERVER2008;database=geodb;tables=rivers;trusted_connection=yes"

Instal on Linux notes

sudo chmod -R 777 /home/soiqualang/.npm
npm i -g cordova-res
sudo chown -R $USER:$(id -gn $USER) /home/soiqualang/.config
sudo chmod -R 777 /opt/lampp/htdocs/test_ionic/
ionic cordova resources android --force