This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
// Philips Sonicare NFC Head Password calculation by @atc1441 Video manual: https://www.youtube.com/watch?v=EPytrn8i8sc | |
uint16_t CRC16(uint16_t crc, uint8_t *buffer, int len) // Default CRC16 Algo | |
{ | |
while(len--) | |
{ | |
crc ^= *buffer++ << 8; | |
int bits = 0; | |
do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
import zlib | |
from typing import BinaryIO, List, Tuple | |
Pixel = Tuple[int, int, int] | |
Image = List[List[Pixel]] | |
BLACK_PIXEL: Pixel = (0, 0, 0) | |
WHITE_PIXEL: Pixel = (255, 255, 255) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "thsq.h" | |
#include "ti-lib.h" | |
#include "gpio-interrupt.h" | |
#include "lib/sensors.h" | |
#include "batmon-sensor.h" | |
#include "dev/leds-arch.h" | |
#include "dev/cc26xx-uart.h" | |
/*---------------------------------------------------------------------------*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "thsq.h" | |
#include "ti-lib.h" | |
/*---------------------------------------------------------------------------*/ | |
/* | |
* Thingsquare lighting switch with slider. | |
* | |
* This client uses a linear potentiometer to set the dim level of the lights | |
* in the network. To save power, we only power the potentiometer when we will | |
* sample it, and we only send light control if it has moved enough. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.views.generic import FormView | |
from django.utils.translation import ugettext_lazy as _ | |
from django.contrib import messages | |
from import_export.formats import base_formats | |
from import_export.forms import ImportForm, ConfirmImportForm | |
from import_export.resources import modelresource_factory | |
from django.http import HttpResponseRedirect | |
from import_export.tmp_storages import TempFolderStorage | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Comparing serialization of complex GeoJSON geometries using: | |
# | |
# - standard lib json, marshal, pickle, cPickle | |
# - umsgpack | |
# - shapely.wkb | |
# - geobuf (protobuf) | |
# | |
# The test case is a nearly circular polygon with 128 vertices. | |
# | |
# Python 2.7 because geobuf isn't possible on Python 3 (because |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jwt | |
from django.conf import settings | |
from django.contrib.auth.models import User | |
from rest_framework import exceptions | |
from rest_framework.authentication import TokenAuthentication | |
class JSONWebTokenAuthentication(TokenAuthentication): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val n = 9 | |
val s = Math.sqrt(n).toInt | |
type Board = IndexedSeq[IndexedSeq[Int]] | |
def solve(board: Board, cell: Int = 0): Option[Board] = (cell%n, cell/n) match { | |
case (r, `n`) => Some(board) | |
case (r, c) if board(r)(c) > 0 => solve(board, cell + 1) | |
case (r, c) => | |
def guess(x: Int) = solve(board.updated(r, board(r).updated(c, x)), cell + 1) | |
val used = board.indices.flatMap(i => Seq(board(r)(i), board(i)(c), board(s*(r/s) + i/s)(s*(c/s) + i%s))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
A script to get the version of Python by which the file was compiled | |
""" | |
from __future__ import print_function | |
import binascii | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from uuid import uuid4 | |
from datetime import timedelta | |
from couchbase import Couchbase | |
from couchbase import FMT_PICKLE | |
from couchbase.exceptions import NotFoundError |
NewerOlder