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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Brilliant</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
[
["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.",
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|
=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')
#!/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

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:

@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) {