Skip to content

Instantly share code, notes, and snippets.

View slothelle's full-sized avatar
🦥
I miss working with @nixpad

L slothelle

🦥
I miss working with @nixpad
  • slothlandia
View GitHub Profile
@slothelle
slothelle / zoo.js
Last active December 18, 2015 11:19 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
var Zoo = {
init : function(animals) {
this.animals = animals;
},
bipeds : function() {
return this.animals.filter(function(eachAnimal) {

Web Security

This post outlines three common web security vulnerabilities with specific examples in Rails. For a more complete list, I highly recommend the OWASP Rails security cheatsheet.

Cross-Site Scripting (XSS)

A cross-site scripting attack is when malicious scripts are injected into a web site in order to compromise it.

For example, let's say we want to allow html tags such as <strong> in our blog comments, so we render raw output using the Rails method #html_safe:

#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
=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')
COURSE_ID = 5 # replace this with id of course with many (>=500) students
# generating a large course is left as an exercise to the reader
course = Course.find(COURSE_ID)
# generate quiz
q = course.quizzes.create! :title => "Big Quiz"
eval(File.read 'quiz_questions.txt').each_with_index do |(question, as), i|
answers = as.map.with_index { |a, j|
[
["The main function of myelin is to",
["form a protective coating over nerve axons.",
"affect the speed of nerve impulses.",
"block the reception of acetylcholine.",
"aid a nerve's receptivity to neurotransmitters by increasing the number of receptor sites available."]],
["The part of the nerve cell specialized for conducting information is the",
["axon.",
"cell body.",
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
@slothelle
slothelle / SassMeister-input-HTML.html
Created April 14, 2014 18:28
Generated by SassMeister.com.
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>Taco!</h1>
</body>
</html>
@slothelle
slothelle / Gemfile
Last active December 18, 2018 02:43
Deploying Rails 4 apps with Resque and Redis to Heroku using Unicorn with a Procfile.
# and whatever other gems you need
gem 'resque', '~> 1.24.1'
gem 'unicorn', '~> 4.6.2'
{
"bold_folder_labels": true,
"caret_extra_width": 1,
"caret_style": "phase",
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"draw_indent_guides": true,
"fade_fold_buttons": false,
"file_exclude_patterns":
[
".gitkeep",