Skip to content

Instantly share code, notes, and snippets.

body {
background: #fff;
color: #343F49;
}
* {
box-sizing: border-box;
}
@boehmrya
boehmrya / find_function.sh
Last active October 17, 2019 04:29
search a directory recursively for a function name
grep -rl function_name .
@boehmrya
boehmrya / create_db.sql
Created September 15, 2019 14:31
Set-up a database for a local website
CREATE DATABASE <database_name>;
CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'database_name'@'localhost';
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 37 columns, instead of 24 in line 7.
date,speed,speed1,speed2,speed3,speed4,speed5,speed6,speed7,speed8,speed9,speed10,speed11,speed12,speed13,speed14,speed15,speed16,speed17,speed18,speed19,speed20,speed21,speed22,speed23,speed24,speed25,speed26,speed27,speed28,speed29,speed30,speed31,speed32,speed33,speed34,speed35
2007,16,14,13,12,11,10,9,8,7,6,5,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2008,33,30,27,24,22,20,18,16,14,13,12,11,20,18,16,14,13,12,11,10,9,8,7,6,12,11,10,9,8,7,6,5,4,3,2,1
2009,50,45,41,37,33,30,27,24,22,20,18,16,40,36,32,29,26,23,21,19,17,15,14,13,30,27,24,22,20,18,16,14,13,12,11,10
2010,75,70,63,57,51,46,41,37,33,30,27,24,60,54,49,44,40,36,32,29,26,23,21,19,40,36,32,29,26,23,21,19,17,15,14,13
2011,100,90,81,73,66,60,54,49,44,40,36,32,80,72,65,59,53,48,43,39,35,32,29,26,60,54,49,44,40,36,32,29,26,23,21,19
2012,305,275,248,223,221,200,180,162,146,131,118,106,100,90,81,73,66,59,53,48,43,39,35,32,80,72,65,59,53,48,43,39,35,32,29,26
2013,505,455,410,369,332,300,270,243,219,197,177,159,305,275,248,223,201,181,163,147,132,119,
@boehmrya
boehmrya / js
Created April 13, 2017 02:20
function to scroll extra if an element is out of view (on click)
var scrollExtra = function( element ) {
// takes a jquery object as input
// determines how many pixels of the elemnt are out of view
// scrolls the just enough to make the element in view
var scrollTop = jQuery(window).scrollTop();
var windowHeight = jQuery(window).height();
var elementOffset = element.offset().top;
var elementHeight = element.height();
var distance = (elementOffset - scrollTop);
var overlap = (distance + 350) - windowHeight; // 350 is the height of the teaser
@boehmrya
boehmrya / js
Created April 5, 2017 22:06
Reset Columns
var flexColLayout = function(element) {
var gridItems = jQuery(element);
var numItems = gridItems.length;
// Adjust Grid Styles
if (numItems == 3) {
gridItems.addClass('three-col');
}
else if (numItems == 2) {
gridItems.addClass('two-col');
@boehmrya
boehmrya / js
Created September 25, 2016 14:06
Remove Image Style Based on Viewport
var expanded = jQuery('.socialmediome-new .field-name-field-expanded');
expanded.each( function() {
jQuery(this).after('<div class="teaser-read-more"> > Read More</div>');
});
var readMore = jQuery('.socialmediome-new .teaser-read-more');
readMore.click(function() {
var thisReadMore = jQuery(this);
var thisExpanded = thisReadMore.prev('.socialmediome-new .field-name-field-expanded');
if (thisExpanded.css("display") == "none") {
@boehmrya
boehmrya / js
Created September 19, 2016 18:41
Form url field autopopulate in drupal webform
//Set feedback form url field to the current page's url
var formUrlField = function() {
var urlField = jQuery('#webform-component-url-of-page-defaults-to-current-page input');
var currentUrl = window.location;
urlField.val(currentUrl);
}
@boehmrya
boehmrya / gist:0718e853ea44d72b406a
Created October 4, 2015 02:05
Pull out a specified number of random items from an array
//Create the random array
$final_random_terms = array();
$random_terms = array_rand($terms, $number_terms);
foreach ($random_terms as $random_term) {
$final_random_terms[] = $terms[$random_term];
}
@boehmrya
boehmrya / gist:3d3a7f5edd83f1ac1250
Created September 24, 2015 03:02
Set Slide and Slide Caption to Always Be the Same Height
//Ensure that caption and slide are always the same height on slideshows
var slideCaption = jQuery('.view-calendar .flexslider .views-field-nothing');
var slideCaptionHeight = slideCaption.height();
console.log(slideCaptionHeight);
var slide = slideCaption.siblings('.view-calendar .flexslider .views-field-field-photo').find('img');
slide.height(slideCaptionHeight);