Skip to content

Instantly share code, notes, and snippets.

🌴
Working from home

Adi Roiban adiroiban

🌴
Working from home
Block or report user

Report or block adiroiban

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adiroiban
adiroiban / ssl_country_codes.js
Created Apr 9, 2015
SSL country codes and country names mapping
View ssl_country_codes.js
var countries = [
{'name': 'Afghanistan', 'code': 'AF'},
{'name': 'Albania', 'code': 'AL'},
{'name': 'Algeria', 'code': 'DZ'},
{'name': 'American Samoa', 'code': 'AS'},
{'name': 'Andorra', 'code': 'AD'},
{'name': 'Angola', 'code': 'AO'},
{'name': 'Anguilla', 'code': 'AI'},
{'name': 'Antarctica', 'code': 'AQ'},
{'name': 'Antigua and Barbuda', 'code': 'AG'},
View test.py
def test_resumeFromResumeOffset(self):
"""
If given a resumeOffset argument, L{DccFileReceive} will attempt to
resume from that number of bytes if the file exists.
"""
fp = FilePath(self.mktemp())
fp.setContent("Twisted is awesome!")
protocol = self.makeConnectedDccFileReceive(fp.path, resumeOffset=11)
self.allDataReceivedForProtocol(protocol, "amazing!")
@adiroiban
adiroiban / tls_protocol_negociation_twisted.py
Created Jun 8, 2015
code to help testing NPN support in Twisted
View tls_protocol_negociation_twisted.py
from OpenSSL import SSL
from twisted.internet import ssl, protocol, defer, endpoints, reactor, task
def main(reactor):
options = ssl.optionsForClientTLS(
hostname=u'http2bin.org',
extraCertificateOptions={'nextProtocols': [b'h2', b'http/1.1']}
)
View README.md

Simple Twisted H2 Client

This gist contains a really stupid implementation of a Twisted HTTP/2 client. It opens a connection, uses ALPN/NPN to negotiate HTTP/2, and then sends a single HTTP/2 GET request to the /ip endpoint.

To execute this:

  1. Create a clean virtual environment.
  2. Install the requirements: pip install -r requirements.txt.
  3. Install the development version of Twisted that contains the nextProtocols code.
  4. Execute the code using python h2test.py.
View weather error
Jun 28 22:05:48 vremea weewx[3245]: engine: Caught unrecoverable exception in engine:
Jun 28 22:05:48 vremea weewx[3245]: **** /lib/arm-linux-gnueabihf/libusb-1.0.so.0: undefined symbol: libusb_strerror
Jun 28 22:05:48 vremea weewx[3245]: **** Traceback (most recent call last):
Jun 28 22:05:48 vremea weewx[3245]: **** File "/home/weewx/bin/weewx/engine.py", line 836, in main
Jun 28 22:05:48 vremea weewx[3245]: **** engine.run()
Jun 28 22:05:48 vremea weewx[3245]: **** File "/home/weewx/bin/weewx/engine.py", line 187, in run
Jun 28 22:05:48 vremea weewx[3245]: **** for packet in self.console.genLoopPackets():
Jun 28 22:05:48 vremea weewx[3245]: **** File "/home/weewx/bin/weewx/drivers/fousb.py", line 1091, in genLoopPackets
Jun 28 22:05:48 vremea weewx[3245]: **** for p in self.get_observations():
Jun 28 22:05:48 vremea weewx[3245]: **** File "/home/weewx/bin/weewx/drivers/fousb.py", line 1156, in get_observations
@adiroiban
adiroiban / txsyslogd.py
Last active Sep 10, 2015 — forked from gleicon/txsyslogd.py
minimalistic syslog daemon written with twisted.
View txsyslogd.py
#!/usr/bin/python
#
# Simple syslog collector used for testing.
#
from twisted.internet import address, reactor, stdio, defer
from twisted.internet.protocol import DatagramProtocol, Protocol, Factory
from twisted.protocols.basic import LineReceiver
import time, re, math, json
#<22>Nov 1 00:12:04 gleicon-vm1 postfix/smtpd[4880]: connect from localhost[127.0.0.1]
@adiroiban
adiroiban / Depth first non blocking traversal
Last active Oct 28, 2015
Depth first non blocking traversal - use task.deferLater to allow other callbacks to execute
View Depth first non blocking traversal
Errors for running the recursive version
['37']
['36']
^CUnhandled error in Deferred:
Traceback (most recent call last):
File "/home/adi/chevah/twisted/twisted/internet/defer.py", line 1184, in gotResult
_inlineCallbacks(r, g, deferred)
@adiroiban
adiroiban / report.rst
Last active Nov 2, 2015
Twisted Fellowship 2015 - October Report
View report.rst

October 2015 - TSF Sponsored Development

This is my first post from a series of post dedicated to my work as part of the 2015-2016 Twisted Maintainer Fellowship program.

The Twisted project via Software Freedom Conservancy were kind enought to contract me as a consultant to help with the review queue and the Git migration.

I am sharing this Twisted Maintainer Fellowship program with Amber aka Hawkie aka hawkowl.

Below is the report for October 2015.

View gist:ae6b6d738173a30f77b1
===============================================================================
[FAIL]
Traceback (most recent call last):
File "/home/adi/chevah/twisted/twisted/internet/test/test_unix.py", line 449, in test_avoidLeakingFileDescriptors
expectedEvent, pformat(events,)))
twisted.trial.unittest.FailTest: Expected event ({'protocolName': 'ConnectableProtocol', 'format': '%(protocolName)s (on %(hostAddress)r) does not provide IFileDescriptorReceiver; closing file descriptor received (from %(peerAddress)r).', 'hostAddress': UNIXAddress(None), 'peerAddress': UNIXAddress('./tmpAMIQ3S.sock')}) not found in logged events ([{'format': '%(log_legacy)s',
'isError': 0,
'log_format': u'{log_text}',
'log_legacy': <twisted.logger._stdlib.StringifiableFromEvent object at 0x7fb94404eb50>,
'log_level': <LogLevel=info>,
View courses.rst

Computer Science Courses that Don't Exist, But Should

CSCI 2100: Unlearning Object-Oriented Programming

Discover how to create and use variables that aren't inside of an object hierarchy. Learn about "functions," which are like methods but more generally useful. Prerequisite: Any course that used the term "abstract base class."

You can’t perform that action at this time.