Skip to content

Instantly share code, notes, and snippets.

@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')
@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
#
@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
@kavu
kavu / example.go
Created September 28, 2013 10:01
Minimal Golang + Cocoa application using CGO. Build with `CC=clang go build`
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>
int
StartApp(void) {
[NSAutoreleasePool new];
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@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>
@pavtaras
pavtaras / webpack.config.js
Created May 15, 2017 07:08
Webpack config for AngularJS apps
var webpack = require('webpack'),
path = require('path');
module.exports = function(env){
env = env || {};
var isProd = env.isProd || false;
var config = {
context: path.resolve("./src"),
entry: {
@jbarrus
jbarrus / gulpfile.js
Last active August 7, 2017 10:12
protractor coverage support with gulp and istanbul (not tested, this is just extracted from larger files to demonstrate how to get protractor coverage working)
var istanbul = require('istanbul'),
gulp = require('gulp'),
istanbul = require('gulp-istanbul');
gulp.task('js', function() {
return gulp.src('js')
.pipe(istanbul({
includeUntested: true,
coverageVariable: '__coverage__'
}))
@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
@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