I hereby claim:
- I am svvitale on github.
- I am svvitale (https://keybase.io/svvitale) on keybase.
- I have a public key ASDTmkxAdl96XWG71bZe4C58UsDKQXlt8DaltryKd8ALYAo
To claim this, I am signing this object:
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using RFIDeas_pcProxAPI; | |
using System.Net; | |
using System.Threading; | |
using System.IO; |
I hereby claim:
To claim this, I am signing this object:
I absolutely love using operator overrides in low-level objects because it can make the caller's use case WAY more intuitive. There are certainly some pitfalls though.
__getitem__
and __setitem__
to make an object more dictionary-like, make sure to also override __iter__
OR __contains__
since they're called to handle membership tests like in
and not in
. (ref: https://docs.python.org/3/reference/expressions.html#membership-test-operations)Enums can be a little tedious in Python, but there are a few things I try to do to streamline usage:
class _Singleton(type): | |
"""Singleton class from Stack Overflow: | |
http://stackoverflow.com/a/6798042 | |
""" | |
_instances = {} | |
def __call__(cls, *args, **kwargs): | |
if cls not in cls._instances: | |
cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs) |
using DYMO.Label.Framework; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Printers printers = new Printers(); | |
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models, migrations | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('spigot', '0034_hydrated_connection_view_v2'), |
import requests | |
class MyApiClient(requests.Session): | |
def do_something(self): | |
response = self.post('/some/url', json={ | |
'param1': 'a', | |
'param2': 'b' | |
}) | |
if response.status_code == requests.codes.ok: |
def fib_iterative(n): | |
sequence = (0, 1) | |
if n < 2: | |
return sequence[n] | |
for _ in range(n - 2): | |
sequence = (sequence[1], sequence[0] + sequence[1]) | |
return sequence[0] + sequence[1] |
import random | |
import string | |
import re | |
allowable = re.sub(r'[IO10]', '', (string.ascii_uppercase + string.digits)) | |
def combos(place): | |
for char in allowable: |