Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃
hihihaha

soiqualang

🙃
hihihaha
View GitHub Profile
@soiqualang
soiqualang / delete_files.php
Last active Aug 24, 2017
delete all function
View delete_files.php
//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 Aug 25, 2017
Service để Ajax gọi tới get data
View services_ajax.php
//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 Aug 25, 2017
Hàm gọi Ajax phía client
View client_ajax.js
$(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 Jan 11, 2019 — forked from zackad/ogr2ogr.sh
ogr2ogr cheatsheet
View ogr2ogr.sh
# 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
View Install MSOffice on Ubuntu.md

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 Jun 28, 2019 — forked from CMCDragonkai/npmatrix_to_geotiff.py
Numpy Matrix to GDAL GeoTiff #python #gdal #numpy
View npmatrix_to_geotiff.py
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 Aug 7, 2019
Embed youtube iframe auto play when loaded
View youtube_frame.html
<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 Aug 7, 2019
[sql] ghep bang - UNION ALL #sql #UNION #ghep_bang
View union_table_postgresql.sql
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 Aug 7, 2019
Clone Database in PostgreSQL #clone #database #sql #postgresql
View clone_database.sql
/* 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 Aug 8, 2019 — forked from henriquemenezes/postgresql-set-id-seq.sql
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
View postgresql-set-id-seq.sql
-- 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));