Skip to content

Instantly share code, notes, and snippets.

@davidmiani
davidmiani / gist:184306
Created September 10, 2009 04:39 — forked from anonymous/gist:184282
added safe
eval_cmd = <<EOF
$SAFE=4
#{$common_code}
#$stdout = Sandbox.new()
#{previous_commands}
$stdout = $original_stdout
#{line}
EOF
#puts eval_cmd
class Symbol
def to_proc
Proc.new { |obj, *args| obj.send(self, *args) }
end
end
$ ruby test.rb
Loaded suite NestingLevelTest
Started
........
Finished in 0.012890806 seconds.
8 tests, 9 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
Loaded suite TryRubyOutputTest
Started
@davidmiani
davidmiani / jquery.js
Created October 11, 2011 11:02
"Hello World" in javascript, using jQuery
/*!
* jQuery JavaScript Library v1.6.4
* http://jquery.com/
*
* Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
@davidmiani
davidmiani / show.html.erb_spec.rb
Created January 28, 2013 06:38
Problem with using before(:all) in a view spec
require 'spec_helper'
describe "carts/show" do
# using before(:all) rather than before(:each) causes the error:
# NoMethodError: undefined method `example_group' for nil:NilClass
# ~/.rvm/gems/ruby-1.9.3-p125/gems/rspec-rails-2.12.0/lib/rspec/rails/example/view_example_group.rb:106:in `_default_file_to_render'
# ~/.rvm/gems/ruby-1.9.3-p125/gems/rspec-rails-2.12.0/lib/rspec/rails/example/view_example_group.rb:112:in `_default_render_options'
# ~/.rvm/gems/ruby-1.9.3-p125/gems/rspec-rails-2.12.0/lib/rspec/rails/example/view_example_group.rb:45:in `render'
# show.html.erb_spec.rb:10:in `block (2 levels) in <top (required)>'
before(:each) do
@davidmiani
davidmiani / vim.js
Created August 14, 2016 03:10
Use kj for escape with codemirror vim mode
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
/**
* Supported keybindings:
*
* Motion:
* h, j, k, l
* gj, gk
* e, E, w, W, b, B, ge, gE
@davidmiani
davidmiani / .pryrc
Created December 29, 2018 09:07
Load command ll, run again with no args to reload the last command
Pry::Commands.create_command "ll" do
description "Loads a file. If no arg is passed, will reload the last file"
def process
if (args.length == 0)
if $PRY_MY_LAST_LL.nil?
output.puts "No last file, aborting"
else
load $PRY_MY_LAST_LL