Skip to content

Instantly share code, notes, and snippets.

View stephenscaff's full-sized avatar

Stephen Scaff stephenscaff

View GitHub Profile
@stephenscaff
stephenscaff / app.js
Created January 22, 2019 15:17
Examples of es6 export / import as class or module
// module.js
/**
* Export Default Class with static methods
* Methods have to be static to use directly on import
*/
export default class {
static color(text) {console.log(`this is color ${text}`)}
static shape(text) {console.log(`this is shape ${text}`)}
}
@font-face {
font-family: "Mallory";
src: url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAASSEABMAAAACmqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCQVNFAAEkKAAAAD4AAABQizmURUZGVE0AASRoAAAAHAAAABx6lp9nR0RFRgAAw8AAAACKAAAAukTRSQtHUE9TAADxLAAAMvkAAKz03bTxukdTVUIAAMRMAAAs3QAAT8z/q2FFT1MvMgAAAiQAAABXAAAAYGVvlZZjbWFwAAAIeAAAA1UAAATOkKZXdmN2dCAAABI4AAAAVgAAAJoHoTECZnBnbQAAC9AAAAXDAAAL4j+uHqNnYXNwAADDuAAAAAgAAAAIAAAAEGdseWYAABw0AACN9AABMeAk45KnaGVhZAAAAagAAAA2AAAANgjRvK9oaGVhAAAB4AAAACEAAAAkCTcIi2htdHgAAAJ8AAAF+wAAE+wwfNgCbG9jYQAAEpAAAAmhAAAJ+GCmqohtYXhwAAACBAAAACAAAAAgBkECLW5hbWUAAKooAAADDAAABudtaHIgcG9zdAAArTQAABaDAAAx5X0262lwcmVwAAARlAAAAKEAAACxe7dACQABAAAAAQBBcTUXlF8PPPUAHwPoAAAAANJ48IMAAAAA0nmH2/8h/v0FiwQuAAAACAACAAAAAAAAeNpjYGRgYD7wX4DhBOuW/4r/TrN2MwBFkAHLbwCr6gfOAAAAAAEAAAT7AE0ABwBfAAUAAgA2AEYAdwAAAIkBNgADAAN42mNgYUphnMDAysDA1MUUwcDA4A2hGeMYjBh1gKKMrIzMrIxMzCwKDAzsDEjALcjLn/EAA+9vJuYD/wUYTjAfYPigwMA4GSTH+IVpD5BSYOABACYtDfQAeNrtl39olVUYx7/veSfrB/5AM1db+9F1bs7N6zZj/hhz2pLmnJpw21UnqEzLUsQ/UjNc/6hYWqhJ
@stephenscaff
stephenscaff / scrollUtils.js
Created October 10, 2018 17:15
Pure JS Scroll Utilities
var scrollUtils = {
getScrollY : function() {
return (window.pageYOffset !== undefined)
? window.pageYOffset
: (window.scrollTop !== undefined)
? window.scrollTop
: (document.documentElement || document.body.parentNode || document.body).scrollTop;
},
@stephenscaff
stephenscaff / form-to-google-sheet.js
Created September 11, 2018 21:40
Google Sheet JS to accept / collect form responses
/**
* Sheet (Tab) Name.
* Sheet1 is default
*/
var sheetName = 'Sheet1'
/**
* Get property store
* all users can access within this script (only)
@stephenscaff
stephenscaff / js-template.js
Created August 2, 2018 19:06
Example - using templates in straight up js.
/**
* Render resources
* Builds out Endurance Resources (FAQ/Glossary) from a js object
* @see views/faq.html.slim & views/glossary.html.slim
*/
/** @ example tempalte
script#template-resources type="text/template"
.accordion__item id="faq{{count}}"
@stephenscaff
stephenscaff / mysql-commands.bash
Last active November 3, 2019 14:13
Basic SQL stuff that I always forget and have to google.
# Access Mysql
mysql -u mysql_username -p
# ie: mysql -u root -p
# Show db uns/pws (on DO)
cat /root/.digitalocean_password
# Dump db to root on server to current location (gen root after ssh)
mysqldump -u [username] -p [target_database_name] > [exported_database_file_name].sql
@stephenscaff
stephenscaff / hbs-helpers.js
Created July 19, 2018 23:33
Collection of Handlebars Helpers.
/**
* Debug Helper
* Logs debug info on object context
*/
Handlebars.registerHelper('debug', function(optionalValue) {
console.log('Current Context');
console.log('====================');
console.log(this);
});
@stephenscaff
stephenscaff / mysqlstuffs.shell
Last active July 9, 2018 23:35
SOme Mysql references.
# Refs
# https://dev.mysql.com/doc/refman/8.0/en/connecting.html
# Apache restart mysql
sudo service mysql restart
# Login
mysql -u root -p
@stephenscaff
stephenscaff / post-type-labels.php
Last active July 9, 2018 16:23
Utility to compile post type and custom taxonomy labels during register_post_type() and register_taxonomy().
/**
* Post Type Labels
* Utility to handle singular / plural labels of register_post_type();
* $labels = jumpoff_post_type_labels('Project', 'Projects');
*/
function jumpoff_post_type_labels( $singular = 'Post', $plural = 'Posts' ) {
$p_lower = strtolower( $plural );
$s_lower = strtolower( $singular );
return [
@stephenscaff
stephenscaff / wp-add-menu-item.php
Created July 9, 2018 16:16
Register Wp Menu Item and add Post Types to it.
/**
* Add Menu Item
* Adds a menu item to wp's main nav.
* Apply post types to our new menu item via register_post_type() arg: 'show_in_menu' => 'some-page',
*/
add_action( 'admin_menu', function(){
add_menu_page(
'Some Page',
'Some Page',