Skip to content

Instantly share code, notes, and snippets.

View frgtn's full-sized avatar

Saulius Žemaitaitis frgtn

  • Vilnius, Lithuania
View GitHub Profile
@dctrwatson
dctrwatson / JenkinsDiffEventListener.php
Last active January 11, 2020 22:56
Jenkins Phabricator Inegration
<?php
/*
* Copyright 2013 Disqus, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@mgedmin
mgedmin / timeit-from-pdb-hack.md
Last active September 27, 2019 16:32
using timeit.timeit from pdb with access to a subset of local vars

= Problem =

timeit.timeit() doesn't let you pass local vars to the code to be timed.

= Solution =

(pdb) !import sys, timeit
(Pdb) !dv = (lambda sys=sys: (lambda **kw: setattr(sys.modules['__main__'], 'VARS', kw)))()
(Pdb) !tt = lambda s, sys=sys: sys.stdout.write('%.3g ms\n' % timeit.timeit(s, 'import sys; self = sys.modules["__main__"].SELF', number=10)/10.*1000)