Skip to content

Instantly share code, notes, and snippets.

View ties's full-sized avatar

Ties de Kock ties

  • The Netherlands
View GitHub Profile
from z3 import Solver, EnumSort, Const, Distinct
s = Solver()
Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
a = Const('a', Color)
b = Const('b', Color)
s.add(Distinct(a, b))
s.check()
@ties
ties / printcall_util.py
Last active June 13, 2017 13:58
Utility that prints calls on the attribute path of the object
import logging
logging.basicConfig()
logging.getLogger(__name__).setLevel(logging.INFO)
LOG = logging.getLogger(__name__)
class PrintCalls(object):
"""
Log all the calls done on this object. This object wraps, and redirects
/**
* An higher order component that provides the 'isAuthenticated' prop to it's
* children
*/
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { selectIsAuthenticated } from './selectors';
@ties
ties / all_inkoopdata.py
Last active February 22, 2017 13:17
Utility: Download alle open inkoopdata bestanen vanaf data.overheid.nl
"""
Utility: Download alle open inkoopdata bestanen vanaf data.overheid.nl
Dependencies: requests, ckanapi
Copyright (c) 2017 T. de Kock
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# Python code written by undergraduate math student:
#
i = 1
while i in range(1, 10):
print(i)
i += 1
"""
**Uses asyncio with async/await syntax**
Requires python 3.5.2 to run without modification
Connect to a TCP socket and read P1 telegrams over TCP. Parse these
and push them onto a queue.
A second coroutine sends them to a MQTT broker.
dependencies:

Strange HTTP handling, echoes a long HTTP method in response...

Anything over 7 characters seems to be echoed as the beginning of the response:

➜  compal_CH7465LG_py git:(master) ✗ curl -v -X"GET GE HTTP/1.0" "http://192.168.178.1/"
*   Trying 192.168.178.1...
* Connected to 192.168.178.1 (192.168.178.1) port 80 (#0)
> GET GE HTTP/1.0 / HTTP/1.1
> Host: 192.168.178.1
> User-Agent: curl/7.49.1
@ties
ties / ocr_grep.py
Last active September 12, 2016 09:57
Utility: Grep in OCR (tesseract) output
"""
To be used when you want to grep in OCR output.
python ocr_grep.py Screenshot\*.png -i werkzaamheden
<glob pattern> <grep arguments>
Each file is run through tesseract, its output is then piped through
`grep <grep_arguments>`
#futurework: Cache OCR output
@ties
ties / also.js
Last active September 2, 2016 17:36
// with Babel do-expression-transform <https://babeljs.io/docs/plugins/transform-do-expressions/>
function(lhs, rhs) {
return do {
if (lhs) {
Api.fromJS(lhs)
} else {
res.firstField = do {
if (rhs) {
List(rhs.map((vt) => SomeClass.fromJS(vt)))
} else {
import { Map, List } from 'immutable';
function attributeWrapper(mappings) {
return {
get(target, property) {
if (!mappings.has(property)) {
return target[property];
}
// get the target property