Skip to content

Instantly share code, notes, and snippets.

@ellm
ellm / cool-module.js
Created January 25, 2016 19:31
JavaScript - Module Pattern Example
function CoolModule() {
var something = "cool";
var another = [1, 2, 3];
function doSomething() {
console.log( something );
}
function doAnother() {
console.log( another.join( " ! " ) );
@ellm
ellm / cool-module-2.js
Created January 28, 2016 18:36
JavaScript - Module Example using Init
var ModuleExample = {
init: function() {
var _self = this;
var varExample = $('form.variations_form');
function exampleFunction() {
console.log(this);
}
}
};
@ellm
ellm / viewport-test.js
Created February 2, 2016 20:54
JavaScript - Test for Element in Viewport
// Check to see if an element is in the viewport
function elementInViewport(el) {
var top = el.offsetTop;
var left = el.offsetLeft;
var width = el.offsetWidth;
var height = el.offsetHeight;
while (el.offsetParent) {
el = el.offsetParent;
top += el.offsetTop;
@ellm
ellm / wp-wysiwyg-test.html
Created March 2, 2016 16:20
WordPress - WYSIWYG Unit Test for CSS Styles
<h1>Heading 1</h1>
Nulla eu erat dolor. <strong>Vestibulum</strong> vel eleifend libero. Donec molestie urna posuere egestas suscipit. Nunc id porttitor nulla. Nulla facilisi. In hac habitasse platea dictumst. <a href="http://www.google.com" target="_blank">Maecenas</a> quis condimentum ipsum. Suspendisse potenti. Cras eget <em>tristique</em> nulla, nec tempus arcu. Donec pulvinar sapien a sapien lobortis, eget egestas augue interdum. Curabitur imperdiet urna et pellentesque convallis. Morbi id risus ex. Morbi condimentum gravida odio. <del>Vestibulum</del> fermentum molestie vestibulum. Phasellus pretium nulla arcu, at pellentesque diam efficitur vitae.
<h2>Heading 2</h2>
Nulla eu erat dolor. Vestibulum vel eleifend libero. Donec molestie urna posuere egestas suscipit. Nunc id porttitor nulla. Nulla facilisi. In hac habitasse platea dictumst. Maecenas quis condimentum ipsum. Suspendisse potenti. Cras eget tristique nulla, nec tempus arcu. Donec pulvinar sapien a sapien lobortis, eget egestas augue interdum.
@ellm
ellm / css-notes-and-snippets.md
Last active March 15, 2017 18:34
CSS Notes and Snippets

CSS notes and snippets

Push elements off screen

  • for UX where navigation flies in from the side of the screen or a rollup that swoops in from the bottom of the screen, use translate3d().
  • the advantage is that you do not need to know the height or width. Whereas using negative margin or top, bottom, etc requires that an exact measurement to push off screen
  • add transition: transform 0.5s to have it smoothly move in and out.
transform: translate3d(0, 100%, 0); // push off screen
@ellm
ellm / vagrant-modern-ie.md
Created March 29, 2017 19:17
Connect to localhost via Modern.ie Vagrant Box
  1. Click on Windows Start button and type in "NotePad"
  2. Right click on NotePad and click "Run as Administrator"
  3. Click File > Open and navigate to: C:\windows\system32\drivers\etc\
  4. Select "All files" to reveal "hosts" files and open it
  5. Add the following (or another localhost IP) to the bottom of hosts file

192.168.50.4 example.dev

@ellm
ellm / Command-Cheatsheet.md
Last active April 19, 2017 19:05
Command Cheatsheet

Vim

Command Description
Editing
d Cut/Delete
dd Cut/Delete entire line
p Paste line p (below) or P (above)
c Change (delete and then place into insert mode)
y Yank (copy) y or yy (copy entire line including carriage return)
@ellm
ellm / plugdj-cheerleadermode.js
Created May 18, 2018 15:13
PlugDJ - dance/woot every song automagically 👯‍♀️
const playing = document.querySelector('.community__song-playing');
const btn = document.querySelector('button.btn-like');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type == "attributes") {
btn.click();
console.log("me_debug", "playing attributes changed")
}
});
@ellm
ellm / php-note-snippets.md
Last active November 29, 2018 14:28
Php Snippets and Notes

Php Snippets and Notes

printf

I need to escape/translate text that also requires HTML within in the copy. Use printf()

    <h3><?php printf( esc_html__( 'Get our exclusive newsletter—the best of %1$s The Dude %2$s every day!', 'localdude' ), '<span>', '</span>' ); ?></h3>