Skip to content

Instantly share code, notes, and snippets.

View soiqualang's full-sized avatar
🙃
hihihaha

Đỗ Thành Long soiqualang

🙃
hihihaha
View GitHub Profile
@Ciantic
Ciantic / dirname-filename-basename.bat
Created April 1, 2016 15:11
How to get filename, dirname, and basename in bat?
set filepath="C:\some path\having spaces.txt"
for /F "delims=" %%i in (%filepath%) do set dirname="%%~dpi"
for /F "delims=" %%i in (%filepath%) do set filename="%%~nxi"
for /F "delims=" %%i in (%filepath%) do set basename="%%~ni"
echo %dirname%
echo %filename%
echo %basename%
@henriquemenezes
henriquemenezes / postgresql-set-id-seq.sql
Created March 31, 2016 12:23
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));
@gordcorp
gordcorp / GeoWebCacheService.py
Created February 8, 2016 03:51
Empty and reseed GeoServer GeoWebCache
import requests
class GeoWebCacheService(object):
"""Class to communicate with the geowebcache api.
Api doco here: http://geowebcache.org/docs/current/rest/seed.html
"""
_url = None
_username = None
_password = None
@trolleway
trolleway / wfs_download.py
Created November 10, 2015 13:30
mass download vector data from WFS service. Generates a sh script with ogr2ogr calls.
from owslib.fes import *
from owslib.etree import etree
from owslib.wfs import WebFeatureService
wfs11 = WebFeatureService(url='http://example.com:8080/geoserver/wfs/', version='1.1.0')
f = open('download.sh', 'wb')
f.write('#!/bin/bash'+'\n')
f.write(''+'\n')
@adriennn
adriennn / leaflet-css-divicon.txt
Created September 18, 2015 08:11
Create a lightweight L.divIcon for Leaflet using css and icon fonts
// modified from http://codepen.io/gisminister/pen/Hdorv
// Create a marker
var myMarker = L.divIcon({
className: 'map-marker marker-color-gray a-class',
iconSize: [28,28],
html:'<i class="fa fa-fw fa-2x fa-question"></i>' // FontAwesome.io
});
// Style with css
@Folyd
Folyd / debug_via_wifi.sh
Created September 17, 2015 11:36
A shell script let you debug android device via WI-FI.
#!/usr/bin/env bash
#Notice: if unable to connect to [ip]:5555,
#try adb kill-server then try again.
adb shell ip route > addrs.txt
#Case 1:Nexus 7
#192.168.88.0/23 dev wlan0 proto kernel scope link src 192.168.89.48
#Case 2: Smartsian T1,Huawei C8813
#default via 192.168.88.1 dev eth0 metric 30
@cmatskas
cmatskas / GitDeleteCommands.ps1
Last active September 22, 2022 07:59
Git Delete Branch commands
## Delete a remote branch
$ git push origin --delete <branch> # Git version 1.7.0 or newer
$ git push origin :<branch> # Git versions older than 1.7.0
## Delete a local branch
$ git branch --delete <branch>
$ git branch -d <branch> # Shorter version
$ git branch -D <branch> # Force delete un-merged branches
## Delete a local remote-tracking branch
@alexgleith
alexgleith / GeoServer GWC REST Example
Created March 18, 2015 21:33
Truncate and Seed GWC cached layers in GeoServer
import json
import urllib2
import base64
baseURL = "https://domain.example:8080/geoserver/gwc/rest/seed/"
descURL = "https://domain.example:8080/geoserver/gwc/rest/layers/"
un = 'username'
pw = 'biglongtrickypassword'
def truncateLayer(layer):
@alfredotranchedone
alfredotranchedone / BetterWMS
Last active November 3, 2023 04:29 — forked from rclark/Issues.md
L.TileLayer.BetterWMS.js extend L.TileLayer.WMS
There are a bunch of reasons why this is convoluted, mostly in building the URL to make the request:
1. You have to rely on an AJAX request, this example uses jQuery
2. To make a GetFeatureInfo request, you must provide a BBOX for a image, and the pixel coordinates for the part of the image that you want info from. A couple of squirrely lines of Leaflet code can give you that.
3. Output formats. The `info_format` parameter in the request. We don't know *a priori* which will be supported by a WMS that we might make a request to. See [Geoserver's docs](http://docs.geoserver.org/stable/en/user/services/wms/reference.html#getfeatureinfo) for what formats are available from Geoserver. That won't be the same from WMS to WMS, however.
4. WMS services return XML docs when there's a mistake in the request or in processing. This sends an HTTP 200, which jQuery doesn't think is an error.
5. added a php proxy and 2 new options (CORS workaround)
@terrywbrady
terrywbrady / GoogleSpreadsheet.html
Last active May 17, 2024 07:17
Sample HTML/JS to parse a Google Spreadsheet
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var spData = null;
function doData(json) {
spData = json.feed.entry;
}