Skip to content

Instantly share code, notes, and snippets.

Avatar

Saulius Žemaitaitis frgtn

View GitHub Profile
@mgedmin
mgedmin / timeit-from-pdb-hack.md
Last active Sep 27, 2019
using timeit.timeit from pdb with access to a subset of local vars
View timeit-from-pdb-hack.md

= 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)
@dctrwatson
dctrwatson / JenkinsDiffEventListener.php
Last active Jan 11, 2020
Jenkins Phabricator Inegration
View JenkinsDiffEventListener.php
<?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
You can’t perform that action at this time.