Skip to content

Instantly share code, notes, and snippets.

def benchmark n
a = (1..n).to_a
Benchmark.bmbm do |bb|
bb.report('a.map:') do
a.map { |x| x * x }
end
bb.report('a.reverse:') do
a.reverse
end
bb.report('a.reverse.each') do
def section_level(example_or_group)
if example_or_group.respond_to? :ancestors
example_or_group.ancestors.size
else
example_or_group.example_group.ancestors.size + 1
end
end
### Simple RPN Calculator
## supported number types: integer, float builtin, extensible
## supported operators : +, *, -, / builtin, extensible
##
##
Tramp: Waiting for prompts from remote shell
Tramp: Sending password
Tramp: Sending command `exec ssh -l root -o ControlPath=/tmp/tramp.27341nSA.%r@%h:%p -o ControlMaster=yes -e none 192.168.2.55'
Tramp: Found remote shell prompt on `192.168.2.55'
Tramp: Opening connection for root@192.168.2.55 using scpc...done
Tramp: Opening connection for root@192.168.2.55 using ssh...
Tramp: Sending command `exec ssh -l root -e none 192.168.2.55'
Tramp: Waiting for prompts from remote shell
Tramp: Sending password
Tramp: Sending command `exec ssh -l root -e none 192.168.2.55'
Tramp: Found remote shell prompt on `192.168.2.55'
Tramp: Opening connection for root@192.168.2.55 using ssh...done
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
### Simple RPN Calculator
## supported number types: integer, float builtin, extensible
## supported operators : +, *, -, / builtin, extensible
##
##
@laynor
laynor / asdf
Created April 3, 2012 17:13
try1
asdf
@laynor
laynor / gist:1996653
Created March 7, 2012 22:22
stumpwm internal loop hack
(defun stumpwm-internal-loop ()
"The internal loop that waits for events and handles them."
(loop
(run-hook *internal-loop-hook*)
(handler-bind
((xlib:lookup-error (lambda (c)
(if (lookup-error-recoverable-p)
(recover-from-lookup-error)
(error c))))
(warning #'muffle-warning)
(defun stumpwm-internal-loop ()
"The internal loop that waits for events and handles them."
(loop
(run-hook *internal-loop-hook*)
(handler-bind
((xlib:lookup-error (lambda (c)
(if (lookup-error-recoverable-p)
(recover-from-lookup-error)
(error c))))
(warning #'muffle-warning)