Skip to content

Instantly share code, notes, and snippets.

View matt-daniel-brown's full-sized avatar

Matthew Daniel Brown matt-daniel-brown

View GitHub Profile

Alex's Rails Cheat Sheet

I think the most confusing thing that I have found about Ruby on Rails so far has been the transition from (trying to) write code myself to the use of the fabled "Rails Magic". So, to help my own understanding of a few core Ruby on Rails concepts, I have decided to write something on what I think is a CRITICAL topic... the idea of Convention over Configuration and why (in my mind) it is the most important thing that helps Rails become magic!

(This may be a topic that we cover in more detail in class but as I said, I'm writing this for my own understanding... I hope it helps someone else understand things too... Perhaps you can give me a hand when I'm crying next week!)

##Convention over configuration ###What does this "actually" mean...

<!DOCTYPE html>
<!--[if lte IE 6]><html class="preIE7 preIE8 preIE9"><![endif]-->
<!--[if IE 7]><html class="preIE8 preIE9"><![endif]-->
<!--[if IE 8]><html class="preIE9"><![endif]-->
<!--[if gte IE 9]><!--><html><!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>title</title>
@matt-daniel-brown
matt-daniel-brown / index.pug
Created November 25, 2017 03:34
Styles For Documentation
nav
.navbar-content
#site-logo
span ◈
ul.container
li
a(href="#") Link
li
a(href="#") Link
li
@matt-daniel-brown
matt-daniel-brown / index.pug
Created November 25, 2017 03:34
Styles For Documentation
nav
.navbar-content
#site-logo
span ◈
ul.container
li
a(href="#") Link
li
a(href="#") Link
li
@matt-daniel-brown
matt-daniel-brown / .htaccess-snippet__disable-access-to-ht-files
Created October 21, 2017 16:56
Using strong pattern matching, this technique prevents external access to any file containing “.hta”, “.HTA”, or any case-insensitive combination thereof. To illustrate, this code will prevent access through any of the following requests: .htaccess, .HTACCESS, .hTaCcEsS, testFILE.htaccess, filename.HTACCESS, FILEROOT.hTaCcEsS.
# Strong pattern matching - method frome at Perishable Press:
# https://perishablepress.com/
# Using strong pattern matching, this technique prevents external access
# to any file containing “.hta”, “.HTA”, or any case-insensitive combination
# thereof, including... :
# - .htaccess
# - .HTACCESS
# - .hTaCcEsS
# - testFILE.htaccess
# - filename.HTACCESS
@matt-daniel-brown
matt-daniel-brown / index.html
Created October 14, 2017 00:50
Foldy: simplified mobile first responsive grid based on the 960 Grid.
<section id="content">
<div class="container">
<section id="introp" class="cf">
<div class="grid-full">
<h1 class="heading">Foldy</h1>
</div>
<div class="grid-2 grid-flow-opposite">
<figure>
<img src="http://placekitten.com/600/400" alt="kittens brought to you by kittens" />
<figcaption>Use <code>.grid-flow-opposite</code> for <a href="">Content Choreography</a>.</figcaption>
<!DOCTYPE html>
<title>My Example</title>
<p id="msg"></p>
<hr>
<p>The first parameter of <code>slice()</code> is a zero-based index to specify where the extraction begins. It extracts up to (but not including) the second parameter.</p>
<script>
var cities = ["Tokyo", "Auckland", "Sydney", "Brisbane", "Cairns", "London"];
@matt-daniel-brown
matt-daniel-brown / jquery-add-content-after.html
Created October 14, 2017 00:02
Simple DOM Manipulations Using jQuery.
<!DOCTYPE html>
<title>My Example</title>
<style>
.box {
background: orange;
color: white;
width: 150px;
padding: 20px;
margin: 10px;
@matt-daniel-brown
matt-daniel-brown / jquery-ajax-getjson---append-to-html.html
Last active October 13, 2017 23:57
A Few SIMPLE jQuery AJAX (to HTML) examples.
<!doctype html>
<title>Example</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
$(function() {
$("#getData").click(function() {
// Put artistList element and JSON file location into a variable
var artistList = $("#artistList");
var url = "https://www.quackit.com/jquery/examples/artists.txt";
@matt-daniel-brown
matt-daniel-brown / grid.html
Created October 13, 2017 23:54
Other mobile-first, 12 column simple grid
<!doctype html>
<title>Example</title>
<style>
.grid {
display: block;
}
.box {
color: white;
font-size: 4vw;
padding: 10px;