This file contains hidden or 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 -*- | |
import threading | |
from collections import deque | |
import functools | |
import traceback | |
MAX_THREADS = 8 | |
class ThreadPool(object): |
This file contains hidden or 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 "bencode.h" | |
BEncode::BEncode() | |
: m_decodeError{ false } | |
{ | |
} | |
QByteArray BEncode::encode(QVariant value) | |
{ | |
return encodeVariant(value); |
This file contains hidden or 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 "XMLHttpRequest.h" | |
XMLHttpRequest::XMLHttpRequest(QObject *parent) | |
: QObject(parent), | |
p_status(0), | |
p_readyState(0) | |
{ | |
} | |
void XMLHttpRequest::open(QString method, QString url) |
This file contains hidden or 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 <stdlib.h> | |
#define PRECISION 0.0000001 | |
#define POW2(x) x * x | |
#define ABS(x) x > 0 ? x : -x | |
#define TEST(VALUE, EXPECT) {\ | |
printf("testing: %0.4f expecting %0.4f", VALUE, EXPECT);\ | |
if (ABS(_sqrt(VALUE) - EXPECT) <= PRECISION)\ |
This file contains hidden or 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 -*- | |
import sys | |
class _ListNode(object): | |
def __init__(self, obj): | |
self._obj = obj | |
self._next = None | |
def _append(self, obj): |
This file contains hidden or 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> | |
uint8_t lookup_table[0xFFFF] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, | |
3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, | |
3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, | |
6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, | |
3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, | |
4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, | |
6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, |
This file contains hidden or 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
def prepare_bitmap(self, bitmap, align="left"): | |
bitmap = bitmap.convert("1") | |
width = self._bitmap_res\ | |
if bitmap.size[0] > self._bitmap_res else bitmap.size[0] | |
height = bitmap.size[1] | |
if width < bitmap.size[0]: | |
bitmap = bitmap.crop((0, 0, width, height)) |
This file contains hidden or 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 -*- | |
import socket | |
import select | |
class RSerialError(IOError): | |
pass | |
This file contains hidden or 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 python2.7 | |
""" | |
LPR server for remote control to serial port via network supporting auto discover of the server. | |
""" | |
import serial | |
import socket | |
import select |
This file contains hidden or 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 <function> | |
#include <QString> | |
#include <QObject> | |
class LambdaConnectorHelper: public QObject | |
{ | |
Q_OBJECT | |
LambdaConnectorHelper(QObject *parent, const function<void()> &f) | |
: QObject(parent), m_lamba(f) | |
{ |
NewerOlder