Skip to content

Instantly share code, notes, and snippets.

@wryun
wryun / gist:aad699bcafdc6ea05236589d30b28cfb
Created December 30, 2023 02:26
generate ISDATA seconds output for sensor watch (actually back to front...)
class ISDATA:
def __init__(self, com, seg, on):
self.com = com
self.segs = [(seg % 8, on)]
self.offset = com * 6 + seg // 8
self.max_seg = seg // 8 * 8 + 7
def attempt_add(self, com, seg, on):
if com != self.com or seg > self.max_seg:
return False
Migrating some-custom-site
---------------------------------
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedColumn: ERROR: column categories.text_color does not exist
LINE 1: ... "categories"."slug", "categories"."description", "categorie...
^
: SELECT "categories"."id", "categories"."name", "categories"."color", "categories"."topic_id", "categories"."topic_count", "categories"."created_at", "categories"."updated_at", "categories"."user_id", "categories"."topics_year", "categories"."topics_month", "categories"."topics_week", "categories"."slug", "categories"."description", "categories"."text_color", "categories"."read_restricted", "categories"."auto_close_hours", "categories"."post_count", "categories"."latest_post_id", "categories"."latest_topic_id", "categories"."position", "categories"."parent_category_id", "categories"."posts_year", "categories"."posts_month", "categories"."posts_week",
@wryun
wryun / example-aws-mock.js
Last active November 16, 2017 10:26
Mocking js aws-sdk using sinon (rough notes)
beforeEach(function () {
this.aws = {};
stubAwsRequest(stubs);
});
afterEach(function () {
AWS.Request.prototype.runTo.restore();
});
AWS.Request.prototype.originalRunTo = AWS.Request.prototype.runTo;
@wryun
wryun / gist:2d14b0c38b56b163a59f
Created November 25, 2014 01:08
geoalchemy2 using geojson rather than wkb/wkt (wkbelement/wktelement)
import geoalchemy2, geoalchemy2.shape
import shapely.geometry
# Could use geomet rather than pushing this through shapely.
class Geometry(geoalchemy2.Geometry):
"""Deal in GeoJSON rather than WKB/WKT"""
def result_processor(self, dialect, coltype):
super_proc = super(Geometry, self).result_processor(dialect, coltype)
def process(v):
return v and shapely.geometry.mapping(