Skip to content

Instantly share code, notes, and snippets.

View mtorosian's full-sized avatar

Mike Torosian mtorosian

  • Fresno, California
View GitHub Profile
@rogden
rogden / functions.php
Created August 6, 2016 18:37
Wordpress - Send email new post
<?php
// add to your theme's functions.php file
// _post can be any custom post type as well. I.E. if you have a book post type it would be 'save_post_book'
add_action( 'save_post_post', function( $post_ID, $post, $update ) {
// if it is an update and not a new post, return early
if ( $update ) return;
// a new post was created, send an email out
@davatron5000
davatron5000 / blur-validate.js
Created May 28, 2015 19:34
HTML5 Validation on blur()
var inputs = document.querySelectorAll('input, textarea');
for(var i=0;i<inputs.length;i++) {
inputs[i].addEventListener('blur', function(){
if(!this.checkValidity()) {
this.classList.add('has-error');
} else {
this.classList.remove('has-error');
}
});
}
@tkadlec
tkadlec / perf.js
Created April 23, 2015 11:54
Super simple example of adding perf timing to the page display during dev work
(function () {
var perfBar = function(budget) {
window.onload = function() {
window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
var timing = window.performance.timing,
now = new Date().getTime(),
output, loadTime;
@raoulwegat
raoulwegat / gist:ded7ec7892e017b6d3c5
Created March 19, 2015 01:51
Wordpress RICG Responsive Images + Advanced Custom Fields in a Gallery + Cycle2
// Responsive Slideshow in Wordpress
// https://github.com/ResponsiveImagesCG/wp-tevko-responsive-images
// http://www.advancedcustomfields.com/pro
// http://jquery.malsup.com/cycle2/
$images = get_field('gallery');
if( $images ): ?>
<div class="cycle-slideshow"
@schilke
schilke / functions.php
Last active February 23, 2023 18:53
How to load CSS files asynchronously in WordPress (using Scott Jehl's "loadCSS")
<?php
// This is the cleaner code per request of a thread in the LinkedIn group "WordPress"
// ...
// register and enqueue loadCSS
function load_scripts_and_styles() {
// register loadCSS
wp_register_script( 'load-css-async', get_stylesheet_directory_uri() . '/path/to/js/loadCSS.js', array(), '', false );
@soul-wish
soul-wish / countries.html
Last active January 31, 2023 14:04
HTML Select List Of Countries (english and russian versions, sorted by alphabet)
<select name="countries">
<option value="United States">United States</option>
<option value="United Kingdom">United Kingdom</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
var containsClass = function (elm, className) {
if (document.documentElement.classList) {
containsClass = function (elm, className) {
return elm.classList.contains(className);
}
} else {
containsClass = function (elm, className) {
if (!elm || !elm.className) {
return false;
}
@jareware
jareware / SCSS.md
Last active April 29, 2026 16:47
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@enigmadigital
enigmadigital / dabblet.css
Created January 30, 2012 06:06
Creating a fading shadow in CSS3 with :before and :after
/**
* Creating a fading shadow in CSS3 with :before and :after
*/
html {
background: #fff;
background: linear-gradient(top, #f06 0%, #fff 100%);
background-size: auto 100px;
background-repeat: repeat-x;
padding: 20px;
}