Skip to content

Instantly share code, notes, and snippets.

View carwin's full-sized avatar
🍔
cheeseburger

Carwin Young carwin

🍔
cheeseburger
  • Missouri
View GitHub Profile
@carwin
carwin / leap_year.rb
Last active December 20, 2015 22:49
Ruby method that tells you how many minutes are in a given year.
# encoding: utf-8
# Write a method leap_year?. It should accept a year value from the user, check
# whether it is a leap year and return true or false.
# Calculate and display the number of minutes in a leap year (2000 and 2004)
# and the minutes in a non-leap year (1900 and 2005).
MINUTES_IN_HOUR = 60
MINUTES_IN_DAY = MINUTES_IN_HOUR * 24
def leap_year?
puts "Give me a year, I'll tell you if it leaps:"
def convert(temp)
(temp.to_f - 32) * 5/9
end
puts "Give it to me in Fahrenheit:"
temp = gets
puts "Here it is in Celsius: " + convert(temp).to_s
@carwin
carwin / ghfm.rb
Created March 27, 2013 11:28
GitHub Flavored Markdown Processor
#!/usr/bin/ruby
require 'rubygems'
require 'redcarpet'
require 'albino'
class SyntaxRenderer < Redcarpet::Render::HTML
def block_code(code, language)
if language && !language.empty?
Albino.colorize(code, language)
@carwin
carwin / gist:5148181
Last active December 14, 2015 20:59
Notes: Drupal 8 Mobile Initiative Meeting 32.0

Drupal Mobile Initiative Meeting 32.0

  1. Code Freeze Retrospective due on Thursday * John is doing a screencast * Shyamala's outline is: in this Google Doc * Screenshots are needed

  2. John needs to connect with js folks like _nod * there are still a lot of js related tickets.

@carwin
carwin / ci-sassy-jenkins.md
Last active December 26, 2019 14:14
Continuous Integration with Jenkins and SASS

Continuous Integration with SASS and Jenkins

This document explains how we can use Jenkins to solve some SASS/Git headaches.

The Problem at Hand

One of the problems that we deal with when working with SASS and Git is that the CSS added to the remote repository changes based on who compiled it.

That means every time someone commits to the remote repository before we can push our work up, HEAD will have changed and our push attempt will be rejected.

@carwin
carwin / gist:5093583
Created March 5, 2013 19:48
Drupal 8 CSS formatting standards, re-written to adhere to RFC documentation standards. Proposed by sun in http://drupal.org/node/1891580#comment-7128434. Original D8 CSS formatting standards document is here: http://drupal.org/node/1887862
<h2>Table of Contents</h2>
<a href="#whitespace">Whitespace</a>
<a href="#comments">Comments</a>
<a href="#format">Format</a>
<a href="#miscellaneous">Miscellaneous</a>
<a href="#example">Practical Example</a>
<h3><a name="terminology"></a>Terminology</h3>
For those unfamiliar with <a href="http://www.w3.org/TR/CSS2/syndata.html#statements">CSS terminology</a>, these are the concise terms used in these standards.
@carwin
carwin / private.xml
Last active July 27, 2017 15:06
Programmer's Shift Keys: Remapping parens, brackets and braces for to because nerd.
<?xml version="1.0"?>
<root>
<item>
<name>Programmer's Shift Keys</name>
<!--
Author: Carwin Young (@carwin)
Last Updated: 2014.07.18
v.1.1
Programmer's Shift Keys
@carwin
carwin / alter_form_weight.php
Created January 19, 2013 03:30
Textmate command to quickly modify a field's weight within `hook_form_alter`
/**
* WTF?
* - This will let you define a shortcut like
* `derp` so that when you type `derp` and
* hit TAB, you get:
* $form['field_name']['#weight'] = weight;
*
* - 'field_name' and 'weight' are variables,
* which means that Textmate will auto-focus
* your current position to the first one and
@carwin
carwin / template.php
Created December 19, 2012 15:27
Create a body class for a specific node type based on the value of a field on the node.
<?
function themename_preprocess_html(&$variables) {
// Add a body class to Articles based on the value of the 'field_article_type'
// field. e.g.: 'article-type-news' or 'article-type-blog'.
if(!empty($variables['page']['content']) && !empty($variables['page']['content']['system_main']['content']['nodes'])) {
$node = $variables['page']['content']['system_main']['content']['nodes'][arg(1)]['body']['#object'];
if(user_is_logged_in()) {
$node = $variables['page']['content']['system_main']['content']['nodes'][arg(1)]['#node'];
}
if($node->type == 'article' && !empty($node->field_article_type)) {
@carwin
carwin / Article-Node-Content.html
Created December 4, 2012 01:31 — forked from jponch-zz/Article-Node-Content.html
Sample markup for article node content
<header class="article-heading">
<div class="meta">
<span class="author">by <a href="" class="name" rel="author">Jeff Eaton</a></span><span class="date">on June 20, 2012</span> <a href="" class="short-url">Short URL</a>
</div><!-- /.meta -->
<hgroup>
<h1>Module Monday: Custom Permissions</h1>
<h2 class="subtitle">Fancy subtitle shows right here just like this when there is one.</h2>
</hgroup>
<ul class="social">
<li><a href="" class="comments">3 Comments</a></li>