Skip to content

Instantly share code, notes, and snippets.

View jakubczaplicki's full-sized avatar

Jakub Czaplicki jakubczaplicki

View GitHub Profile
{'type': 'Polygon', 'coordinates': (((105.6218096, 10.4721381), (105.6220386, 10.4712392), (105.6240097, 10.4694264), (105.6257081, 10.4676611), (105.626322, 10.4669884), (105.6268526, 10.4662731), (105.6277602, 10.46479), (105.6283808, 10.4636678), (105.6288847, 10.4625653), (105.6292433, 10.4617926), (105.6303257, 10.4594585), (105.6306228, 10.4588102), (105.630757, 10.4585173), (105.6326297, 10.4542549), (105.632689, 10.4541465), (105.6340595, 10.4549877), (105.635508, 10.4558845), (105.636892, 10.4567656), (105.6422267, 10.4600134), (105.6420984, 10.460099), (105.6420346, 10.4601582), (105.6419155, 10.4603322), (105.6416404, 10.4607085), (105.641363, 10.4611956), (105.64122, 10.4615701), (105.6409888, 10.4623105), (105.6408281, 10.4629881), (105.6404208, 10.4649776), (105.6401765, 10.4657591), (105.6399013, 10.4665016), (105.6397472, 10.4668112), (105.6391484, 10.4675624), (105.6382744, 10.4685084), (105.6378275, 10.4691016), (105.637068, 10.4701991), (105.6366717, 10.4707923), (105.6365738, 10.4708994),
{'type': 'MultiPolygon', 'coordinates': [(((-58.4947729, -33.5855496), (-58.4946871, -33.5870601), (-58.4944311, -33.5880873), (-58.4938717, -33.5898933), (-58.4926272, -33.5931374), (-58.4879335, -33.6058521), (-58.484838, -33.6145478), (-58.482118, -33.625382), (-58.4772512, -33.6442167), (-58.4766394, -33.6464541), (-58.4762016, -33.6480635), (-58.4753967, -33.650208), (-58.4741008, -33.6525408), (-58.4695637, -33.6586175), (-58.4617281, -33.6687469), (-58.4519405, -33.6816091), (-58.448353, -33.6861508), (-58.4471807, -33.6881443), (-58.4430385, -33.698815), (-58.4391359, -33.7089058), (-58.4360116, -33.717055), (-58.4347009, -33.7203792), (-58.4341336, -33.7232867), (-58.4341258, -33.7249626), (-58.4344054, -33.7303622), (-58.4353137, -33.7381698), (-58.4362163, -33.7458763), (-58.4372675, -33.7529441), (-58.4376312, -33.7559226), (-58.437813, -33.7591697), (-58.4373884, -33.7659953), (-58.4366654, -33.7772091), (-58.4358353, -33.7920132), (-58.4350791, -33.8040656), (-58.435013, -33.8052057), (-58.43490
from datetime import datetime
from functools import singledispatch
from utils.data.data_point import DataPoint
@singledispatch
def extract_data(item, **kwargs):
return None # unknown type
@jakubczaplicki
jakubczaplicki / python_octoprint.sh
Last active June 26, 2020 08:07
Installing Python 3.8.3 + PIP + virtualenv + Octoprint on RaspberryPI
# install dependencies
sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev
# install openssl
./config --prefix=$HOME/openssl && make install
# add the path /home/pi/openssl/lib to /etc/ld.so.conf
ldconfig
# install python
./configure --with-openssl=/home/pi/openssl --prefix=$HOME/python38
@jakubczaplicki
jakubczaplicki / christmas_lights.ino
Created April 20, 2018 08:34
Christmas lights fading
/*
Christmas lights fading example
The analogWrite() function uses PWM, so if
you want to change the pin you're using, be
sure to use another PWM capable pin. On most
Arduino, the PWM pins are identified with
a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
*/
@mock.patch('aiodns.DNSResolver.query')
def test_resolve_fqdn_to_cname(self, query):
f = asyncio.Future()
f.set_result(("dummy_cname", "ttl"))
query.return_value = f
@jakubczaplicki
jakubczaplicki / gist:6b9ee2f6390ae088f267b4fbc361207e
Created February 17, 2018 22:46
storeImageToExternalStorage
private fun storeImageToExternalStorage(imageData: String, personIdentityId: String) {
// TODO: refactor to add base64 string to the cached JSON
val offendersFile = File(mView?.getContext()?.filesDir, personIdentityId+".jpg")
if (offendersFile.exists()) offendersFile.delete()
offendersFile.createNewFile()
val outputStream = mView?.getContext()?.openFileOutput(
personIdentityId+".jpg",
Context.MODE_PRIVATE
)
start = time.time()
r = requests.get(cls.base_url)
while r.status_code != 200:
print("Server not ready..")
if time.time() - start > 3:
raise RuntimeError("Failed to Start Server")
time.sleep(0.01)
r = requests.get(cls.base_url)
import asyncio
import sys
from aio_pika import connect, Message
import logging
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logging.getLogger("pika.heartbeat").setLevel(logging.CRITICAL)
logging.getLogger("pika.callback").setLevel(logging.CRITICAL)
@jakubczaplicki
jakubczaplicki / sds011
Created February 22, 2017 20:35 — forked from kadamski/sds011
SDS011 dust sensor reading
#!/usr/bin/python
# coding=utf-8
# "DATASHEET": http://cl.ly/ekot
from __future__ import print_function
import serial, struct, sys, time
DEBUG = 1
CMD_MODE = 2
CMD_QUERY_DATA = 4
CMD_DEVICE_ID = 5