Skip to content

Instantly share code, notes, and snippets.

View nicholasf's full-sized avatar

Nicholas Faiz nicholasf

View GitHub Profile
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("]", "")
@nicholasf
nicholasf / gist:69869
Created February 24, 2009 23:24
ProfilingUtils
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("]", "")
@nicholasf
nicholasf / remove_offending.rb
Created July 7, 2009 04:49
A simple script to remove specified text from all files in a directory tree
#!/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
# 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!
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.
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
<!-- 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>
#why doesn't this exist?
class Foo
attr_accessor :two, :one
end
foo = Foo.new("two", "one")
foo.one.should eql "one"
#map the 'send' route to a controller then watch Rails break
map.connect "/send", :controller => "invitations", :action => "send"