Skip to content

Instantly share code, notes, and snippets.

@implementation CalendarView: CPView
{
}
-(id)init {
self = [super initWithFrame:CGRectMake(0, 0, 200, 200)];
if (self) {
[self loadData];
}
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@JangoSteve
JangoSteve / ubuntu_rails_install.rb
Created January 22, 2011 17:58
Capistrano script to install Ruby, RVM, Rails in ubuntu (modified from deploy.rb scripts)
namespace :ubuntu do
desc "Setup Environment"
task :setup_env, :roles => :app do
update_apt_get
install_dev_tools
install_git
install_subversion
install_sqlite3
# Install and setup RVM instead of old Rails stack
#install_rails_stack
@phoet
phoet / renderer.rb
Last active June 19, 2023 08:59
helps finding which partial to look at in rails4
if Rails.env.development?
module My
module PartialRenderer
def render(context, options, block)
msg = "rendering '#{options[:partial]}' with locals '#{(options[:locals] || {}).keys}'"
"<!-- start #{msg}-->\n#{super(context, options, block)}\n<!-- end #{msg}-->\n".html_safe
end
end
end
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@jlebrech
jlebrech / run.sh
Created March 30, 2012 11:58
NGINX+RVM+UNICORN stack commands
echo precompile assets for production
rvmsudo RAILS_ENV=production bundle exec rake assets:precompile
echo restart unicorn
sudo kill `cat unicorn.pid`
echo start unicorn as production
rvmsudo unicorn_rails -c config/unicorn.rb -D --env production
anonymous
anonymous / decorator.rb
Created April 16, 2012 13:29
decorator - keeping it simple
class ThingDecorator < SimpleDelegator
def initialize(klass)
@model = klass
super(klass)
end
def class
@model.class
end
@vojtajina
vojtajina / all-templates.html
Created August 15, 2012 00:00
AngularJS: load all templates in one file
<script type="text/ng-template" id="one.html">
<div>This is first template</div>
</script>
<script type="text/ng-template" id="two.html">
<div>This is second template</div>
</script>
@postmodern
postmodern / rails_rce.rb
Last active July 17, 2023 11:54
Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Caveats
#
@excid3
excid3 / renderer.rb
Created August 28, 2013 22:31
Override ActionView::Renderer to inject view template/partial names into the HTML.
module ActionView
class Renderer
def render(context, options)
Rails.logger.info options.inspect
result = if options.key?(:partial)
render_partial(context, options)
else
render_template(context, options)
end