Skip to content

Instantly share code, notes, and snippets.

View clamstew's full-sized avatar
🧘
🎨 🤖 🚀 vibe-coding 24/7. Let's Go!

Clay Stewart clamstew

🧘
🎨 🤖 🚀 vibe-coding 24/7. Let's Go!
View GitHub Profile
@clamstew
clamstew / rotating-images.html
Created May 1, 2014 06:41
I was thinking about an image rotator and started mocking one up on a small scale.
<!DOCTYPE html>
<html>
<head>
<style>
body {margin: 0;}
.container {
margin: 0 auto;
width: 800px;
background: aliceblue;
}
@clamstew
clamstew / form_for_lesson.md
Last active August 29, 2015 13:57
rough version of the form for lesson

form_for 'helper' method

Up until now we have looked at the create and update controller action in Rails in the context of using a basic <html> form tag, <form></form>.

When you wanted to POST a new movie to your Metube app:

'new' action

First you made a new controller-action in your videos controller. This action was mapped to the GET route that loaded the new video form from the views/videos/new.html.erb file with a route that looks like get "/videos/new", to: "videos#new" in the routes.rb file.

Looking at the new action in the videos controller, it's time to come clean. There was really no reason in the previous Rails CRUD lesson with the new action that we needed to hand down this instance variable:

@clamstew
clamstew / gravatar_array_loop.rb
Last active August 29, 2015 13:57
email gravatar each loop. outputs a hash of all the emails input
require 'digest/md5'
# make an email array for images you want to find
array_emails = ["email1", ...]
# make a new hash to store email:image_url as a key value pair
hash_email_image = {}
def gravatar_for(email, options = { size: 50 })
gravatar_id = Digest::MD5::hexdigest(email.downcase)
size = options[:size]
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
@clamstew
clamstew / polymorphic_associations.md
Last active February 18, 2022 13:18
A blog post on polymorphic associations. By @clamstew and @truffaut

Why Polymorphic Associations:

This was a question from @photonerddan during class, and after looking through many examples online approaching it from an inheritance stance, as well as ones with examples that seemed outside of common use-cases, Mike and I decided to approach it from a problem / solution standpoint, which looks at it from a database perspective.

We will cover it more in-depth during the second week of Rails MakerSquare, but for now here is a short example to highlight the problem that polymorphism is solving in your database.

So let's start with the problem it is solving:

Polymorphism keeps you from having excessive foreign key columns in a database table where multiple things, such as notification feed items, are owned by other objects.


Partner Exercise 4:

**View concepts we will cover: **

  • more practice with the Foundation CSS framework and writing minimal layout css
  • using partials to encapsulate parts of your layout
  • using partials and passing in local variables for repeating elements
  • using font-awesome icon set for rapid prototyping
[
{
"sha": "a26394d7481d439e41f18b5d2efd08f64daaa5d4",
"commit": {
"author": {
"name": "Xavier Noria",
"email": "[email protected]",
"date": "2014-02-19T16:53:13Z"
},
"committer": {
<div class="off-canvas-wrap">
<div class="inner-wrap">
<nav class="tab-bar">
<section class="left-small">
<a class="left-off-canvas-toggle menu-icon" ><span></span></a>
</section>
<%= render 'layouts/mobile_menu_btn' %>
<section class="middle tab-bar-section" style="">
<div style="width: 100%; text-align: left; margin-left: 0em;"><span style="font-weight: 800; font-size: 1.5em;">MAKER</span><span><%= image_tag "course/logo.png", {class: "logo", alt: "Logo", style: "margin: 0px 2px; margin-bottom: 10px;width: 30px"} %></span><span style="font-weight: 300; font-size: 1.5em;">SQUARE</span></div>
@clamstew
clamstew / javascript_callback_functions.md
Last active December 30, 2015 06:59
What Are Javascript Callback Functions? An introductory blog post that first goes over 'Functions as Arguments' then how to use those as call back functions in both javascript and jQuery. by @taylor-smith and @clamstew

#What Are Javascript Callback Functions?

###Functions as Arguments

By now it should be clear that we can pass variables and objects into Javascript functions as arguments. For example, given:

// assign the string "Bob" to a variable 'name'
var name = "Bob";
// assign a function that returns a phrase as uppercase string
@clamstew
clamstew / Eterna Boostrap
Created November 14, 2013 14:06
Eterna Boostrap full example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Eterna | Think of anything right now</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
<!-- put in font awesome -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
@clamstew
clamstew / Eterna Bootstrap
Created November 14, 2013 14:04
Full example of using bootstrap to quickly mockup eterna example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Eterna | Think of anything right now</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
<!-- put in font awesome -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">