Skip to content

Instantly share code, notes, and snippets.

View drewrawitz's full-sized avatar

Drew Rawitz drewrawitz

View GitHub Profile
@drewrawitz
drewrawitz / elevator-challenge.md
Last active January 4, 2022 16:52
Elevator Challenge

Elevator Challenge

Create a virtual elevator that meets the following requirements:

  1. Ability to select floor 1 to 10 on a keypad.
  2. There is a representation of an elevator and a building with 10 floors. This can be as simple as 10 blocks stacked on top of each other for the floors and a different colored block that represents the elevator.
  3. A current floor display shows what floor the elevator is currently on.
  4. Upon selecting a floor on the keypad
  • The selected floor button lights up
  • The elevator begins to move to the selected floor
@drewrawitz
drewrawitz / truncate.js
Created September 29, 2016 19:53
JS Truncate without cutting off words
var truncate = function(text, characterLimit) {
if( !text || text.length < characterLimit ){ return text; }
var expressionString = "^(.{" + characterLimit + "}[^\\s]*).*";
var expression = new RegExp(expressionString);
var truncatedText = text.replace(expression, "$1");
return truncatedText + '...'
}
export const updateAlert = (alert, message) => {
return {
type: 'UPDATE_ALERT',
alert,
message
}
}
export const updateAlertThenDelete = (alert, message) => {
return function (dispatch) {
@drewrawitz
drewrawitz / automated-cache-busting.php
Created November 30, 2015 20:57 — forked from kjbrum/wp-automated-cache-busting.php
Automated Cache Busting. This works by adding the file's change time to the end of the url (last argument of the call)
<?php
/* For Themes */
wp_enqueue_style('slug', get_template_directory_uri().'/css/slug.css', array(), filemtime(get_template_directory().'/css/slug.css'));
wp_enqueue_script('slug', get_template_directory_uri().'/js/slug.js', array(), filemtime(get_template_directory().'/js/slug.js'));
/* For Plugins */
wp_enqueue_style('slug', plugin_dir_url(__FILE__).'css/slug.css', array(), filemtime(plugin_dir_path(__FILE__).'css/slug.css'));
wp_enqueue_script('slug', plugin_dir_url(__FILE__).'js/slug.js', array(), filemtime(plugin_dir_path(__FILE__).'js/slug.js'));
Atom Settings