'(:cell) REPL
Cell is a toy language based on the original Lisp specification.
SnowPlow does three things:
- Identifies users, and tracks the way they engage with one or more websites
- Stores the associated data in a scalable “clickstream” data warehouse
- Makes it possible to leverage a big data toolset (e.g. Hadoop, Pig, Hive) to analyse that data
[…] a static analysis tool which checks Ruby on Rails applications for security vulnerabilities.
The ampex library takes the idea from &:symbol, and adds a little more flexibility. This means that you can get all the punctuation-free, variable-free goodness, but more often!
A few examples of how cool this can be:
# when you want to pass an argument to a method
[10, 11, 12].map(&X.to_s(16))
=> ["a", "b", "c"]
# when you want to parse some JSON
owners = [{'name' => 'Fred', 'dog' => 'Fido'},
{'name' => 'Ron', 'dog' => 'Rex'}];
owners.map(&X['name'])
=> ["Fred", "Ron"]
# when you want to chain some method calls
"alpha\nbeta\ngamma\n".lines.map(&X.strip.upcase)
=> ["ALPHA", "BETA", "GAMMA"]
[…] a utility for meta-programming Object-Oriented JavaScript.
This library adds before, after, around, and guard method combinations to underscore.js projects, in much the same style as the Common Lisp Object System or Ruby on Rails controllers.
For when you realise that the file you want to edit is owned by root.
I played around with this a few years back, and deleted it. But recently my trackpad(s) have been playing up, and it took me a while to find it again. So linking here for reference
I’ve had to jump through these hoops twice now, so saving the link here for posterity.
I needed to play around with Capybara/Selenium, but it’s a pain waiting for Firefox to start up every time you make a small change. Fortunately, I’m not the only one with the problem. Drop this somewhere:
require 'irb'
module IRB # :nodoc:
def self.start_session(binding)
unless @__initialized
args = ARGV
ARGV.replace(ARGV.dup)
IRB.setup(nil)
ARGV.replace(args)
@__initialized = true
end
workspace = WorkSpace.new(binding)
irb = Irb.new(workspace)
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
@CONF[:MAIN_CONTEXT] = irb.context
catch(:IRB_EXIT) do
irb.eval_input
end
end
end
And it’s use is quite simple. When you want to drop into an irb session, you simply do
IRB.start_session(binding)
As of Emacs 20.3, there is indeed a repeat command (C-x z) that repeats the last command. If you preface it with a prefix argument, the prefix arg is applied to the command.
You can also type C-x <ESC> <ESC> (repeat-complex-command) to reinvoke commands that used the minibuffer to get arguments. In repeat-complex-command you can type M-p and M-n (and also up-arrow and down-arrow, if your keyboard has these keys) to scan through all the different complex commands you’ve typed.
a minor mode for Emacs. It displays strings representing colors with the color they represent as background.
Using mocha with edge beta Rails 3, I added Mocha to the Gemfile
gem "mocha"
All was going swimmingly until I ran into a problem. I reduced it to:
The result of running this test was:
#test_mock_doesnt_fail should fail, but doesn’t. Changing the require lines at the top of the file to not load Rails and only load Mocha (+Rubygems+Test::Unit):
require "rubygems"
require "test/unit"
require "mocha"
caused the test to fail as expected. After an hour or two digging around, I stumbled across a post on the Mocha mailing-list that mentioned ordering problems with Mocha and Test::Unit. Sure enough, if I rearranged the modified require lines so that Test::Unit was loaded after Mocha:
require "rubygems"
require "mocha"
require "test/unit"
the test would break — I.e. wouldn’t fail.
Following the advice in the post — modified for bundler — I changed my Gemfile to read:
gem 'mocha', :require => nil
and added:
require "mocha"
to test/test_helper.rb to make sure Mocha was loaded. This isn’t strictly needed, but it’s good to be clear.
Final result, the test fails as expected, and Mocha is seems to be working properly.
‘Now will this be everything, or…’
‘Well, I might need to raise an exception.’
The compiler purses its lips. ‘An exception? Hmmm… let’s see…’
JRM at Abstract HeresiesTrying
irb> d = [1,2,3,4]
=> [1,2,3,4]
irb> d[0..-2].each_with_index {|k,i| d[i+1] = "x"; puts k }
1
2
3
=> [1,2,3]
irb> d
[1, "x", "x", "x"]
Reasonable, d[0..-2] would make a copy of d
irb> d.each_with_index {|k,i| d[i+1] = "x" if i < 3; puts k }
1
x
x
x
=> [1,2,3]
irb> d
[1, "x", "x", "x"]