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
# this works | |
a = lambda{ |b| b*3 } | |
# => #<Proc:0x01f5f540@(irb):125> | |
a.call 4 | |
# => 12 | |
# strangely, this does too (with a warning) | |
a.call 4, 6 | |
# (irb):125: warning: multiple values for a block parameter (2 for 1) | |
# from (irb):131 |
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
# http://woss.name/2005/09/06/bash-completion-for-mac-os-x-open/ | |
if [ "`uname`" = "Darwin" ]; then | |
_open() { | |
local cur prev | |
COMPREPLY=() | |
cur=${COMP_WORDS[COMP_CWORD]} | |
prev=${COMP_WORDS[COMP_CWORD-1]} | |
if [ "${prev}" = -a ]; then | |
local IFS=$'\n' |
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
== An elementary as hell solution to stephenfry's #L challenge: == | |
-- Get the twitter scrape from infochimps.org | |
-- http://blog.infochimps.org/2008/12/29/massive-scrape-of-twitters-friend-graph/ | |
-- (not available yet, but sometime soon) | |
-- | |
-- Then run this pig (http://wiki.apache.org/pig/) code | |
-- to extract all twitter screen names with three or more L's | |
-- It's not properly case insensitive but who cares. | |
-- |
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
# | |
# Words by L-fraction, from lull to zill to algebraically | |
# | |
# All words valid in US Scrabble that are | |
# composed of 21% or more L's (including space), | |
# sorted by descending L-fraction. For help in | |
# @stephenfry's http://hashtags.org/tag/l | |
# "L challenge" | |
# | |
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
Nested Model Forms | |
Posted by michael January 26, 2009 @ 08:55 AM | |
The most popular request on our new Feedback site was for the ability to easily manage multiple models in a single form. Thankfully Eloy Duran has a patch that does just this. But before we roll it into rails 2.3 we want to get some more feedback from you guys. Eloy's written this brief introduction to the patch, so take a look, and add any feedback you have to the lighthouse ticket. | |
In Rails it has always been a little tricky to create a single form for both a model and its associations. Last summer, the :accessible option was committed as a first stab at a unified solution for dealing with nested models. However, this feature was pulled before the 2.2 release because it only supported nested models during object creation. | |
The resulting discussion on the core mailing list and our need for mass assignment have resulted in this patch for ticket #1202 which is now up for scrutinizing. | |
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
http://github.com/binarylogic/authlogic/tree/master | |
http://www.binarylogic.com/2008/11/21/tutorial-using-openid-with-authlogic | |
http://binarylogic.lighthouseapp.com/projects/18752-authlogic/tickets | |
http://github.com/mischa/auth_store/tree/master | |
http://github.com/josh/rack-openid/tree/master | |
-------------------- | |
http://guides.rubyonrails.org/2_3_release_notes.html | |
http://weblog.rubyonrails.org/2009/1/26/nested-model-forms | |
http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes | |
http://gist.github.com/78393 |
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
// IE also doesn't set the accept headers correctly, so you have | |
// to request a file with the right extension (.js, probably). | |
// If you're not using one of the ruby remote form doodads, | |
// you'll want to ensure the form is sent to /widget/69.js | |
// and not the default /widget/69 : | |
// make forms do remote requests | |
jQuery.fn.submitWithAjax = function(){ | |
this.submit(function () { | |
// Amend the URL for submitting this form to have a .js extension |
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 FreqUser | |
class Mapper < Wukong::Streamer::StructStreamer | |
# | |
# extract just the word | |
# | |
def process thing, &block | |
next unless thing.is_a? TweetToken | |
yield [thing.user_id, thing.word] | |
end | |
end |
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
# Three more ways to cheat: | |
# Stack up all the values in a list then sum them at once: | |
require 'active_support/core_ext/enumerable' | |
class Reducer1 < Wukong::Streamer::ListReducer | |
def finalize | |
yield [ key, values.map(&:last).map(&:to_i).sum ] | |
end | |
end |
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 Wuclan::Models | |
# | |
# Text and metadata for a twitter status update | |
# | |
class Tweet < TypedStruct.new( | |
:id, | |
:created_at, | |
:twitter_user_id, | |
:favorited, |
OlderNewer