Skip to content

Instantly share code, notes, and snippets.

@Ivoz
Ivoz / gist:7035239
Last active December 25, 2015 20:29
from __future__ import absolute_import, division, print_function
from cryptography.bindings import _default_api
class BlockCipher(object):
def __init__(self, cipher, mode, api=None):
super(BlockCipher, self).__init__()
if api is None:
@Ivoz
Ivoz / .gitignore
Last active December 25, 2015 19:29
_site/
bower_components/
.sass_cache/
.ruby-version
@Ivoz
Ivoz / calldules.py
Last active October 19, 2020 11:17
import ctypes
# Create a function prototype for a 3-arg function
ternaryfunc = ctypes.CFUNCTYPE(ctypes.py_object, ctypes.py_object,
ctypes.py_object, ctypes.c_void_p)
# Define a new python type that's callable, via a ternaryfunc
class PyTypeObject(ctypes.Structure):
@Ivoz
Ivoz / fixpos.py
Created September 23, 2013 19:15
import os
import sys
from os.path import join
from fabric.api import local
BASE_DIR = os.path.realpath(os.path.dirname(__file__))
BUILD_DIR = join(BASE_DIR, '_build')
SOURCE_DIR = join(BASE_DIR, 'source')
LOCALE_DIR = join(SOURCE_DIR, 'locale',
@Ivoz
Ivoz / knuth.py
Last active December 20, 2015 10:09
def up(a, b, n):
"""Calculates a ↑ⁿ b"""
if a == 1:
return 1
elif b == 1:
return a
elif n == 1:
return a**b
else:
return up(a, up(a, b - 1, n), n - 1)
@Ivoz
Ivoz / Strategist.php
Last active December 17, 2015 02:59
Phur Strategy without needing custom Interfaces, using reflection
<?php
/**
* @author Rick Wong <rick@webambition.nl>
* @contributor Matthew Iversen <teh.ivo@gmail.com>
*/
namespace Phur\Strategy;
/**
* The Strategy Pattern. It is used when your application needs to
* pick one business algorithm out of many. The behavior of your
"""Modum
Usage:
modum [options]
modum -h | --help
modum -v | --version
Options:
-h --help Show this screen.
-v --version Show version.
from gevent import wsgi
def simple_app(environ, start_response):
headers = [('Content-Type', 'text/plain')]
start_response('200 OK', headers)
def content():
# We start streaming data just fine.
yield 'The dwarves of yore made mighty spells,'
yield 'While hammers fell like ringing bells'
#!/usr/bin/env python
#
# Copyright (C) 2011, 2012, 2013 Strahinja Val Markovic <val@markovic.io>
#
# This file is part of YouCompleteMe.
#
# YouCompleteMe is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.