Skip to content

Instantly share code, notes, and snippets.

🌴
Working from home

Adi Roiban adiroiban

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
View Multi line context call
with nested(
patch(
'chevah.server.commons.commands.copyfile',
),
patch(
'chevah.server.commons.commands.generate_ssh_key',
return_value=(0, 'message'),
),
patch.object(
local_filesystem,
@adiroiban
adiroiban / remote_proxy.yml
Created Mar 15, 2013
Idea of describing salt state for proxy minion
View remote_proxy.yml
#
# Define remote system config as a pillar
#
gateway:
host: hostname
port: 22
protocol: ssh | telnet # uses scp/ssh or rcp/rsh
ssh_key: "/path/on/local/minion"
server_fingerpring: '34:32:a4:32:32:32:a4:32:a4'
@adiroiban
adiroiban / reuse_threadpool.py
Last active Dec 15, 2015
Example to write test using multiple deferred in the same test.
View reuse_threadpool.py
class TestDatabaseHandlerSQLite(ServerTestCase):
"""
Integration tests for the SQLite database log handler.
"""
def setUp(self):
super(TestDatabaseHandlerSQLite, self).setUp()
self.pool = DBConnectionPool('sqlite://:memory:')
self.handler = DatabaseHandler(self.pool, capacity=1)
self.handler._scheduler = Clock()
View .gitconfig
[user]
name = Adi Roiban
email = adi.roiban@chevah.com
[alias]
ae = !"~/.local/opt/Sublime\\ Text\\ 2/sublime_text" ~/.gitconfig
st = status -s
ci = commit -a
cis = commit
push = push --tags
View tst.py
def __init__(self, url, pool_size_min=3, pool_size_max=8):
self._url = url
self._db_config = DBConfiguration(url)
self._pool = ConnectionPool(
self._db_config.driver_name,
cp_min=pool_size_min,
cp_max=pool_size_max,
**self._db_config.driver_arguments,
)
@adiroiban
adiroiban / in.py
Last active Dec 15, 2015
Describe an object persisted in DB using interfaces and schema.
View in.py
class IDBEventEntry(IDBTable):
message_id = schema.db.Integer(name='event_id', description='Some docstring here', lenght=12)
class DBObject(TwistarDBObject):
def getColums():
"""
Return all db columns.
"""
@adiroiban
adiroiban / gist:5442928
Created Apr 23, 2013
Reactor stop with exit code.
View gist:5442928
def _exit(self, exit_code=0):
"""
Helper method for testing.
Use os._exit() to avoid re-raising SystemExit error.
When reactor is running add a hook to be called after reactor stop.
This is mocked in tests since we can not addSystemEventTrigger
multiple times for the same reactor.
View import try
try:
from chevah import altceva
altceva
except ImportError:
altceva = None
altceva
View gist:5634931
(1375-win-envir~)$ paver lint
---> brink.pavement_commons.lint
./make-windows-environment.js
21: E:0131: Single-quoted string preferred over double-quoted string.
23: E:0131: Single-quoted string preferred over double-quoted string.
23: E:0131: Single-quoted string preferred over double-quoted string.
37: E:0131: Single-quoted string preferred over double-quoted string.
40: E:0131: Single-quoted string preferred over double-quoted string.
48: E:0131: Single-quoted string preferred over double-quoted string.
61: E:0013: No semicolon is required to end a code block
View test.py
deferrer_connection = doConnection()
deferred_connection.addCallback(lambda result: getSchemaDeferred())
deferrer_connection.addCallback(cbStartFlushing)
deferrer_connection.addErrback(ebDisableLogger)
deferrer_connection.addErrback(ebConvertUnknownErrors)
You can’t perform that action at this time.