Skip to content

Instantly share code, notes, and snippets.

<% params.reject {|k,v| !(k.to_s =~ /^fb_/)}.each_pair do | name, value | %>
<input type="hidden" name="<%= name %>" value="<%= value %>">
<% end %>
@bryfox
bryfox / fb-comments.rb
Created December 3, 2009 23:05 — forked from mjfreshyfresh/fb-comments.rb
with new link_to_app
# app_helper
def callback_attribute
if request.env['PATH_INFO']
" callbackurl='#{link_to_app(request.env['PATH_INFO'])}?_method=GET' "
end
end
# in the view
<fb:comments xid="m_story_<%= @first.id %>_comments" canpost="true" candelete="false" showform="true" numposts="5" publish_feed="false" simple="true" reverse="true" returnurl="<%= link_to_app "item/#{@first.id}" %>" <%= callback_attribute %>>
<fb:title> <%= @first.couple_name %></fb:title>
@bryfox
bryfox / fb-comments.rb
Created January 7, 2010 00:58 — forked from mjfreshyfresh/fb-comments.rb
Facebook comment callback (_method fix)
# app_helper
def callback_attribute
%{ callbackurl="#{url_for(request.path) + "?_method=GET&" + request.query_string}" }
end
# in the view
<fb:comments xid="m_story_<%= @first.id %>_comments" canpost="true" candelete="false" showform="true" numposts="5" publish_feed="false" simple="true" reverse="true" returnurl="<%= link_to_app "item/#{@first.id}" %>" <%= callback_attribute %>>
<fb:title> <%= @first.couple_name %></fb:title>
</fb:comments>
@bryfox
bryfox / list_us_timezones.rb
Created March 4, 2010 00:35
List US Timezones
require 'tzinfo'
TZInfo::Country.get('US').zone_identifiers
@bryfox
bryfox / FB_erb_stream_publish.js
Created March 17, 2010 20:41
Basic Facebook stream publishing with an image
var attachment = {
name: "Name (shows as linked text)",
href: '<%= link_to_app("models/#{@model.id}") %>',
description: "Relatively short description",
media:[
{ type: 'image',
src: '<%= @model.amazon_public_url %>',
href: '<%= link_to_app("models/#{@model.id}") %>'
}
]
module DataMapper
module Resource
def to_hash
h = {}
self.class.properties.collect {|p| p.name}.each do | property |
h[property.to_sym] = self[property]
end
h
end
# vim solution to the problem we have with actionscript files (windows-related?)
# which causes problems in some programs, including git diff
# substitute ^M characters when editing a polluted file
# The first ^M below is the string, and should be entered by typing Ctrl-V followed by Ctrl-M
# The first ^M below is a linebreak, and should be entered by typing Ctrl-V followed by Enter
:%s/^M/^M/g
# them remove the BOM
:set nobomb
@bryfox
bryfox / disclosures.css
Created November 11, 2010 19:23
Experimental css-only disclosure indicators (arrows on iOS table views)
/* experimental CSS disclosure indicators */
/* FIXME: need to be able to center this vertically */
ul.disclosure li::after,
li.disclosure::after {
-webkit-transform: rotate(45deg);
content: " ";
display: block;
width: 6px;
height: 6px;
float: right;
@bryfox
bryfox / branchnames.profile
Created December 22, 2010 02:01
Add branch names for git & hg repos to command prompt
# add to .bash_profile or somesuch
hg_branch() {
hg branch 2> /dev/null | awk '{print "(hg:"$1")"}'
}
git_branch() {
git branch 2> /dev/null | head -1 | awk '{print "(git:"$2$3")"}'
}
export PS1='\[\033[38m\]\u@\h\[\033[01;32m\] \w \[\033[31m\]$(hg_branch)$(git_branch)\[\033[37m\] $\[\033[00m\] '
'some string here'.gsub(/\b\w/){$&.upcase}