Skip to content

Instantly share code, notes, and snippets.

💭
Drinking tea

Matt Walker walkermatt

💭
Drinking tea
Block or report user

Report or block walkermatt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View standalone-qgis3.py
# Code borrowed from https://subscription.packtpub.com/book/application_development/9781783984985/1/ch01lvl1sec18/creating-a-standalone-application
# and upgraded for QGIS 3.0
import sys
from qgis.core import (QgsApplication, QgsFeature, QgsGeometry,
QgsProject, QgsVectorLayer)
from qgis.gui import QgsMapCanvas
from qgis.PyQt.QtCore import Qt
# Unused so commented
# from qgis.PyQt.QtGui import *
View gist:6c7b0afb180be4def6e705d701835f29
# got a huge ammount of help from https://stackoverflow.com/questions/11550153/determine-position-of-number-in-a-grid-of-numbers-centered-around-0-and-increasi
def sequence(i):
n = 2 * i - 1
return n * n
def layer(i):
return math.floor((math.sqrt(i) + 1) / 2)
def length(i):
@csuzw
csuzw / SpiralMemory.cs
Last active Dec 4, 2017
Advent of Code 2017 Day 3
View SpiralMemory.cs
int SpiralMemoryPartOne(int location)
{
if (location <= 1) return 0;
var ring = 1;
var max = 9;
while (max < location)
{
ring += 1;
max += (((ring + 1) * 2) - 2) * 4;
@opera443399
opera443399 / python_UnicodeEncodeError.py
Last active Jul 30, 2019
export PYTHONIOENCODING=UTF-8
View python_UnicodeEncodeError.py
from:
http://chase-seibert.github.io/blog/2014/01/12/python-unicode-console-output.html
Print to the console in Python without UnicodeEncodeErrors 12 Jan 2014
I can't believe I just found out about this! If you use Python with unicode data, such as Django database records, you may have seen cases where you print a value to the console, and if you hit a record with an extended (non-ascii) character, your program crashes with the following:
Traceback (most recent call last):
File "foobar.py", line 792, in <module>
print value
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)
@iacovlev-pavel
iacovlev-pavel / geoserver-install.sh
Last active May 8, 2020
Install GeoServer on Ubuntu 18.04
View geoserver-install.sh
#
apt-get install openjdk-8-jre
# PostgreSQL and PostGIS
apt-get install postgresql postgresql-contrib postgis postgresql-10-postgis-2.4
# Create "geoserver" database
sudo -u postgres createuser -P geoserver
sudo -u postgres createdb -O geoserver geoserver
sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" geoserver
View runtimer.js
function* runTimer(getState) {
while(yield take('START')) {
while(true) {
const {stop, tick} = yield race({
stop : take('STOP'),
tick : call(wait, ONE_SECOND);
})
if ( !stop ) {
yield put(actions.tick());
@t-mart
t-mart / netrw quick reference.md
Last active May 30, 2020
A quick reference for Vim's built-in netrw file selector.
View netrw quick reference.md
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
@javisantana
javisantana / speed.sql
Created Aug 12, 2015
speed from a track table
View speed.sql
WITH deltas as (
SELECT
st_distance(the_geom::geography, lag(the_geom::geography, 1) over(order by timestamp)) as ddist,
timestamp - lag(timestamp, 1) over(order by timestamp) as dt
from out_2 offset 1000
)
select avg(ddist/dt) as speed from deltas
@AustinDizzy
AustinDizzy / pre-commit
Created Jul 12, 2015
A pre-commit git hook that prompts you to automatically `gofmt` Go files staged to commit.
View pre-commit
#!/bin/sh
# Modified 2015, Austin Dizzy
# Copyright 2012 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# git gofmt pre-commit hook
#
# To use, store as .git/hooks/pre-commit inside your repository and make sure
# it has execute permissions.
View browserify_for_webpack_users.markdown

browserify for webpack users

There's been a strange explosion in misinformation about browserify recently, particularly in comparisons to webpack.

Generally speaking, most of this confusion stems from how webpack is more willing to pull features into its core to ease discoverability while browserify is more likely to push features out to userland instead.

I think that longer-term, separability has more benefits from a maintenance and

You can’t perform that action at this time.