Skip to content

Instantly share code, notes, and snippets.

Scott Vitale svvitale

Block or report user

Report or block svvitale

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
@svvitale
svvitale / Example.cs
Created Jan 23, 2018
Dymo SDK Concurrency Issues
View Example.cs
using DYMO.Label.Framework;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Printers printers = new Printers();
@svvitale
svvitale / ca.md
Created Jan 4, 2018 — forked from soarez/ca.md
How to setup your own CA with OpenSSL
View ca.md

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

View 0035_hydrated_connection_view_v3.py
# -*- 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'),
@svvitale
svvitale / standard_api_client.py
Created Nov 14, 2017
Requests.Session -> Async
View standard_api_client.py
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:
View fib.py
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]
@svvitale
svvitale / gen.py
Created Jan 24, 2017
What does this do?
View gen.py
import random
import string
import re
allowable = re.sub(r'[IO10]', '', (string.ascii_uppercase + string.digits))
def combos(place):
for char in allowable:
@svvitale
svvitale / setup.py
Created Jun 14, 2016
setup.py with -isystem includes
View setup.py
from setuptools import setup
from distutils.core import Extension
from distutils.command.build import build
import os
from subprocess import call
import multiprocessing
from glob import glob
@svvitale
svvitale / decorated_view.py
Created Mar 31, 2015
Comparison of Traditional Django Views to Decorated Views for APIs
View decorated_view.py
from django.views.generic import View
from django.shortcuts import get_object_or_404
from .decorators import json
from .models import RoomModel
from django.http import HttpResponse
class RoomView(View):
"""Room view class that implements the primary HTTP verbs (POST, GET, PUT, DELETE).
@svvitale
svvitale / Comprehension.py
Last active Aug 29, 2015
Comprehensions or Loops?
View Comprehension.py
def get(self, request):
return {
"rooms": [
{attrName: attrVal for attrName, attrVal in model_to_dict(x).items()
if attrName in RoomView.ROOM_PUBLIC_FIELDS}
for x in Room.objects.all()
]
}
@svvitale
svvitale / either_or.py
Last active Aug 29, 2015
A unittest/nose decorator for grouping tests together with an expected failure rate. A use case would be if you've written two tests, one of which should always pass. This decorator will skip failures until the expected failure count is exceeded or the grouping completes without reaching the expected failure count.
View either_or.py
import nose
import functools
_either_or_map = dict()
def either_or(key='default', expected_failures=1):
def either_or_decorator(test):
global _either_or_map
You can’t perform that action at this time.