Skip to content

Instantly share code, notes, and snippets.

View haoliangyu's full-sized avatar

Haoliang Yu haoliangyu

View GitHub Profile
@pixelhandler
pixelhandler / pre-push.sh
Last active May 17, 2024 12:12
Git pre-push hook to prevent force pushing master branch
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
# Based on https://gist.github.com/fernandoaleman/5083680
# Start the old vagrant
$ vagrant init ubuntu_saucy
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
@jeffjohnson9046
jeffjohnson9046 / percent-filter.js
Last active September 4, 2020 23:25
Format percentages in AngularJS
// In app.js or main.js or whatever:
// var myApp = angular.module('askchisne', ['ngSanitize', 'ngAnimate', 'ui.bootstrap', 'ui.bootstrap.tpls']);
// This filter makes the assumption that the input will be in decimal form (i.e. 17% is 0.17).
myApp.filter('percentage', ['$filter', function ($filter) {
return function (input, decimals) {
return $filter('number')(input * 100, decimals) + '%';
};
}]);
@averagehuman
averagehuman / postgres-docker-config.sh
Last active April 3, 2019 22:36
Run postgres on docker host, connect from docker containers
#!/bin/bash
################################################################################
# Rather than run postgres in its own container, we want to run it on
# the (Ubuntu) host and allow:
#
# + peer connections on the host
# + local md5 connections from any docker container
#
# THIS IS COPY/PASTED FROM COMMAND LINE INPUT AND IS UNTESTED AS A SINGLE SCRIPT
################################################################################
@clhenrick
clhenrick / README.md
Last active April 1, 2024 14:55
PostgreSQL & PostGIS cheatsheet (a work in progress)
@jeffaudi
jeffaudi / gdal2tilesG.py
Last active March 17, 2023 10:14
This is a version of gdal2tiles.py that generates tiles with the Google Maps naming rather than the normal OGC TMS one. This is just an inversion in the direction of the Y axis (ynew = 2^zoom – yold). I have also replaced EPSG:900913 by EPSG:3785 since gdal issues a warning.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#******************************************************************************
# $Id: gdal2tiles.py 27044 2014-03-16 23:41:27Z rouault $
#
# Project: Google Summer of Code 2007, 2008 (http://code.google.com/soc/)
# Support: BRGM (http://www.brgm.fr)
# Purpose: Convert a raster into TMS (Tile Map Service) tiles in a directory.
# - generate Google Earth metadata (KML SuperOverlay)
# - generate simple HTML viewer based on Google Maps and OpenLayers
@Sumbera
Sumbera / LICENSE.txt
Last active February 29, 2024 15:44
Many Polygons with geojson-vt on Leaflet
Licensed under MIT
Copyright (c) 2015 Stanislav Sumbera,
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@odoe
odoe / vector-tile-pr.md
Last active January 5, 2021 02:40
Indexing of Vector Tiles (Clipping Justification)

Indexing of Vector Tiles (Clipping Justification)

This pull-request provides the ability to display vector tile trees containing leaves at different levels of detail (LOD) based on data density. This requires clipping tiles when zoomed in beyond a physically present leaf and using an index to determine tile presence.

Purpose

The goal is to efficiently cook tiles and still maintain a high level of data precision in vector tiles. We can achieve this by limiting the cooking of tiles to a satisfactory LOD in less geometrically dense areas. On the consumer side, clipping can be used to clip larger tiles to fit a more precise LOD as needed. This methodology also provides over-zooming of tiles beyond the LOD limit of the current Vector Tile specification.

@bcoe
bcoe / npm-top.md
Last active May 14, 2024 11:29
npm-top.md

npm Users By Downloads (git.io/npm-top)


npm users sorted by the monthly downloads of their modules, for the range May 6, 2018 until Jun 6, 2018.

Metrics are calculated using top-npm-users.

# User Downloads
@wboykinm
wboykinm / falsehoods.md
Last active February 1, 2024 15:52
Falsehoods programmers believe about addresses - by Michael Tandy

Falsehoods programmers believe about addresses

This is an anchor-linked version of the excellent, amazing original opus magnum by Michael Tandy.

An address will start with, or at least include, a building number.

Counterexample: Royal Opera House, Covent Garden, London, WC2E 9DD, United Kingdom.

When there is a building number, it will be all-numeric.

Counterexample: 1A Egmont Road, Middlesbrough, TS4 2HT