Skip to content

Instantly share code, notes, and snippets.

@tsauerwein
tsauerwein / batch-delete.py
Created December 3, 2018 10:05
Bulk delete a larger number of rows without locking up the table
import subprocess
import re
import time
def delete():
delete_stmt = [
'mysql',
'-h', '...',
'-u', '...',
'--password=...',
@tsauerwein
tsauerwein / none-nested-sequence.py
Created October 28, 2016 08:29
Colander and None?
import colander
class NoneSequence(colander.MappingSchema):
foo = colander.SchemaNode(colander.String())
bar = colander.SchemaNode(
colander.Sequence(), colander.SchemaNode(colander.String()),
missing=None)
@tsauerwein
tsauerwein / sqlalchemy-raw-sql.py
Created October 15, 2016 08:51
SQLAlchemy: Using raw SQL in ORM statements
# ...
participants_and_editor = text(
'ARRAY(SELECT DISTINCT UNNEST(array_cat('
' ARRAY[guidebook.feed_document_changes.user_id], :participants)) '
'ORDER BY 1)')
DBSession.execute(
DocumentChange.__table__.update().
where(DocumentChange.document_id == outing_id).
where(DocumentChange.change_id != existing_change.change_id).
values(user_ids=participants_and_editor),
@tsauerwein
tsauerwein / index.html
Created April 19, 2016 20:21
OpenLayers 3 + windy.js
<!doctype html>
<html lang="en">
<head>
<title>windy.js integration example</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="http://openlayers.org/en/v3.15.0/css/ol.css" type="text/css">
<style type="text/css">
#map {
@tsauerwein
tsauerwein / index.html
Last active November 28, 2019 08:48
ol3-google-maps test
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="index, all" />
<title>OL3-Google-Maps vector example</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="http://dev5.mapgears.com/ol3-google-maps/node_modules/openlayers/css/ol.css" type="text/css" />
<link rel="stylesheet" href="http://dev5.mapgears.com/ol3-google-maps/css/ol3gm.css" type="text/css" />
@tsauerwein
tsauerwein / index.html
Created February 20, 2016 11:23
Smart mouse-wheel scrolling for OpenLayers 3 maps #2
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="http://openlayers.org/en/v3.13.1/css/ol.css" type="text/css">
<style>
.content {
@tsauerwein
tsauerwein / index.html
Last active February 20, 2016 11:02
Smart mouse-wheel scrolling for OpenLayers 3 maps
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="http://openlayers.org/en/v3.13.1/css/ol.css" type="text/css">
<style>
.content {
@tsauerwein
tsauerwein / bulk_none.py
Created January 6, 2016 20:43
SQLAlchemy bulk insertion with None
from sqlalchemy import Column, String, Integer
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.sql.expression import null
Base = declarative_base()
class Doc(Base):
__tablename__ = 'doc'
@tsauerwein
tsauerwein / flight-animation-1.js
Created August 24, 2015 12:44
OpenLayers 3 Flight Animation
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.Stamen({layer: 'toner'})
})
],
renderer: 'canvas',
target: 'map',
view: new ol.View({
center: [0, 0],
@tsauerwein
tsauerwein / update-gh-pages.sh
Last active August 29, 2015 14:28
OpenLayers 3: Update gh-pages
#!/bin/bash
# run from inside the ol3 directory with e.g.:
# ./../update-gh-pages.sh draw-and-modify
#
# http://tsauerwein.github.io/ol3/draw-and-modify/examples/
if [[ -z $1 ]]; then
echo "Usage error."
exit 1