save_and_open_page
have_button(locator)| GC::Profiler.enable | |
| # your code | |
| puts GC::Profiler.result | |
| # GC.disable | |
| puts ObjectSpace.count_objects.inspect |
| // Use the browser's built-in functionality to quickly and safely escape the | |
| // string | |
| function escapeHtml(str) { | |
| var div = document.createElement('div'); | |
| div.appendChild(document.createTextNode(str)); | |
| return div.innerHTML; | |
| }; | |
| // UNSAFE with unsafe strings; only use on previously-escaped ones! | |
| function unescapeHtml(escapedStr) { |
| var AutocompleteView = Backbone.View.extend({ | |
| initialize: function() { | |
| this.availableTags = [ | |
| "ActionScript", | |
| "AppleScript", | |
| "Asp", | |
| "BASIC", | |
| "C", | |
| "C++", |
| # http://docs.mongodb.org/manual/reference/bsondump/ | |
| fh = File.open("somefile.bson", "rb") | |
| while not fh.eof? do | |
| obj = BSON.read_bson_document fh | |
| id = obj.delete "_id" | |
| # assume Thing is a Mongoid::Document | |
| thing = Thing.new obj | |
| thing["_id"] = id.to_s | |
| thing.save |
| # Usage: rackup config.ru | |
| require 'gollum' | |
| require 'gollum/frontend/app' | |
| require 'puma' | |
| Precious::App.set(:gollum_path, Dir.pwd) | |
| Precious::App.set(:server, :puma) | |
| require 'mongoid' | |
| class MongoidCloseConnections | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) | |
| path = env['PATH_INFO'] || '' | |
| begin |
| #!/usr/bin/env jruby | |
| %W{rails/command/server rack webrick webrick/https}.each { |lib| require lib } | |
| ENV['HTTPS'] = 'on' | |
| module Rails | |
| class Server < ::Rack::Server | |
| def default_options | |
| super.merge({ |
| #!/usr/bin/env ruby | |
| # Usage: | |
| # git clog # prints | |
| # git clog -w # writes | |
| # | |
| # https://gist.github.com/2880525 | |
| module Clog | |
| extend self |
| var srv = sinon.fakeServer.create(); | |
| srv.autoRespond = true; // server should automatically respond after a timeout | |
| srv.autoRespondAfter = 500; // response timeout in milliseconds | |
| srv.xhr.useFitlers = true; // tell Sinon that some requests should not be faked | |
| // add a filter that will tell Sinon to allowa all requests to access the server | |
| // except fitlers defined when calling Server#fake. | |
| srv.xhr.addFilter(function(method, url, async, username, password) { | |
| var fakedRequest = _.find(Server.fakedRequests, function(request) { | |
| return request.method === method && request.regex.test(url); |