Skip to content

Instantly share code, notes, and snippets.

View soiqualang's full-sized avatar
🙃
hihihaha

Đỗ Thành Long soiqualang

🙃
hihihaha
View GitHub Profile
@kennethreitz
kennethreitz / .htaccess
Created March 29, 2010 04:55
(Passwd) Basic Authentication .htaccess example
Options +Indexes
<Files *>
AuthType Basic
AuthName "Please enter your username and password."
AuthUserFile .htpasswd
Require valid-user
</Files>
@fj
fj / gist:1597544
Created January 11, 2012 23:51
Slightly nicer way of writing large files to disk with PHP
// Copy big file from somewhere else
$src_filepath = 'http://example.com/all_the_things.txt'; $src = fopen($src_filepath, 'r');
$tmp_filepath = '...'; $tmp = fopen($tmp_filepath, 'w');
$buffer_size = 1024;
while (!feof($src)) {
$buffer = fread($src, $buffer_size); // Read big file/data source/etc. in small chunks
fwrite($tmp, $buffer); // Write in small chunks
}
@retgef
retgef / pug-bomb.php
Created June 24, 2012 07:46
Pug Bomb API Endpoint WordPress Plugin
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{
@schoenobates
schoenobates / mbtile-server.py
Created August 3, 2012 09:39
Really quick and dirty way to serve tiles from a MBTiles file
#!/usr/bin/env python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import re
import sqlite3 as sqlite
# Hacky serving of MBtile data
# Put filename to the MBTiles file below: this could be done with cmd line options
# but this is a hack so there ....
@thuandt
thuandt / no_accent_vietnamese.py
Created August 22, 2012 03:07
Chuyển đổi từ Tiếng Việt có dấu sang Tiếng Việt không dấu
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Chương trình chuyển đổi từ Tiếng Việt có dấu sang Tiếng Việt không dấu
Chỉnh sửa từ mã nguồn của anh NamNT
http://www.vithon.org/2009/06/14/x%E1%BB%AD-ly-ti%E1%BA%BFng-vi%E1%BB%87t-trong-python
"""
import re
INTAB = "ạảãàáâậầấẩẫăắằặẳẵóòọõỏôộổỗồốơờớợởỡéèẻẹẽêếềệểễúùụủũưựữửừứíìịỉĩýỳỷỵỹđẠẢÃÀÁÂẬẦẤẨẪĂẮẰẶẲẴÓÒỌÕỎÔỘỔỖỒỐƠỜỚỢỞỠÉÈẺẸẼÊẾỀỆỂỄÚÙỤỦŨƯỰỮỬỪỨÍÌỊỈĨÝỲỶỴỸĐ"
@justinlewis
justinlewis / postgis2shp.py
Last active October 10, 2022 09:02
A simple script for converting PostGIS tables to shapefiles with ogr2ogr.
#### Author: Justin Lewis
#### This script can be used to export a single pg table to shapefile.
####
#### Developed in a linux environment but should require minimal modification to run on other platforms.
####
#### Dependancies:
###### fwtools (gdal > ogr2ogr), PostGIS database, Python, PyGreSQL
import os, _pg
@tmcw
tmcw / xyz_vs_tms.md
Last active April 3, 2024 06:18
The difference between XYZ and TMS tiles and how to convert between them

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

@perrygeo
perrygeo / zonal_stats.py
Last active March 22, 2023 05:01
Python implementation of zonal statistics function. Optimized for dense polygon layers, uses numpy, GDAL and OGR to rival the speed of starspan.
"""
Zonal Statistics
Vector-Raster Analysis
Copyright 2013 Matthew Perry
Usage:
zonal_stats.py VECTOR RASTER
zonal_stats.py -h | --help
zonal_stats.py --version
@bmcbride
bmcbride / gdal.txt
Last active January 11, 2021 17:48
GDAL commands to convert NYSDOP orthoimagery JPEG2000 files to GeoTiff & PDF
SINGLE FILE CONVERT
gdal_translate input_nysdop_ortho.jp2 output.tif -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co JPEG_QUALITY=25 -co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES -a_srs EPSG:2260
BATCH CONVERT
for /r %g in (*.jp2) do gdal_translate -of GTiff "%g" "%~dpng.tif" -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co JPEG_QUALITY=25 -co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES -a_srs EPSG:2260
BUILT VIRTUAL RASTER (CATALOG)
gdalbuildvrt catalog.vrt e_06811416_06_05000_4bd_2011.jp2 e_06811414_06_05000_4bd_2011.jp2 e_06781416_06_05000_4bd_2011.jp2 e_06781414_06_05000_4bd_2011.jp2
gdalbuildvrt -allow_projection_difference -hidenodata -vrtnodata "255 255 255" nysdop.vrt *.jp2 -a_srs EPSG:2260
@emiliom
emiliom / AOOS_SOS_SensorML_owslib_AlaskaNDBCBuoy_1.ipynb
Created November 5, 2013 01:50
#IOOS #SOS #OWSLib #MMI Access the AOOS SOS GetCapabilities, issue a sample DescribeSensor request, then parse parts of the response. Includes examples of testing the validity of controlled vocabulary terms vs MMI (using the approach described on the IPython notebook http://nbviewer.ipython.org/6514804). This SOS test complements the one for Get…
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.