Skip to content

Instantly share code, notes, and snippets.

View JeffreyATW's full-sized avatar

Jeffrey Carl Faden JeffreyATW

View GitHub Profile
@JeffreyATW
JeffreyATW / gist:5034913
Created February 26, 2013 01:13
Generates a nice list of names for addressing purposes
def address_name
families = []
last_names = {}
guests.each do |guest|
# Discard if name has question marks
unless guest.name =~ /\?/
names = guest.name.split(' ')
# Discard if last name isn't uppercase
if names.last =~ /[A-Z]/
# If last name ends with a period, it's a suffix
@JeffreyATW
JeffreyATW / friendly_count.rb
Last active December 20, 2015 17:09
This code was fun to write, but there's got to be an easier way to do this... right?
def friendly_count(num)
if num >= 1000000000000
'999B+'
elsif num >= 2000000000
"#{num / 1000000000}B"
elsif num >= 1100000000
"#{(num.to_f / 1000000000.0).round(1)}B"
elsif num >= 1000000000
'1B'
elsif num >= 2000000
@JeffreyATW
JeffreyATW / gist:7209085
Created October 29, 2013 04:13
Beginnings of our guest backbone app
var Guest = Backbone.Model.extend();
var Table = Backbone.Model.extend();
var firstGuest = new Guest(guests[0]);
var GuestView = Backbone.View.extend({
initialize: function () {
this.listenTo(this.model, 'change', this.render);
},
tagName: 'h1',
@JeffreyATW
JeffreyATW / getMaxZIndex.js
Created January 29, 2016 01:15
Get the maximum z-index of an element's ancestors
var getMaxZIndex = function (element, maxZIndex) {
var maxZIndex = maxZIndex || 0;
var zIndex = element.css('z-index');
if (zIndex !== 'auto') {
maxZIndex = Math.max(maxZIndex, zIndex);
}
var parent = element.parent();
if (parent[0].nodeName === 'HTML') {
return maxZIndex;
} else {
@JeffreyATW
JeffreyATW / nb.css
Created February 13, 2016 16:59
NB fullwidth image css
.copy > * {
margin-left: 30px;
margin-right: 30px;
}
.copy > .post-title {
margin-left: 30px;
margin-right: 30px;
}
@JeffreyATW
JeffreyATW / mq.html
Created March 24, 2016 21:00
Use CSS-defined media breakpoints in JS without matchMedia
<div class="mq">
<div class="mq__xs"></div>
<div class="mq__sm"></div>
<div class="mq__md"></div>
<div class="mq__lg"></div>
</div>
position:relative;
z-index:1;
/* put the above two lines at the end of the .nav rule (inside the brackets) in monsterpulse.css, lines 86-94 */
<?php
// Change these to suit your site!
$homepage = "http://example.com"; // The home page of your comic
$comic_dir = "comics"; // The folder where comic image files are kept
$news_dir = "news"; // The folder where post/news HTML files are kept
$digits = 3; // The number of digits in each comic ID. e.g. 3 for 001
// Checks whether a page exists for a given ID in the directory
// If it does, returns the file name